Ashu and Shanu are best buddies. One day Shanu gives Ashu a problem to test his intelligence.He gives him an array of N natural numbers and asks him to solve the following queries:-

Query 0:- modify the element present at index i to x.
Query 1:- count the number of even numbers in range l to r inclusive.
Query 2:- count the number of odd numbers in range l to r inclusive.    

input:
First line of the input contains the number N. Next line contains N natural numbers. 
Next line contains an integer Q followed by Q queries.
0 x y - modify the number at index x to y.  
1 x y - count the number of even numbers in range l to r inclusive.
2 x y - count the number of odd numbers in range l to r inclusive.  

Constraints:
1 ≤ N,Q ≤ 10^5
1 ≤ l ≤ r ≤ N  
0 ≤ Ai ≤ 10^9
1 ≤ x ≤ N
0 ≤ y ≤ 10^9

Note:- indexing starts from 1.

SAMPLE INPUT
6
1 2 3 4 5 6
4
1 2 5
2 1 4
0 5 4
1 1 6

SAMPLE OUTPUT
2
2
4
import math
def cretre(low,up,pos):
	global seg
	global arr
	if up == low:
		seg[pos] = arr[low]
		return 
	mid = (up+low)/2
	cretre(low,mid,2*pos+1)
	cretre(mid+1,up,2*pos+2)
	seg[pos] = seg[2*pos+1] +seg[2*pos+2]
	return
def query(low,up,mn,mx,pos):
	global seg
	if mn>=low and mx<= up:
		return seg[pos]
	elif mn>up or mx<low:
		return 0
	mid = (mx+mn)/2
	return query(low,up,mn,mid,2*pos+1)+query(low,up,mid+1,mx,2*pos+2)
def update(ind,pos,arrlow,arrup,y):
	global seg
	if arrup== arrlow:
		seg[pos] = y
		return
	mid = (arrup+arrlow)/2
	if ind<= mid:
		update(ind,2*pos+1,arrlow,mid,y)
	else:
		update(ind,2*pos+2,mid+1,arrup,y)
	seg[pos] = seg[2*pos+1]+seg[2*pos+2]
	return
n = input()
arr = map(int,raw_input().split())
for x in xrange(n):
	arr[x] = arr[x]%2
u = int(math.ceil(math.log(n)/math.log(2)))
u = 2**(u+1)-1
seg = [0]*u
cretre(0,n-1,0)
#print seg
tst = input()
for x in xrange(tst):
	q,x,y = map(int,raw_input().split())
	if q == 2:
		w = query(x-1,y-1,0,n-1,0)
		print w
	elif q == 1:
		w = query(x-1,y-1,0,n-1,0)
		print (y-x+1)-w
	else:
		update(x-1,0,0,n-1,y%2)