Comeback#12199

Comeback

2 seconds
256 megabytes
Very hard

During another timeout in CS2 on the best map — Mirage — Chmyaaaaks came up with an idea for a problem. But since he needs to pull off a comeback from a 1:12 score, he's busy and has asked you to solve it instead.

We say that a bit string , containing bits with value , majorizes another bit string , which also contains bits with value , if for every such that 1 \leq i \leq x, the position of the -th in is less than or equal to the position of the -th in . In particular, if x = 0, then majorizes .

You are given two bit strings and , each of size . You need to process two types of queries:

  1. Flip the bit at position in one of the strings.

  2. You are given two positions l_a and l_b. Your task is to find the largest pair (r_a, r_b) such that, if we set all bits outside of the segment [l_a, r_a] in to zero and outside of the segment [l_b, r_b] in to zero, the resulting and contain the same number of set bits and moreover, majorizes . Among all valid pairs, return the largest one, where the comparison is made first by r_a (larger r_a is better), and if those are equal, then by r_b.

Input

The first line contains two integers and (1 \leq n, q \leq 10^6) — the size of the arrays and the number of queries.

The second line contains a bit string of length .

The third line contains a bit string of length .

Each of the next lines describes a query of one of the following two types:

  • t, c, x where t = 1, c \in \{\textbf{a}, \textbf{b}\}, and 1 \leq x \leq n — the first type of query.

  • t, l_a, l_b where t = 2, and 1 \leq l_a, l_b \leq n — the second type of query.

Output

For each query of type , output r_a and r_b on a new line, or if there are no valid right borders.

Examples

Example 1

Loading
Loading

Note

For the first query, our subsegments are and . After setting all the other elements to zero, we obtain:

a = [00000000001100100101010000]
b = [00000000000001011001110000]

Both bit strings have exactly set bits, and it can be seen that majorizes .

Scoring

Here, Q_1 is the number of queries of type .

  1. ( points): n, q \leq 100

  2. ( points): q \leq 10

  3. ( points): Q_1 = 0

  4. ( points): l_a = l_b

  5. ( points): n, q \leq 200000

  6. ( points): no additional constraints