#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(44);

struct node {
	char c;
	int sum;
	node() {}
};

int k, q, p;
char c;
string s;
node t[1 << 19];
map <int, int> old_pos_new_pos;

void my_reverse(string& s, int l, int r) {
	int len = r - l + 1;
	int i = 0;
	while (len > 0) {
		swap(s[l + i], s[r - i]);
		old_pos_new_pos[l + i] = r - i;
		old_pos_new_pos[r - i] = l + i;
		i++;
		len -= 2;
	}
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("lca_rmq.in", "r", stdin);
	//freopen("lca_rmq.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> k >> s;
	int ma_len = (1 << k);
	int len = 1;
	reverse(s.begin(), s.end());
	while (len < ma_len) {
		my_reverse(s, len - 1, len + len - 2);
		len <<= 1;
	}
	int cnt = (1 << (k - 1));
	for (int i = s.length(); i >= 1; i--) {
		t[i].c = s[i - 1];
		cnt--;
		if (cnt >= 0)
			if (t[i].c == '?')
				t[i].sum = 2;
			else
				t[i].sum = 1;
		else {
			if (t[i].c == '0')
				t[i].sum = t[2 * i].sum;
			if (t[i].c == '1')
				t[i].sum = t[2 * i + 1].sum;
			if (t[i].c == '?')
				t[i].sum = t[2 * i + 1].sum + t[2 * i].sum;
		}
	}
	cin >> q;
	while (q--) {
		cin >> p >> c;
		p = s.length() - p;
		p = old_pos_new_pos[p];
		p++;
		t[p].c = c;
		if (p >= (1 << (k - 1))) {
			if (c == '?')
				t[p].sum = 2;
			else
				t[p].sum = 1;
			p >>= 1;
		}
		while (p >= 1) {
			c = t[p].c;
			if (c == '0')
				t[p].sum = t[2 * p].sum;
			if (c == '1')
				t[p].sum = t[2 * p + 1].sum;
			if (c == '?')
				t[p].sum = t[2 * p].sum + t[2 * p + 1].sum;
			p >>= 1;
		}
		cout << t[1].sum << '\n';
	}
	return 0;
}