#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 19;
int n, q;
int a[1 << mxn], f[1 << mxn];

int ff(char c){ return c != '?' ? 2 + '0' - c : 3;}

void upd(int x){
	f[x] = 0;
	for(int i = 0; i < 2; i++) f[x] += ((a[x] >> i) & 1) * f[(x << 1) | i];
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0; i < (1 << n); i++) f[(1 << n) + i] = 1;
	
	for(int i = (1 << n) - 1; i; i--){
		char c;
		cin >> c;
		a[i] = ff(c);
		upd(i);
	}
	
	cin >> q;
	
	while(q--){
		int x;
		char c;
		cin >> x >> c;
		a[x = (1 << n) - x] = ff(c);
		for(int i = x; i; i >>= 1) upd(i);
		cout << f[1] << endl;
	}
	
	return 0;
}