#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll calc2(ll id)
{
    //return log2l(id + 1) + 1;
    int ret = 0;
    while ((1ll << ret) < id + 2) ret++;
    return ret;
}
bool isPrefix(ll a, ll b)
{
    if (a == 0) return true;
    for (; b; b >>= 1)
        if (a == b) return true;
    return false;
}
int main()
{
    ll m, k, q, op, x;
    scanf("%lld%lld%lld", &m, &k, &q);
    set<ll> rm;
    if (m == 1)
        while (q--)
        {
            scanf("%lld%lld", &op, &x);
            if (op == 1)
                rm.insert(x);
            if (op == 2)
                rm.erase(x);
            printf("%lld\n", rm.empty() ? k : *rm.begin());
        }
    if (m == 2)
        while (q--)
        {
            scanf("%lld%lld", &op, &x);
            if (op == 1)
                rm.insert(x);
            if (op == 2)
                rm.erase(x);
            ll cnt = (1ll << k) - 1;
            for (auto ite = rm.begin(); ite != rm.end(); ++ite)
            {
                bool flag = true;
                for (auto ite2 = rm.begin(); ite2 != ite && flag; ++ite2)
                    flag = !isPrefix(*ite2 + 1, *ite + 1);
                if (flag) cnt -= (1ll << (k - calc2(*ite) + 1)) - 1;
            }
            printf("%lld\n", cnt);
        }
    return 0;
}
