import std.stdio;
import std.ascii;
import std.string;
import std.range;
import std.algorithm;
import core.stdc.stdio;

int main()
{
    int k = readInt!int;
    char[] s = readString.dup.reverse;
    int n = cast(int)s.length;
    int q = readInt!int;

    long[] pos = new long[](n + 1);
    void calculate(int v)
    {
        if (v * 2 > s.length)
        {
            if (s[v - 1] == '0' || s[v - 1] == '1') pos[v] = 1;
            else pos[v] = 2;
            return;
        }
        int left = 2 * v;
        int right = 2 * v + 1;
        calculate(left);
        calculate(right);
        if (s[v - 1] == '1')
        {
            pos[v] = pos[left];
        }
        else if (s[v - 1] == '0')
        {
            pos[v] = pos[right];
        }
        else
        {
            pos[v] = pos[right] + pos[left];
        }
    }
    calculate(1);
    foreach(qi; 0 .. q)
    {
        int p = n - readInt!int + 1;
        string ch = readString;
        s[p - 1] = ch[0];
        while (p >= 1)
        {
            if (p * 2 >= n)
            {
                if (s[p - 1] == '0' || s[p - 1] == '1') pos[p] = 1;
                else pos[p] = 2;
                goto done;
            }
            if (s[p - 1] == '1')
            {
                pos[p] = pos[2 * p];
            }
            else if (s[p - 1] == '0')
            {
                pos[p] = pos[2 * p + 1];
            }
            else
            {
                pos[p] = pos[2 * p] + pos[2 * p + 1];
            }
            done:
            p /= 2;
        }
        pos[1].writeln;
    }
    return 0;
}


/* INPUT ROUTINES */
int currChar;
static this()
{
    currChar = getchar();
}
char topChar()
{
    return cast(char) currChar;
}
void popChar()
{
    currChar = getchar();
}
auto readInt(T)()
{
    T num = 0;
    int sgn = 0;
    while (topChar.isWhite) popChar;
    while (topChar == '-' || topChar == '+') { sgn ^= (topChar == '-'); popChar; }
    while (topChar.isDigit) { num *= 10; num += (topChar - '0'); popChar; }
    if (sgn) return -num; return num;
}
string readString()
{
    string res = "";
    while (topChar.isWhite) popChar;
    while (!topChar.isWhite) { res ~= topChar; popChar; }
    return res;
}
/**MODULAR SYSTEM*/
struct Z(immutable long m)
{
    long rep;
    this(long num)
    {
        rep = num;
    }
    Z!m opBinary(string operator)(Z!m rhs)
    {
        static if (operator == "+")
        {
            long result = rhs.rep + this.rep;
            if (result >= m) result -= m;
            return Z!m(result);
        }
        else static if (operator == "-")
        {
            long result = this.rep - rhs.rep;
            if (result < 0) result += m;
            return Z!m(result);
        }
        else static if (operator == "*")
        {
            long result = this.rep * rhs.rep;
            if (result >= m) result %= m;
            return Z!m(result);
        } else static assert(text("Operator ", operator, " not supported"));
    }
    Z!m opBinary(string operator)(long exponent) if (operator == "^^")
    {
        assert(exponent >= 0);
        Z!m base = this;
        Z!m result = 1;
        while (exponent)
        {
            if (exponent & 1)
                result = result * base;
            base = base * base;
            exponent >>= 1;
        }
        return result;
    }
    invariant
    {
        assert(rep >= 0 && rep < m);
    }
}
