#include <bits/stdc++.h>

using namespace std;

int k;
string s;
int match[(1 << 19) + 10];
long long pre[(1 << 19) + 10];
char v[(1 << 19) + 10];

int main() {

    for (int i = 0; i < (1 << 19) + 10; ++i)
        pre[i] = 1;
    

    cin >> k >> s;

    int dk = k;
    int pos = 0;
    while(dk--) {
        int ini = (1 << dk);
        for (int i = 0; i < (1 << dk); ++i, ini++) {
            match[pos++] = ini;
        }
    }

    for (int i = 0; i < (int)s.size(); ++i) {
        int cur = match[i];
        v[cur] = s[i];
        pre[cur] = 0;
    }
    

    auto update = [&]( int cur) {
        while(cur >= 1) {
            if(v[cur] == '?') 
                pre[cur] = pre[2 * cur] + pre[2 * cur + 1];

            if(v[cur] == '0')
                pre[cur] = pre[2 * cur];

            if(v[cur] == '1')
                pre[cur] = pre[2 * cur + 1];

            cur /= 2;
        }
    };

    for (int i = 0; i < (1 << (k - 1)); ++i) {
        int cur = match[i];
        update(cur);
    }

    int q;
    cin >> q;

    while(q--) {
        int x;
        char c;
        cin >> x >> c;
        x--;
        int cur = match[x];
        v[cur] = c;
        s[x] = c;
        update(cur);
        cout << pre[1] << "\n";
    }

    return 0;
}
