#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define PB push_back
#define FI first
#define SE second
#define umap unordered_map
#define uset unordered_set
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ALL(X) (X).begin(),(X).end()
#ifndef DEBUG
#define endl (char)10
#endif
using namespace std;
using ll = long long;
using ld = long double;

void handle1(){
    string s;
    int q;
    cin >> s >> q;
    while(q--){
        int a;
        char c;
        cin >> a >> c;
        s[0] = c;
        cout << (s[0] == '?' ? 2 : 1) << endl;
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    if (k == 1){
        handle1();
        return 0;
    }
    int P = (1 << k) - 1;
    int WIN = P - 1;
    int Q = (1 << (k - 1));
    vi pot;
    int x = 1;
    while(x < P){
        pot.PB(x);
        x *= 2;
    }

    reverse(ALL(pot));
    pot.pop_back();

    vi par(P);
    vvi dz(P);
    par[WIN] = P;
    int pref = 0;
    for(int x : pot){
        FOR(i,0,x){
            par[pref + i] = x + pref + i / 2;
            dz[x + pref + i / 2].PB(pref + i);
        }
        pref += x;
    }
    string s;
    int q;
    cin >> s >> q;
    vi V(P);
    FOR(i,0,Q){
        V[i] = (s[i] == '?') + 1;
    }
    FOR(i,Q,P){
        V[i] = 0;
        if (s[i] != '1') V[i] += V[dz[i][0]];
        if (s[i] != '0') V[i] += V[dz[i][1]];
    }
    while(q--){
        int a;
        char c;
        cin >> a >> c;
        a--;
        s[a] = c;
        int p = a;
        while(p < P){
            V[p] = 0;
            if (p < Q){
                V[p] = (s[p] == '?') + 1;
            } else{
                if (s[p] != '1') V[p] += V[dz[p][0]];
                if (s[p] != '0') V[p] += V[dz[p][1]];
            }
            p = par[p];
        }
        cout << V[WIN] << endl;
    }
}
