#ifdef MYDEBUG
#include "pch.h"
#else
#include <bits/stdc++.h>
#endif
using namespace std;
typedef long long intl;
typedef vector<intl> vi;
typedef map<intl, intl> mii;
typedef pair<intl, intl> pii;

#define println(arg) cout << arg << endl
#define print(arg) cout << arg
#define endln cout << endl
#define inputArr(arg) for (auto& e : arg) cin >> e
#define printArr(arg) for (auto& e : arg) print(e << ' '); endln
#define printRet(arg) {	println(arg);return; }
#define all(x) (x).begin(),(x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
intl RAND(intl lo = 0, intl hi = LLONG_MAX) { return uniform_int_distribution<intl>(lo, hi)(rng); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	unsigned int t = 1;
	//cin >> t;
	void code();
	while (t--)	code();
}

constexpr intl mod = 1e9 + 7;
constexpr intl maxn = 3e5 + 1;

intl val[maxn];
string s;
intl sz;
void func(intl nd)
{
	if (nd > sz/2)
	{
		if (s[sz - nd] == '?') val[nd] = 2;
		else val[nd] = 1;
		return;
	}

	func(2 * nd + 1);
	func(2 * nd);
	if (s[sz - nd] == '?')
		val[nd] = val[2 * nd + 1] + val[2 * nd];
	else if (s[sz - nd] == '0')
		val[nd] = val[2 * nd + 1];
	else
		val[nd] = val[2 * nd];
}

void  code()
{
	intl k, q;
	cin >> k;
	cin >> s;
	cin >> q;
	sz = s.size();
	intl pp = sz - 1;
	
	func(1);

	intl id;
	char c;
	while (q--)
	{
		cin >> id >> c;
		s[id - 1] = c;
		id = (sz - id) + 1;
		
		while (id)
		{
			if (id > sz / 2)
			{
				if (s[sz - id] == '?') val[id] = 2;
				else val[id] = 1;
			}
			else
			{
				if (s[sz - id] == '?')
					val[id] = val[2 * id + 1] + val[2 * id];
				else if (s[sz - id] == '0')
					val[id] = val[2 * id + 1];
				else
					val[id] = val[2 * id];
			}
			id /= 2;
		}

		println(val[1]);
	}
}