#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
signed main()
{
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int n;
cin >> n;
int blockline = (1 << (n - 1))*n;
vector<int> blockedSquares(blockline + 1, 1);
int GHPX = 0;
int GHPY = 0;
set<pair<int, int>> placements;
while (true) {
if (GHPY == -1) {
return 0;
}
if (GHPX + GHPY == blockline) {
if (placements.count({ GHPX, GHPY + 1 }) == 1) {
cout << GHPX + 1 << " " << GHPY << "\n";
break;
}
else {
cout << GHPX << " " << GHPY+1 << "\n";
break;
}
}
int holeSize = 0;
int holeBegin = 0;
int maxHSize = 0;
int maxHBegin = 0;
for (size_t i = 0; i < GHPX; i++)
{
blockedSquares[i] = 0;
}
for (size_t i = 0; i < GHPY; i++)
{
blockedSquares[blockline - i] = 0;
}
for (size_t i = 0; i < blockedSquares.size(); i++)
{
if (blockedSquares[i] == 1) {
if (holeSize == 0) {
holeSize++;
holeBegin = i;
}
else {
holeSize++;
}
}
else {
if (holeSize > maxHSize) {
maxHSize = holeSize;
maxHBegin = holeBegin;
}
holeSize = 0;
}
}
if (holeSize > maxHSize) {
maxHSize = holeSize;
maxHBegin = holeBegin;
}
int cX = maxHBegin + maxHSize / 2;
int cY = blockline + 1 - cX;
cout << cX << " " << cY << "\n";
placements.insert({ cX, cY });
blockedSquares[max(0,cX - 1)] = 0;
blockedSquares[cX] = 0;
cin >> GHPX;
cin >> GHPY;
}
cin >> GHPX;
cin >> GHPY;
}