{"problem":{"name":"Annoying String Problem","description":{"content":"For strings $S$ and $T$ consisting of lowercase English letters, and a string $X$ consisting of `0` and `1`, define the string $f(S,T,X)$ consisting of lowercase English letters as follows: *   Start","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc181_b"},"statements":[{"statement_type":"Markdown","content":"For strings $S$ and $T$ consisting of lowercase English letters, and a string $X$ consisting of `0` and `1`, define the string $f(S,T,X)$ consisting of lowercase English letters as follows:\n\n*   Starting with an empty string, for each $i=1,2,\\dots,|X|$, append $S$ to the end if the $i$\\-th character of $X$ is `0`, and append $T$ to the end if it is `1`.\n\nYou are given a string $S$ consisting of lowercase English letters, and strings $X$ and $Y$ consisting of `0` and `1`.\nDetermine if there exists a string $T$ (which can be empty) such that $f(S,T,X)=f(S,T,Y)$.\nYou have $t$ test cases to solve.\n\n## Constraints\n\n*   $1 \\leq t \\leq 5 \\times 10^5$\n*   $1 \\leq |S| \\leq 5\\times 10^5$\n*   $1 \\leq |X|,|Y| \\leq 5\\times 10^5$\n*   $S$ is a string consisting of lowercase English letters.\n*   $X$ and $Y$ are strings consisting of `0` and `1`.\n*   The sum of $|S|$ across all test cases in a single input is at most $5 \\times 10^5$.\n*   The sum of $|X|$ across all test cases in a single input is at most $5 \\times 10^5$.\n*   The sum of $|Y|$ across all test cases in a single input is at most $5 \\times 10^5$.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$t$\n$\\mathrm{case}_1$\n$\\vdots$\n$\\mathrm{case}_t$\n\nEach case is given in the following format:\n\n$S$\n$X$\n$Y$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc181_b","tags":[],"sample_group":[["3\naraara\n01\n111\naraaaa\n100100\n0010111\nabacabac\n0\n1111","Yes\nNo\nNo\n\nBelow, string concatenation is represented using $+$.\nFor the 1st test case, if $T=$`ara`, then $f(S,T,X)=S+T=$`araaraara` and $f(S,T,Y)=T+T+T=$`araaraara`, so $f(S,T,X)=f(S,T,Y)$.\nFor the 2nd and 3rd test cases, there is no $T$ that satisfies the condition."],["2\nempty\n10101\n00\nempty\n11111\n111","Yes\nYes\n\n$T$ can be empty."]],"created_at":"2026-03-03 11:01:14"}}