A. String conversion
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given two strings $$$X$$$ and $$$Y$$$ of length $$$n$$$ each, consisting of characters A and B. The following two kinds of operations can be applied on the string $$$X$$$ any (including $$$0$$$) number of times:

  • You can replace an occurrence of AA by BA.
  • You can replace an occurrence of BB by AB.

For example, you can convert ABAA to ABBA, and then ABBA to AABA.

First, find whether it is possible to convert $$$X$$$ into $$$Y$$$ using any (including 0) number of allowed operations. If it is so possible, find the minimum number of operations required for the conversion.

Then, you need to process updates of the following types:

  • X p: Flip the $$$p-$$$th character in $$$X$$$. Make it $$$\texttt{A}$$$ if it was $$$\texttt{B}$$$ before, and make it $$$\texttt{B}$$$ otherwise.
  • Y p: Flip the $$$p-$$$th character in $$$Y$$$. Make it $$$\texttt{A}$$$ if it was $$$\texttt{B}$$$ before, and make it $$$\texttt{B}$$$ otherwise.

After each update, find if it is possible to convert $$$X$$$ into $$$Y$$$. Note that, you only have to check if it is possible to convert $$$X$$$ into $$$Y$$$; you don't have to actually convert it. Also, you don't have to print the minimum number of operations required after updating, in case the conversion is possible.

Input

The first line contains $$$t (1 \le t \le 100)$$$, the number of test cases. Then, the testcases follow:

  • The first line of each testcase contains two space separated integers $$$n (1 \le n \le 3 \cdot 10^5)$$$ and $$$q (0 \le q \le 3 \cdot 10^5)$$$, the length of both the strings, and the number of updates respectively.
  • The second line contains the string $$$X$$$.
  • The third line contains the string $$$Y$$$.
  • Each of the next $$$q$$$ lines contains two values, the first of which is a character, either X or Y, and the second is an integer $$$p$$$, representing the position at which the character has to be flipped.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$. The sum of $$$q$$$ over all testcases also does not exceed $$$3 \cdot 10^5$$$.
Output

For each testcase:

  1. On the first line, print "YES" if $$$X$$$ can be converted into $$$Y$$$ using the allowed operations, before any updates have been done. Otherwise, print "NO". Then, if the conversion is possible, print a single line containing the minimum number of operations required to do so.
  2. Then, in the $$$i-$$$th of the next $$$q$$$ lines, print "YES" if it is possible to convert $$$X$$$ into $$$Y$$$, after the first $$$i$$$ updates and "NO" otherwise.
Example
Input
2
1 0
A
B
4 2
ABAA
AABA
Y 3
X 2
Output
NO
YES
2
NO
YES
Note

In the first testcase, $$$X=\texttt{A}$$$ and $$$Y=\texttt{B}$$$. Since the conversion is not possible, we print "NO" on the first line. Then, there are no updates to process ($$$Q = 0$$$), so we move to the next testcase

In the second testcase:

Number of updates$$$X$$$$$$Y$$$Possible to convert?Minimum Number of moves required
0ABAAAABAYES2
1ABAAAAAANO-
2AAAAAAAAYES0 (not to be printed)
  • Before any updates are done, $$$X$$$ is $$$\texttt{ABAA} $$$ and $$$Y$$$ is $$$\texttt{AABA}$$$, and as explained earlier, we can do the conversion as:

    ABAA $$$\rightarrow$$$ ABBA $$$\rightarrow$$$ AABA

  • After the first update, $$$X$$$ is $$$\texttt{ABAA} $$$ and $$$Y$$$ is $$$\texttt{AAAA}$$$, and the conversion is not possible.
  • After the second update, $$$X = Y = \texttt{AAAA} $$$, and the conversion is possible in $$$0$$$ operations.