#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define bakku ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod2 1000000007
#define mod 998244353
#define PI 3.1415926535897932384
#define INF LLONG_MAX
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

//first index greater than key
lli binarysearch(lli arr[], lli l, lli r, lli key)
{
    lli ans = -1; // return -1 if no element is greater than key

    if(arr[r] <= key)
        return (r+1);

    if(arr[l] > key)
        return l;

    while(l <= r)
    {
        lli m = l + (r-l+1)/2;

        if(arr[m] <= key)
            l = m + 1;

        else if(arr[m] > key)
        {
            ans = m;
            r = m - 1;
        }
    }

    return ans;
}

lli max(lli a, lli b)
{
    if(a > b) return a;
    return b;
}

lli min(lli a, lli b)
{
    if(a < b) return a;
    return b;
}

// void dfs(vector<lli> adj[], lli v, lli used[])
// {
//     used[v] = 1;
//     cout << v << " ";

//     for(lli u : adj[v])
//     {
//         if(used[u] == 0)
//             dfs(adj, u, used);
//     }

//     used[v] = 2;
// }

// palindrome
lli pal(string str)
{
    string temp = str;
    reverse(temp.begin(), temp.end());

    if(temp == str)
        return 1;

    return -1;
}

lli maxSubArraySum(lli a[], lli l, lli r) 
{ 
   lli max_so_far = a[l]; 
   lli curr_max = a[l]; 
  
   for(lli i=l+1; i<r-l+1; i++) 
   { 
        curr_max = max(a[i], curr_max+a[i]); 
        max_so_far = max(max_so_far, curr_max); 
   } 
   return max_so_far; 
}

// lli modexp(lli x, lli y, lli mod)  
// {  
//     lli res = 1;     // Initialize result  
  
//     x = x % mod; // Update x if it is more than or  
//                 // equal to p  
  
//     while (y > 0)  
//     {  
//         // If y is odd, multiply x with result  
//         if (y & 1)  
//             res = (res*x) % mod;  
  
//         // y must be even now  
//         y = y>>1; // y = y/2  
//         x = (x*x) % mod;  
//     }  
//     return res;  
// }

lli gcd(lli a, lli b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 

lli lcm(lli a, lli b)
{
    lli x = gcd(a, b);
    lli ans = (a*b)/x;
    return ans;
}

lli ncr(lli n, lli r) 
{ 
  
    // p holds the value of n*(n-1)*(n-2)..., 
    // k holds the value of r*(r-1)... 
    lli p = 1, k = 1; 
  
    // C(n, r) == C(n, n-r), 
    // choosing the smaller value 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
  
            // gcd of p, k 
            lli m = gcd(p, k); 
  
            // dividing by gcd, to simplify product 
            // division by their gcd saves from the overflow 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
  
        // k should be simplified to 1 
        // as C(n, r) is a natural number 
        // (denominator should be 1 ) . 
    } 
  
    else
        p = 1; 
  
    // if our approach is correct p = ans and k =1 
    // cout << p << endl; 

    return p;
}

lli modpow(lli x, lli y, lli p = mod)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
 
lli modadd(lli a, lli b, lli m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}
 
lli modmul(lli a, lli b, lli m = mod)
{
    return ((a % m) * (b % m)) % m;
}
 
lli modi(lli a, lli m = mod) 
{ 
    return modpow(a, m - 2, m); 
}

/*########################################################################*/
/*########################################################################*/
/*########################################################################*/
/*########################################################################*/

int main()
{
    bakku;
    lli testcases = 1;
    // cin >> testcases;
    
    while(testcases--)
    {
        lli k;
        cin >> k;
        
        lli n = pow(2, k);
        
        string s;
        cin >> s;
        
        // reverse(s.begin(), s.end());
        // s.push_back('$');
        // reverse(s.begin(), s.end());
        
        lli a[n];
        fill(a, a+n, 0);
        
        for(lli i=0; i<n/2; i++)
        {
            if(s[i] == '0' || s[i] == '1')
            {
                // a[i+n/2] = 1;
                a[n-1-i] = 1;
            }    
            
            else
            {
                // a[i+n/2] = 2;
                a[n-1-i] = 2;
            }
        }
        
        // lli save = n/4;
        // lli cur = save;
        
        for(lli i=n/2; i<n; i++)
        {
            lli ind = n-1-i;
            
            if(s[i] == '0')
            {
                // a[cur] = a[2*cur];
                a[ind] = a[2*ind + 1];
            }
            
            else if(s[i] == '1')
            {
                // a[cur] = a[2*cur + 1];
                a[ind] = a[2*ind];
            }
            
            else
            {
                // a[cur] = a[2*cur] + a[2*cur+1];
                a[ind] = a[2*ind + 1] + a[2*ind];
            }
            
            // cur++;
            
            // if(save * 2 == cur)
            // {
            //     save/=2;
            //     cur = save;
            // }
        }
        
        // for(lli i=n-1; i>=1; i--)
        // {
        //     cout << i << ": " << a[i] << endl;
        // }
        
        // cout << "*****\n";
        
        lli q;
        cin >> q;
        
        for(lli i=0; i<q; i++)
        {
            lli p; char c;
            
            cin >> p >> c;
            p--;
            
            s[p] = c;
            
            lli ind = n-1-p;
            
            if(s[p] == '0')
            {                
                if(2*ind+1 < n)
                    a[ind] = a[2*ind+1];
                    
                else 
                    a[ind] = 1;                 
            } 
            
            else if(s[p] == '1')
            {
                if(2*ind < n)
                    a[ind] = a[2*ind];
                    
                else
                    a[ind] = 1;
            }
            
            else 
            {
                if(2*ind+1 < n)
                    a[ind] = a[2*ind + 1] + a[2*ind];
                    
                else
                    a[ind] = 2;
            }
            
            ind /= 2;
            
            while(ind != 0)
            {
                p = n-1-ind;
                
                if(s[p] == '0')
                {                
                    if(2*ind+1 < n)
                        a[ind] = a[2*ind+1];
                        
                    else 
                        a[ind] = 1;
                } 
                
                else if(s[p] == '1')
                {
                    if(2*ind < n)
                        a[ind] = a[2*ind];
                        
                    else
                        a[ind] = 1;
                }
                
                else 
                {
                    if(2*ind+1 < n)
                        a[ind] = a[2*ind + 1] + a[2*ind];
                        
                    else
                        a[ind] = 2;
                }         
                
                ind /= 2;       
            }
            
            cout << a[1] << endl;
        }
    }

    return 0;
}
