#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 3e5+10;
const int inf = 1e9+7;

int n, k, q;
char a[N], c;
int t[4*N];

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = 1;
    } else {
        int tm = (tl + tr) / 2;
        build(v + v, tm + 1, tr);
        build(v + v + 1, tl, tm);
        if (a[v] == '1') t[v] = t[v + v];
        if (a[v] == '0') t[v] = t[v + v + 1];
        if (a[v] == '?') t[v] = t[v + v + 1] + t[v + v];
    }
}

void upd(int p, char c) {
    a[n - p] = c;
    int v = n - p;
    while (v > 0) {
        if (a[v] == '1') t[v] = t[v + v];
        if (a[v] == '0') t[v] = t[v + v + 1];
        if (a[v] == '?') t[v] = t[v + v + 1] + t[v + v];
        v /= 2;
    }
}

void solve() {
    cin >> k;
    n = (1 << k);
    for (int i = 1; i < n; i++)
        cin >> a[i];
    reverse(a + 1, a + n);
//    for (int i = 1; i < n; i++)
//        cout << a[i];
//    cout << endl;
    build(1, 1, n);
    cin >> q;
    while (q--) {
        int p;
        cin >> p >> c;
        upd(p, c);
        cout << t[1] << endl;
    }
}

int main() {
    int test = 1;
    //cin >> test;
    while (test--) {
        solve();
    }
}
