#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rev(i,a,b) for(int i=a;i>b;i--)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define se second
#define all(a) (a).begin(),(a).end()
#define endl '\n'
#define MOD 998244353
#define PI 3.14159265358979323846
using namespace std;
int k, up[500010], down[500010], rght[500010], n, m;
int ans[500010];
string s;
void update(int i){
    int ans_up = (i<m) ? 1:ans[up[i]], ans_down = (i<m)? 1:ans[down[i]];
    if(s[i] == '?')
        ans[i] = ans_up + ans_down;
    else if(s[i] == '0')
        ans[i] = ans_up;
    else
        ans[i] = ans_down;
}
void rec_update(int i){
    update(i);
    if(i!=n-1)
        rec_update(rght[i]);
}
void code(){
    cin>>k>>s;
    n = s.length(), m=(s.length()+1)/2;
    for(int i=0, j=m; j<n; i+=2, j++){
        rght[i]=j;
        rght[i+1]=j;
        up[j]=i;
        down[j]=i+1;
    }
    for(int i=0; i<n; i++)
        update(i);
    int q;
    cin>>q;
    while(q--){
        int i;
        char c;
        cin>>i>>c;
        i--;
        s[i]=c;
        rec_update(i);
        cout<<ans[n-1]<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
        code();
	}
}
