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
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 10:23:54 2015

@author: gangireddy
"""

#high = n-1
def buildSegmentTree(entries, segmenttree, low, high, pos):
    #print low, high, pos    
    if low == high:
        segmenttree[pos] = (entries[low] % 2)
        return
    mid = (low + high) / 2
    buildSegmentTree(entries, segmenttree, low, mid, 2*pos+1)
    buildSegmentTree(entries, segmenttree, mid+1, high, 2*pos+2)
    segmenttree[pos] = segmenttree[2*pos+1] + segmenttree[2*pos+2]

def rangeOddQuery(segmenttree, query, low, high, pos):
    if query[0] > high or query[1] < low:
        return 0
    if query[0] <= low and query[1] >= high:
        return segmenttree[pos]
    mid = (low + high) / 2
    return rangeOddQuery(segmenttree, query, low, mid, 2*pos+1) + rangeOddQuery(segmenttree, query, mid+1, high, 2*pos+2)

def updateElement(segmenttree, index, low, high, pos, val):
    #print low, high, pos
    if low == high and high == index:
        segmenttree[pos] = (val % 2)
        return
    mid = (low + high) / 2
    if index <= mid:
        updateElement(segmenttree, index, low, mid, 2*pos+1, val)
    else:
        updateElement(segmenttree, index, mid+1, high, 2*pos+2, val)
    segmenttree[pos] = segmenttree[2*pos+1] + segmenttree[2*pos+2]
    
def next2thpower(v):
    v -= 1
    v |= v>>1
    v |= v>>2
    v |= v>>4
    v |= v>>8
    v |= v>>16
    v += 1
    return v

n = int(raw_input())
arr = map(int, raw_input().split())
q = int(raw_input())
#find 2's power next to n
newn = next2thpower(n)
#print newn, n
segtree = [0]*(2*newn-1)
#lazytree = [0]*(2*newn-1)
buildSegmentTree(arr, segtree, 0, n-1, 0)
#print segtree
for query in xrange(q):
    t, x, y = map(int, raw_input().split())
    if t == 0 and (arr[x-1] % 2 != y % 2):
        #print 'updating'
        arr[x-1] = y
        updateElement(segtree, x-1, 0, n-1, 0, y)
    if t == 1:
        print (y-x)+1 - rangeOddQuery(segtree, (x-1, y-1), 0, n-1, 0)
    if t == 2:
        print rangeOddQuery(segtree, (x-1, y-1), 0, n-1, 0)