#include <bits/stdc++.h>

#define endl '\n'
#define IOS std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen(".//data_generator//in.txt","r",stdin),freopen("res.txt","w",stdout)
#define FI freopen(".//data_generator//in.txt","r",stdin)
#define FO freopen("res.txt","w",stdout)
#define mp make_pair
#define seteps(N) fixed << setprecision(N)
typedef long long ll;

using namespace std;
/*-----------------------------------------------------------------*/

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
#define INF 0x3f3f3f3f3f3f3f3f
const int N = 3e5 + 10;
char s[N];
int n;
int cnt[N << 2];
int k;

int ind(int x) {
    return n - x + 1;
}

void build(int rt) {
    if(rt > n) {
        cnt[rt] = 1;
        return ;
    }
    build(rt << 1 | 1);
    build(rt << 1);
    if(s[ind(rt)] == '1') {
        cnt[rt] = cnt[rt << 1];
    } else if(s[ind(rt)] == '0'){
        cnt[rt] = cnt[rt << 1 | 1];
    } else {
        cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
    }
}

void push_up(int rt) {
    if(!rt) return ;
    if(s[ind(rt)] == '1') {
        cnt[rt] = cnt[rt << 1];
    } else if(s[ind(rt)] == '0'){
        cnt[rt] = cnt[rt << 1 | 1];
    } else {
        cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
    }
    push_up(rt >> 1);
}

void upd(int rt, char type) {
    if(type == '1') {
        cnt[rt] = cnt[rt << 1];
    } else if(type == '0') {
        cnt[rt] = cnt[rt << 1 | 1];
    } else {
        cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
    }
    push_up(rt >> 1);
}

int main() {
    IOS;
    cin >> k;
    cin >> s + 1;
    n = strlen(s + 1);
    build(1);
    int q;
    cin >> q;
    while(q--) {
        int p;
        char c;
        cin >> p >> c;
        upd(ind(p), c);
        s[p] = c;
        cout << cnt[1] << endl;
    }
}
