Chef likes trees a lot. Today he has an infinte full binary tree (each node has exactly two childs) with special properties.
Chef's tree has the following special properties :

Each node of the tree is either colored red or black.
Root of the tree is black intially.
Both childs of a red colored node are black and both childs of a black colored node are red.


The root of the tree is labelled as 1. For a node labelled v, it's left child is labelled as 2*v and it's right child is labelled as 2*v+1.


Chef wants to fulfill Q queries on this tree. Each query belongs to any of the following three types:


Qi 	   Change color of all red colored nodes to black and all black colored nodes to red.
Qb x y  Count the number of black colored nodes on the path from node x to node y (both inclusive).
Qr x y  Count the number of red colored nodes on the path from node x to node y (both inclusive).

Help chef accomplishing this task.

Input
First line of the input contains an integer Q denoting the number of queries. Next Q lines of the input contain Q queries (one per line). Each query belongs to one of the three types mentioned above.

Output
For each query of type Qb or Qr, print the required answer.

Constraints


1<=Q<=10^5


1<=x,y<=10^9



Sample Input
5
Qb 4 5
Qr 4 5
Qi
Qb 4 5
Qr 4 5

Sample Output
2
1
1
2

Explanation
With the initial configuration of the tree, Path from node 4 to node 5 is 4->2->5 and color of nodes on the path is B->R->B.  

Number of black nodes are 2.
Number of red nodes are 1. 

After Query Qi, New configuration of the path from node 4 to node 5 is R->B->R.

Number of black nodes are 1.
Number of red nodes are 2. 


Scoring

 Subtask #1: 1<=Q<=100  1<=x,y<=1000   	         	                        : 27 pts
 Subtask #2: 1<=Q<=10^3  1<=x,y<=10^5       :  25 pts

 Subtask #3: 1<=Q<=10^5  1<=x,y<=10^9       :  48 pts
from math import log
var = 1

t = input()
for f in range(t):
	ta = 0
	tb = 0
	r_cnt = 0
	b_cnt = 0
	s = raw_input()
	s = s.split()
	if len(s) == 1:
		if var == 1:
			var = 0
		else:
			var = 1
	else:
		
		a = int(s[1])
		b = int(s[2])
		if s[0] == 'Qb':
			if var == 1:
				val = 1
				if (int(log(a,2)) + 1)%2 == val:
					b_cnt = b_cnt + 1
					ta = 1
				if (int(log(b,2)) + 1)%2 == val:
					b_cnt = b_cnt + 1
					tb = 1
				while(True):
					while(a < b):
						b = b/2
						if(tb == 1):
							tb = 0
						else:
							b_cnt = b_cnt + 1
							tb = 1
				
					while(b < a):
						a = a/2
						if(ta == 1):
							ta = 0
						else:
							b_cnt = b_cnt + 1
							ta = 1
					if a == b:
						if(tb == 1):
							b_cnt = b_cnt - 1
						print b_cnt
						break
			else:
				val = 0
				if (int(log(a,2)) + 1)%2 == val:
					b_cnt = b_cnt + 1
					ta = 1
				if (int(log(b,2)) + 1)%2 == val:
					b_cnt = b_cnt + 1
					tb = 1
				while(True):
					while(a < b):
						b = b/2
						if(tb == 1):
							tb = 0
						else:
							b_cnt = b_cnt + 1
							tb = 1
				
					while(b < a):
						a = a/2
						if(ta == 1):
							ta = 0
						else:
							b_cnt = b_cnt + 1
							ta = 1
					if a == b:
						if(tb == 1):
							b_cnt = b_cnt - 1
						print b_cnt
						break
		else:
			if var == 1:
				val = 0
				if (int(log(a,2)) + 1)%2 == val:
					r_cnt = r_cnt + 1
					ta = 1
				if (int(log(b,2)) + 1)%2 == val:
					r_cnt = r_cnt + 1
					tb = 1
				while(True):
					while(a < b):
						b = b/2
						if(tb == 1):
							tb = 0
						else:
							r_cnt = r_cnt + 1
							tb = 1
				
					while(b < a):
						a = a/2
						if(ta == 1):
							ta = 0
						else:
							r_cnt = r_cnt + 1
							ta = 1
					if a == b:
						if(tb == 1):
							r_cnt = r_cnt - 1
						print r_cnt
						break
			else:
				val = 1
				if (int(log(a,2)) + 1)%2 == val:
					r_cnt = r_cnt + 1
					ta = 1
				if (int(log(b,2)) + 1)%2 == val:
					r_cnt = r_cnt + 1
					tb = 1
				while(True):
					while(a < b):
						b = b/2
						if(tb == 1):
							tb = 0
						else:
							r_cnt = r_cnt + 1
							tb = 1
				
					while(b < a):
						a = a/2
						if(ta == 1):
							ta = 0
						else:
							r_cnt = r_cnt + 1
							ta = 1
					if a == b:
						if(tb == 1):
							r_cnt = r_cnt - 1
						print r_cnt
						break