Problem: Ikta, who was in trouble because he couldn't come up with an idea for the problem to be presented at the training camp of the programming contest, consulted with a friend one day.

Mr. Ikta "I want to create a problem that cannot be solved without using such an algorithm. Is there anything?"

Friend "Then why not think about something like this?"

In this way, the friend came up with the idea that would be the basis for the following problems.

Given binary numbers A and B, process the following query.

* Output query: Outputs the number of 1s when max {x is expressed in binary | A ≤ x <A + B}
* A change query: Inverts the i-th bit (0-origin) from the least significant bit of A
* B change query: Inverts the i-th bit (0-origin) from the least significant bit of B



Note that the i-bit is represented by 0-origin. That is, the 0th bit from the least significant bit of A represents the least significant bit.



Input

The input is given in the following format.


N A B
Q1
...
QN

The number of queries N, binary numbers A and B are given in the first line.

The following query is given in the 2nd to N + 1 lines.

* Q
* A i
* B i



Q represents the output query, and A i and B i represent the change query that inverts the i-th bit from the least significant bit of A and the i-th bit from the least significant bit of B, respectively.

Constraints

Each variable being input satisfies the following constraints.

* 1 ≤ N <300,000
* 1 ≤ | A |, | B | ≤ 300,000 (| A | is the length of A)
* In the query A i, 0 ≤ i <| A |
* In the query B i 0 ≤ i <| B |
* B can never be 0

Output

Print the answer on one line for each output query.

Examples

Input

4 10000 00101
Q
A 0
B 1
Q


Output

3
4


Input

9 0110111101 0010100111
Q
B 4
Q
A 4
Q
B 9
Q
A 8
Q


Output

9
9
9
10
9

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct BinaryIndexedTree{
	int n;
	vector<int>dat;
	BinaryIndexedTree(int n=0):n(n){
		dat.resize(n+1);
	}
	void add(int k,int x){
		for(k++;k<=n;k+=k&-k)dat[k]+=x;
	}
	int sum(int k){
		int ret=0;
		for(k++;k;k-=k&-k)ret+=dat[k];
		return ret;
	}
};

int Q;
int A[666666],B[666666];

signed main(){

    cin>>Q;
    string s;
    cin>>s;reverse(all(s));
    for(int i=0;i<s.size();i++)A[i]=s[i]=='1';
    cin>>s;reverse(all(s));
    for(int i=0;i<s.size();i++)B[i]=s[i]=='1';

    set<int>b;
    set<int>latte,beet;
    BinaryIndexedTree bit(666666+114);
    for(int i=0;i<666666;i++){
        bit.add(i,A[i]);
        if(B[i])b.insert(i);
        if(A[i]==1&&B[i]==1)latte.insert(i);
        if(A[i]==0&&B[i]==0)beet.insert(i);
    }
    latte.insert(-2);
    beet.insert(-1);

    while(Q--){
        char c;cin>>c;
        if(c=='Q'){
            int x=*b.rbegin();

            auto it=latte.upper_bound(x);
            it--;
            auto jt=beet.upper_bound(x);
            jt--;
            if(*it>*jt){
                cout<<bit.sum(666666)-bit.sum(x)+x+1<<endl;
            }
            else{
                cout<<bit.sum(666666)-bit.sum(x)+x<<endl;
            }
        }
        else if(c=='A'){
            int x;cin>>x;
            if(A[x]&&B[x])latte.erase(x);
            if(!A[x]&&!B[x])beet.erase(x);
            bit.add(x,-A[x]);

            A[x]^=1;
            if(A[x]&&B[x])latte.insert(x);
            if(!A[x]&&!B[x])beet.insert(x);
            bit.add(x,A[x]);
        }
        else{
            int x;cin>>x;
            if(A[x]&&B[x])latte.erase(x);
            if(!A[x]&&!B[x])beet.erase(x);
            if(B[x]==1)b.erase(x);
            else b.insert(x);

            B[x]^=1;
            if(A[x]&&B[x])latte.insert(x);
            if(!A[x]&&!B[x])beet.insert(x);
        }
    }
    return 0;
}