#include<iostream>
#include<vector>
using namespace std;
typedef struct{
int x, y, c;
}Node;
vector<Node> res;
void dfs(int k, int x, int y, int dx, int dy){
if(k == 0) return;
int mx = 1 << k - 1, my = 1 << k - 1;
if(x > mx && y > my){
res.push_back({mx + dx, my + dy, 4});
dfs(k - 1, mx, my, dx, dy);
dfs(k - 1, mx, 1, dx, my + dy);
dfs(k - 1, 1, my, mx + dx, dy);
dfs(k - 1, x - mx, y - my, mx + dx, my + dy);
}
if(x > mx && y <= my){
res.push_back({mx + dx, my + 1 + dy, 3});
dfs(k - 1, mx, my, dx, dy);
dfs(k - 1, mx, 1, dx, my + dy);
dfs(k - 1, 1, 1, mx + dx, my + dy);
dfs(k - 1, x - mx, y, mx + dx, dy);
}
if(x <= mx && y > my){
res.push_back({mx + 1 + dx, my + dy, 2});
dfs(k - 1, mx, my, dx, dy);
dfs(k - 1, 1, 1, mx + dx, my + dy);
dfs(k - 1, 1, my, mx + dx, dy);
dfs(k - 1, x, y - my, dx, my + dy);
}
if(x <= mx && y <= my){
res.push_back({mx + 1 + dx, my + 1 + dy, 1});
dfs(k - 1, mx, 1, dx, my + dy);
dfs(k - 1, 1, 1, mx + dx, my + dy);
dfs(k - 1, 1, my, mx + dx, dy);
dfs(k - 1, x, y, dx, dy);
}
}
int main(){
int k, x, y;
cin >> k >> x >> y;
dfs(k, x, y, 0, 0);
for(auto t : res) cout << t.x << ' ' << t.y << ' ' << t.c << endl;
}