#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include "bits/stdc++.h"
using namespace std;

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define forstl(i,v) for(auto &i: v)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x

#define testcase(t) int t;cin>>t;while(t--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> p64;
typedef pair<int, int> p32;
typedef pair<int, p32> p96;
typedef vector<ll> vll;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<vll> vvll;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int, int> m32;

const int LIM = 2e5 + 5, MOD = 1e9 + 7;
const ld EPS = 1e-9;

void bandev() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool isPrimeSeive(ll k) {
	if (k == 1) return false;
	if (k == 2) return true;
	if (k % 2 == 0) return false;
	bitset <1000> bs;
	for (int i = 2; i <= k; i++) {
		if (bs[i] == 0) {
			for (int j = i * i; j <= k; j += i) {
				bs |= 1 << j;
			}
		}
	}
	if (bs[k]) return false;
	return true;
}

ll nthPrime(ll n) {
	if (n == 0) return 1;
	ll k = 1;
	bitset <1000> bs(3);
	for (int i = 3; i <= 1000; i += 2) {
		if (bs[i] == 0) k++;
		if (k == n) {
			return i;
		}
		if (bs[i] == 0) {
			for (int j = i * i; j <= 1000; j += i) {
				bs[j] = 1;
			}
		}
	}
	return 2;
}

int gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

void printArr(vll nw) {
	for (ll i = 0; i < nw.size(); i++)
		cout << nw[i] << " ";
	cout << endl;
}
void printMat(vvll mat) {
	for (ll i = 0 ; i < mat.size() ; i++) {
		for (ll j = 0; j < mat[i].size() ; j++) {
			printf("%d ", int(mat[i][j]));
		}
		printf("\n");
	}
	return;
}
ll sizeDecimal(ll k) {
	if (k == 0) return 1;
	ll num = 0;
	while (k > 0) {
		num++;
		k /= 10;
	}
	return num;
}

ll sz(vll arr) {
	if (arr.empty()) return 0;
	return arr.size();
}

bool isPrime(ll k) {
	if (k == 1) return false;
	if (k == 2) return true;
	if (k % 2 == 0) return false;
	for (int i = 3; i * i <= k; i += 2) {
		if (k % i == 0) return false;
	}
	return true;
}

vector<ll> dp;

ll retPow(ll n) {
	if (dp[n] > -1) return dp[n];
	if (n % 2 == 0) dp[n] = (retPow(n / 2) * retPow(n / 2)) % MOD;
	else dp[n] = (((retPow(n / 2) * retPow(n / 2)) % MOD) * 2) % MOD;
	return dp[n];
}

ll retNow(ll n, ll m) {
	if (m == 0) return 1;
	if (m % 2 == 0) return (retNow(n, m / 2) * retNow(n, m / 2)) % MOD;
	return (((retNow(n, m / 2) * retNow(n, m / 2)) % MOD) * n) % MOD;
}

ll ret(ll j) {
	if (j == 1) return 0;
	return 1 + ret(j / 2);
}

void run_case(ll t) {
	ll n;
	cin >> n;
	string str;
	cin >> str;
	ll tot = ll(pow(2, n) - 1);
	vector<string> mat;
	vvll mt;
	ll st = 0, len = ll(pow(2, n - 1));
	while (len >= 1) {
		string vec(str.begin() + st, str.begin() + st + len);
		mat.pb(vec);
		st += len;
		len /= 2;
	}
	for (ll i = 0; i < mat.size(); i++) {
		//cout << mat[i] << endl;
		vll mw;
		if (i == 0) {
			for (ll j = 0; j < mat[i].size(); j++) {
				if (mat[i][j] != '?') mw.pb(1);
				if (mat[i][j] == '?') mw.pb(2);
			}
		}
		else {
			for (ll j = 0; j < mat[i].size(); j++) {
				if (mat[i][j] == '0') {
					mw.pb(mt[i - 1][2 * j]);
				}
				else if (mat[i][j] == '1') {
					mw.pb(mt[i - 1][2 * j + 1]);
				}
				else {
					mw.pb(mt[i - 1][2 * j + 1] + mt[i - 1][2 * j]);
				}
			}
		}
		mt.pb(mw);
	}
	ll q;
	cin >> q;
	for (ll i = 0; i < q; i++) {
		ll ind;
		cin >> ind;
		char c;
		cin >> c;
		ll idx = ret(tot - ind + 1);
		ll dst = ll(pow(2, idx)) - 1 - (tot - ind) + ll(pow(2, idx) - 1);
		//cout << " ind: " << ind  << " idx: " << idx << " dst: " << dst << endl;
		mat[n - 1 - idx][dst] = c;
		// for (ll i = 0; i < mat.size(); i++) {
		// 	cout << mat[i] << endl;
		// }
		for (ll j = n - 1 - idx; j < n; j++) {
			if (j == 0) {
				if (mat[j][dst] != '?') mt[j][dst] = 1;
				if (mat[j][dst] == '?') mt[j][dst] = 2;
			}
			else {
				if (mat[j][dst] == '0') {
					mt[j][dst] = mt[j - 1][2 * dst];
				}
				else if (mat[j][dst] == '1') {
					mt[j][dst] = mt[j - 1][2 * dst + 1];
				}
				else {
					mt[j][dst] = mt[j - 1][2 * dst + 1] + mt[j - 1][2 * dst];
				}
			}
			dst = dst / 2;
		}
		cout << mt[n - 1][0] << endl;
	}
}


int main()
{
	ll n = 1;
	//cin >> n;
	for (ll i = 0; i < n; i++) {
		run_case(i + 1);
	}
	return 0;
}