#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int f(const string& s)
{
	int n = s.length() + 1;
	vector<int> dp(n * 2);
	for (int i = n; i < 2 * n; ++i)
	{
		dp[i] = 1;
	}
	for (int i = n - 1; i > 0; --i)
	{
		int c = s[n - i - 1];
		if (c == '0')
		{
			dp[i] = dp[i << 1 | 1];
		}
		if (c == '1')
		{
			dp[i] = dp[i << 1];
		}
		if (c == '?')
		{
			dp[i] = dp[i << 1] + dp[i << 1 | 1];
		}
	}
	return dp[1];
}

vector<int> playoffTournamentBad(int k, const string& s0, const vector<int> &p, const vector<char> &c)
{
	string s = s0;
	int q = p.size();
	vector<int> ans;
	for (int i = 0; i < q; ++i)
	{
		s[p[i] - 1] = c[i];
		ans.push_back(f(s));
	}
	return ans;
}
vector<int> playoffTournament(int k, const string& s0, const vector<int> &p, const vector<char> &c)
{
	string s = s0;
	int q = p.size();
	int n = s.length() + 1;
	vector<int> dp(n * 2);
	for (int i = n; i < 2 * n; ++i)
	{
		dp[i] = 1;
	}
	for (int i = n - 1; i > 0; --i)
	{
		int c = s[n - i - 1];
		if (c == '0')
		{
			dp[i] = dp[i << 1 | 1];
		}
		if (c == '1')
		{
			dp[i] = dp[i << 1];
		}
		if (c == '?')
		{
			dp[i] = dp[i << 1] + dp[i << 1 | 1];
		}
	}
	vector<int> ans;
	for (int i = 0; i < q; ++i)
	{
		s[p[i] - 1] = c[i];
		for (int x = n - p[i]; x > 0; x >>= 1)
		{
			char c = s[n - x - 1];
			if (c == '0')
			{
				dp[x] = dp[x << 1 | 1];
			}
			if (c == '1')
			{
				dp[x] = dp[x << 1];
			}
			if (c == '?')
			{
				dp[x] = dp[x << 1] + dp[x << 1 | 1];
			}
		}
		ans.push_back(dp[1]);
	}
	return ans;
}

string randString(int len)
{
	string result;
	for (int i = 0; i < len; ++i)
	{
		int r = rand() % 3;
		if (r == 0)
		{
			result.push_back('0');
		}
		if (r == 1)
		{
			result.push_back('1');
		}
		if (r == 2)
		{
			result.push_back('?');
		}
	}
	return result;
}

void test()
{
	bool anyFailingTest = false;
	for (int i = 0; i < 100; ++i)
	{
		int k = 3;
		int kp = pow(2, k) - 1;
		if (kp != 7)
		{
			cout << "wrong\n";
		}
		string s = randString(kp);
		int q = 10;
		vector<int> p;
		vector<char> c;
		for (int j = 0; j < q; ++j)
		{
			p.push_back(rand() % kp + 1);
			int r = rand() % 3;
			if (r == 0)
			{
				c.push_back('0');
			}
			if (r == 1)
			{
				c.push_back('1');
			}
			if (r == 2)
			{
				c.push_back('?');
			}
		}
		vector<int> got = playoffTournament(k, s, p, c);
		vector<int> want = playoffTournamentBad(k, s, p, c);
		if (got.size() != want.size())
		{
			cout << "Found different size for test " << s << "\n";
			anyFailingTest = true;
		}
		else
		{
			for (int j = 0; j < got.size(); ++j)
			{
				if (got[j] != want[j])
				{
					cout << "got != want for test " << s << "\n";
					anyFailingTest = true;
				}
			}
		}
	}
	if (!anyFailingTest)
	{
		cout << "No difference found\n";
	}
}

int main(int argc, char** argv)
{
	if (argc > 1)
	{
		test();
	}
	int k;
	cin >> k;
	string s;
	cin >> s;
	int q;
	cin >> q;
	vector<int> p(q);
	vector<char> c(q);
	for (int i = 0; i < q; ++i)
	{
		cin >> p[i] >> c[i];
	}
	vector<int> ans = playoffTournament(k, s, p, c);
	for (int x : ans)
	{
		cout << x << "\n";
	}
	return 0;
}