#include <bits/stdc++.h>

using namespace std;

#define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int MAXN = (1LL<<20);

int cnt[MAXN];
int encode[MAXN];
int decode[MAXN];
int k,n;
string str; 

inline void init()
{
    int id = 0;
    int tk = n;
    for (int i=1;i<=k;i++)
    {
        int len = 1 << (i-1);
        for (int j=len;j>=1;j--)
        {
            encode[tk] = id + j;
            decode[id + j] = tk;
            tk--;
        }
        id = id + len;
    }

    for (int i=n+1;i<=n+n+1;i++)
        cnt[i] = 1;
    for (int i=n;i>=1;i--)
    {
        int p = i;
        if (str[decode[i]] == '1')
        {
            cnt[p] = cnt[p << 1 | 1];
        }
        else if (str[decode[i]] == '0')
        {
            cnt[p] = cnt[p << 1];
        }    
        else 
        {
            cnt[p] = cnt[p << 1 | 1] + cnt[p << 1];
        }
    }
    
}

inline void pushup(int x)
{   
    while (x != 1)
    {
        x >>= 1;
        if (str[decode[x]] == '1')
            cnt[x] = cnt[x << 1 | 1]; 
        else if (str[decode[x]] == '0')
            cnt[x] = cnt[x << 1]; 
        else 
            cnt[x] = cnt[x << 1] + cnt[x << 1 | 1]; 
    }
}

inline void solve()
{
    cin >> k;
    n = (1 << k) - 1;
    
    // for (int i=1;i<=n;i++)
    //     cout << encode[i] << "\n";
    cin >> str;
    str = " " + str;

    init();
    
    int q;  cin >> q;
    while (q--)
    {
        int tmp;char c;    cin >> tmp >> c;
        str[tmp] = c;
        int p = encode[tmp];
        //cout << p << "\n";
        if (c == '1')
        {
            cnt[p] = cnt[p << 1 | 1];
        }
        else if (c == '0')
        {
            cnt[p] = cnt[p << 1];
        }    
        else 
        {
            cnt[p] = cnt[p << 1 | 1] + cnt[p << 1];
        }
        pushup(p);
        cout << cnt[1] << "\n";
    }   
    

    return ;
}

int main()
{closeSync;
    // int T;  cin >> T;
    // while (T--)
        solve();
    return 0;
}