#include <bits/stdc++.h>
#define int long long
#define pi pair<int, int>
#define mod 1000000007
#define ss second
#define inf 1e16
#define ff first
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define forit() for (auto it = m.begin(); it != m.end(); it++)
#define srt(a) sort(a.begin(), a.end())
#define rvs(a) reverse(a.begin(), a.end())
#define pb push_back
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define fr() for (int i = 0; i < n; i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;
string a;
int ans = 0, n;
vi dp;
int dfs(int s)
{
    if (2 * s + 1 >= n)
    {
        if (a[s] == '?')
            return dp[s] = 2;
        return dp[s] = 1;
    }
    int x1 = dfs(2 * s), x2 = dfs(2 * s + 1);
    if (a[s] == '0')
        return dp[s] = x2;
    if (a[s] == '1')
        return dp[s] = x1;
    return dp[s] = x1 + x2;
}
int32_t main()
{
    fast //fast
        int t = 1;
    while (t--)
    {
        cin >> n;
        n = (1 << n);
        cin >> a;
        reverse(a.begin(), a.end());
        a = "#" + a;
        dp.resize(n + 1, 0);
        int q;
        cin >> q;
        dfs(1);
        while (q--)
        {
            int x;
            char ch;
            cin >> x;
            cin >> ch;
            x = n - x;
            // cout<<x<<endl;
            a[x] = ch;
            ans = 0;

            while (x > 0)
            {
                if (2 * x + 1 >= n)
                {
                    if (a[x] == '?')
                        dp[x] = 2;
                    else
                        dp[x] = 1;
                    x=x/2;
                    continue;
                }
                int x1 = dp[2 * x], x2 = dp[2 * x + 1];
                if (a[x] == '0')
                    dp[x] = x2;
                else if (a[x] == '1')
                    dp[x] = x1;
                else
                    dp[x] = x1 + x2;
                x = x / 2;
            }
            cout << dp[1] << endl;
        }
    }
    return 0;
}
