#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

typedef struct data
{
	data* bit[2];
	int cnt = 0;
	int sum = 0;
}trie;

trie* head;

void insert(int x, int val)
{
	trie* cur = head;
	for(int i = 60; i >= 0; i--)
	{
		int b = (x >> i) & 1;
		if(!cur->bit[b])
			cur -> bit[b] = new trie();
		cur = cur -> bit[b];
		cur->cnt++;
		cur->sum += val;
	}
}

int query(int x)
{
	trie* cur = head;
	int ans = 0;
	for(int i = 60; i >= 0; i--)
	{
		int b = (x >> i) & 1;
		if(b == 0 && !cur->bit[b])
			return ans;
		else if(b == 0)
			cur = cur->bit[b];
		else
		{
			if(cur->bit[0] != NULL)
				ans += (cur->bit[0])->sum;
			if(!cur->bit[b])
				return ans;
			cur = cur->bit[b];
		}
	}
	return ans;
}

int32_t main()
{
	IOS;
	head = new trie();
	int prev = 0;
	int q, m1 = 1e9, m2 = 1e9;
	cin >> q >> m1 >> m2;
	map<int, int> val;
	while(q--)
	{
		int type, a, b;
		cin >> type;
		if(type == 1)
		{
			cin >> a >> b;
			int x = (a + prev) % m1 + 1;
			int y = (b + prev) % m2 + 1;
			if(val.find(x) != val.end())
				insert(x, -val[x]);
			val[x] = y;
			insert(x, val[x]);
		}
		else
		{
			cin >> a;
			int x = (a + prev) % m1 + 1;
			prev = query(x);
			if(val.find(x) != val.end())
				prev += val[x];
			cout << prev << endl;
		}
	}
	return 0;
}