#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1 << 18;

#define ls (p << 1)
#define rs (ls | 1)
#define tm ((tl + tr) >> 1)

string t;
char s[N << 2];
int n, a[N << 2];
int sum[N << 2];

void up(int p) {
    if (s[p] == '1') {
        sum[p] = sum[ls];
    } else if (s[p] == '0') {
        sum[p] = sum[rs];
    } else if (s[p] == '?') {
        sum[p] = sum[ls] + sum[rs];
    }
    // cerr << "sum[" << p << "] = " << sum[p] << " ";
    // cerr << "sum[" << ls << "] = " << sum[ls] << " ";
    // cerr << "sum[" << rs << "] = " << sum[rs] << "\n";
}

void build(int p) {
    if (n - p + 1 > 0 && n - p + 1 <= n) {
        // cerr << "n = " << n << '\n';
        // cerr << "p = " << p << " tl = " << tl << " tr = " << tr;
        // cerr << " s[" << p << "] = " << " t[" << n - p + 1 << "] = " << t[n - p + 1] << '\n';
        s[p] = t[n - p + 1];
        a[n - p + 1] = p;
    }
    sum[p] = 1;
    // cerr << "sum[" << p << "] = " << sum[p] << '\n';
    // cerr << "p = " << p << " ls = " << ls << " rs = " << rs << '\n';
    if (ls <= 2 * n) {
        build(ls);
        build(rs);
        up(p);
    }
}

void modify(int p, int pos, char v) {
    // cerr << "p = " << p << " tl = " << tl << " tr = " << tr << " pos = " << pos << " v = " << v << '\n';
    // if (tl > tr || tl < 0 || tr > n || p < 0 || p > n) return;
    if (p == pos) {
        s[p] = v;
    }
    up(p);
    if ((p >> 1) > 0 && (p >> 1) <= n) modify(p >> 1, pos, v);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    int k;
    cin >> k;
    cin >> t;
    n = t.size();
    t = " " + t;
    // cerr << "n = " << n << '\n';
    build(1);
    int q;
    cin >> q;
    // cout << sum[1] << '\n';
    while (q--) {
        int p;
        char c;
        cin >> p >> c;
        // cout << "a[" << p << "] = " << a[p] << '\n';
        modify(a[p], a[p], c);
        cout << sum[1] << '\n';
    }
    return 0;
}