#include <bits/stdc++.h>
#define For(i, a, b) for (int i = (a), _##i = (b); i < _##i; ++i)
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define Forr(i, a, b) for (int i = (a), _##i = (b); i > _##i; --i)
#define FORR(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define all(a) a.begin(), a.end()
#define range(i, a) for (auto& i : a)
#define RANGE(i, a) for (auto i = a.rbegin(); i != a.rend(); ++i)
#define SINGLE
using ll = long long;
using pii = std::pair<int, int>;
using pdd = std::pair<double, double>;

namespace Solver {
  const int N = (1 << 18) + 5;
  std::string opt;
  int res[N << 1];
  int n, cnt;
  void update(int p, char c) {
    if (opt[p] == c)
      return;
    opt[p] = c;
    // if (c == '?')
    //   res[p] = res[p << 1] + res[p << 1 | 1];
    while (p) {
      if (opt[p] == '?')
        res[p] = res[p << 1] + res[p << 1 | 1];
      else if (opt[p] == '1')
        res[p] = res[p << 1];
      else
        res[p] = res[p << 1 | 1];
      p >>= 1;
    }
  }
  void build(int u) {
    if ((u << 1) <= cnt)
      build(u << 1);
    if ((u << 1 | 1) <= cnt)
      build(u << 1 | 1);
    if (opt[u] == '?')
      res[u] = res[u << 1] + res[u << 1 | 1];
    else if (opt[u] == '1')
      res[u] = res[u << 1];
    else
      res[u] = res[u << 1 | 1];
  }
  void main() {
    std::cin >> n;
    std::string temp;
    std::cin >> temp;
    std::fill(res, res + (N << 1) - 1, 1);
    cnt = (1 << n) - 1;
    opt = " ";
    RANGE (i, temp)
      opt.push_back(*i);
    build(1);
    int T;
    for (std::cin >> T; T--;) {
      int p;
      char c;
      std::cin >> p >> c;
      update(cnt - p + 1, c);
      std::cout << res[1] << std::endl;
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  #ifndef SINGLE
  int T;
  for (std::cin >> T; T--;)
  #endif
    Solver::main();
  return 0;
}