#include <bits/stdc++.h>
using namespace std;
int ik, ix, iy;
void div(int tx, int ty, int k, int x, int y)
{
if (k == 0)
{
return;
}
if (x < tx + (1 << (k - 1)) && y < ty + (1 << (k - 1)))
{
cout << tx + (1 << (k - 1)) << " " << ty + (1 << (k - 1)) << " " << 1 << endl;
div(tx, ty, k - 1, x, y);
div(tx + (1 << (k - 1)), ty, k - 1, tx, ty + (1 << (k - 1)) - 1);
div(tx, ty + (1 << (k - 1)), k - 1, tx + (1 << (k - 1)) - 1, ty);
div(tx + (1 << (k - 1)), ty + (1 << (k - 1)), k - 1, tx, ty);
}
else if (x >= tx + (1 << (k - 1)) && y < ty + (1 << (k - 1)))
{
cout << tx + (1 << (k - 1)) - 1 << " " << ty + (1 << (k - 1)) << " " << 2 << endl;
div(tx, ty, k - 1, tx + (1 << (k - 1)) - 1, ty + (1 << (k - 1)) - 1);
div(tx + (1 << (k - 1)), ty, k - 1, x, y - (1 << (k - 1)));
div(tx, ty + (1 << (k - 1)), k - 1, tx + (1 << (k - 1)) - 1, ty);
div(tx + (1 << (k - 1)), ty + (1 << (k - 1)), k - 1, tx, ty);
}
else if (x < tx + (1 << (k - 1)) && y >= ty + (1 << (k - 1)))
{
cout << tx + (1 << (k - 1)) << " " << ty + (1 << (k - 1)) - 1 << " " << 3 << endl;
div(tx, ty, k - 1, tx + (1 << (k - 1)) - 1, ty + (1 << (k - 1)) - 1);
div(tx + (1 << (k - 1)), ty, k - 1, tx, ty + (1 << (k - 1)) - 1);
div(tx, ty + (1 << (k - 1)), k - 1, x - (1 << (k - 1)), y);
div(tx + (1 << (k - 1)), ty + (1 << (k - 1)), k - 1, tx, ty);
}
else
{
cout << tx + (1 << (k - 1)) - 1 << " " << ty + (1 << (k - 1)) - 1 << " " << 4 << endl;
div(tx, ty, k - 1, tx + (1 << (k - 1)) - 1, ty + (1 << (k - 1)) - 1);
div(tx + (1 << (k - 1)), ty, k - 1, tx + (1 << (k - 1)), ty + (1 << (k - 1)) - 1);
div(tx, ty + (1 << (k - 1)), k - 1, tx + (1 << (k - 1)) - 1, ty + (1 << (k - 1)));
div(tx + (1 << (k - 1)), ty + (1 << (k - 1)), k - 1, x - (1 << (k - 1)), y - (1 << (k - 1)));
}
}
int main()
{
cin >> ik >> ix >> iy;
div(1, 1, ik, ix, iy);
return 0;
}