# include <bits/stdc++.h>
//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>
# define ull unsigned long long int
# define ll long long
# define ld long double
# define pb push_back
# define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//# define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

ll const mod = 998244353;
using namespace std;
//using namespace __gnu_pbds;

ll power(ll x, ll y){

    ll res = 1;
    x %= mod;

    if (x == 0){
        return 0;
    }

    while (y > 0){
        if (y & 1){
            res = (res * x) % mod;
        }
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

vector <ll> prime;

void Sieve(ll n){
    bool pri[n + 1];
    memset(pri, true, sizeof(pri));

    for (ll p = 2; p * p <= n; p++){
        if (pri[p] == true){
            for (ll i = p * p; i <= n; i += p){
                pri[i] = false;
            }
        }
    }
    for (ll p = 2; p <= n; p++){
        if (pri[p] == true){
            prime.pb(p);
        }
    }
}

map <ll, ll> fact;

void primeFactors(ll n){ 
    
	while (n % 2 == 0){
		fact[2]++;
		n /= 2;
	}	
 
	for (ll i = 3; i * i <= n; i++){
		while (n % i == 0){
			fact[i] ++;
			n /= i;
		}
	}
	
	if (n != 1){
		fact[n] = 1;
	}   
} 


void solve(){
	
	ll k;
	cin >> k;
	ll firstround = pow (2, k) / 2;
	string s;
	cin >> s;
	reverse (s.begin(), s.end());
	
	ll n = s.size();
	ll tree[n];
	for (ll i = n - 1; i >= 0; i--){
		if (i >= n / 2){
			if (s[i] == '?'){
				tree[i] = 2;
			}
			else{
				tree[i] = 1;
			}
		}
		else{
			if (s[i] == '?'){
				tree[i] = tree[2 * i + 1] + tree[2 * i + 2];
			}
			else if (s[i] == '1'){
				tree[i] = tree[2 * i + 1];
			}
			else{
				tree[i] = tree[2 * i + 2];
			}
		}
	}
	
	ll q;
	cin >> q;
	
	while (q--){
		ll pos;
		char ch;
		cin >> pos >> ch;
		pos = n - pos;
		s[pos] = ch;
		while (pos != 0){
			if (pos >= n / 2){
				if (s[pos] == '?'){
					tree[pos] = 2;
				}
				else{
					tree[pos] = 1;
				}
				pos = (pos - 1) / 2;
				continue;
			}
			
			if (s[pos] == '?'){
				tree[pos] = tree[2 * pos + 1] + tree[2 * pos + 2];
			}
			else if (s[pos] == '1'){
				tree[pos] = tree[2 * pos + 1];
			}
			else{
				tree[pos] = tree[2 * pos + 2];
			}
			pos = (pos - 1) / 2;
		}
		if (n > 1){
			if (s[0] == '?'){
				tree[0] = tree[1] + tree[2];
			}
			else if (s[0] == '1'){
				tree[0] = tree[1];
			}
			else{
				tree[0] = tree[2];
			}
		}
		else{
			if (s[pos] == '?'){
				tree[pos] = 2;
			}
			else{
				tree[pos] = 1;
			}
		}
		
		cout << tree[0] << endl;
	}	
	
}
	
int main(){
   	IOS
    //Sieve(1500);
    int t = 1;
    //std::cout << std::fixed;
    //std::cout << std::setprecision(50) << ans;
//	cin >> t;

    while (t--){
        solve();
    }

}

