#include <bits/stdc++.h>
using namespace std;

struct fT {
	long long ans;
	char now;
};

vector <fT> tree;



void build(int x, int n) {
	if ((2 * x + 1) >= n) {
		if (tree[x].now == '?')
			tree[x].ans = 2;
		else
			tree[x].ans = 1;
		return;
	}
	build(2 * x + 1, n);
	build(2 * x + 2, n);
	if (tree[x].now == '?')
		tree[x].ans = tree[2 * x + 1].ans + tree[2 * x + 2].ans;
	else if (tree[x].now == '1')
		tree[x].ans = tree[2 * x + 1].ans;
	else
		tree[x].ans = tree[2 * x + 2].ans;
}

int change(int i, char ne, int n) {
	tree[i].now = ne;
	int x = i;
	if ((2 * x + 1) < n) {
		if (tree[x].now == '?')
			tree[x].ans = tree[2 * x + 1].ans + tree[2 * x + 2].ans;
		else if (tree[x].now == '1')
			tree[x].ans = tree[2 * x + 1].ans;
		else
			tree[x].ans = tree[2 * x + 2].ans;
	}
	else {
		if (tree[x].now == '?')
			tree[x].ans = 2;
		else
			tree[x].ans = 1;
	}
	while (true) {
		x = (x - 1) / 2;
		if ((2 * x + 1) < n) {
			if (tree[x].now == '?')
				tree[x].ans = tree[2 * x + 1].ans + tree[2 * x + 2].ans;
			else if (tree[x].now == '1')
				tree[x].ans = tree[2 * x + 1].ans;
			else
				tree[x].ans = tree[2 * x + 2].ans;
		}
		if (x == 0)
			break;
	}
	return tree[0].ans;
}


int main() {
	int k;
	cin >> k;
	int n = pow(2, k) - 1;
	tree.resize(n);
	for (auto& now : tree) {
		cin >> now.now;
	}
	reverse(tree.begin(), tree.end());
	build(0, n);
	int q;
	cin >> q;
	while (q--) {
		int x;
		char a;
		cin >> x >> a;
		x--;
		x = n - 1 - x;
		cout << change(x, a, n) << '\n';
	}
}