#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10, mod = 1e9 + 7;
void solve() {
    int k; string s;
    cin >> k >> s, s = " " + s;
    vector<int>par(1 << k), L(1 << k), R(1 << k), f(1 << k);
    for (int i = 1, x = 1, y = (1 << (k - 1)) + 1; i < k; ++i) {
        for (int j = 0; j < (1 << (k - i)); ++j) {
            par[j + x] = j / 2 + y;
            (j & 1 ? R : L)[j / 2 + y] = j + x;
        }
        x = y;
        y += (1 << (k - 1 - i));
    }
    auto up = [&](int i) {
        f[i] = 0;
        if (i <= (1 << (k - 1)))f[i] = 1 + (s[i] == '?');
        else {
            if (s[i] != '1')f[i] += f[L[i]];
            if (s[i] != '0')f[i] += f[R[i]];
        }
    };
    for (int i = 1; i < (1 << k); ++i)up(i);
    int _; for (cin >> _; _--;) {
        int p; string c;
        cin >> p >> c;
        for (s[p] = c[0] ; p; p = par[p])up(p);
        cout << f.back() << "\n";
    }
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    solve();
    return 0;
}