#include <stdio.h>#include <iostream>#include <string>using namespace std;#define MAX 100000+200int n;__int64 c[MAX];int lowbit(int x){0 return x&(-x);}int bitcount(unsigned int n){ unsigned int c =0 ; // 计数器 for (c =0; n; n >>=1) // 循环移位 c += n &1 ; // 如果当前位是1,则计数器加1 return c ;}__int64 sum(int x){ __int64 all = 0; for(int i=x; i>0; i-=lowbit(i)) all += c[i]; return all;}void modify(int x, int val){ for(int i=x; i<n+10; i+=lowbit(i)) c[i] += val;}int main(){ //freopen("read.txt", "r", stdin); int T; scanf("%d", &T); while(T--) { scanf("%d", &n); memset(c, 0 ,sizeof(c)); __int64 tp; for(int i=1; i<=n; i++) { scanf("%I64d", &tp); modify(i, bitcount(tp)); } int command; int q; scanf("%d", &q); int a, b; for(int i=1; i<=q; i++) { scanf("%d", &command); if(command == 1) { scanf("%d%d", &a, &b); printf("%d\n", sum(b)-sum(a-1)); } else if(command == 2) { scanf("%d%d", &a, &b); modify(a, bitcount(b) - (sum(a)-sum(a-1)) ); } else if(command == 3) { scanf("%d%d", &a, &b); } } } return 0;}