#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<random>
#include<ctime>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,sse4,popcnt")

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;

const int N = 2e6 + 2, inf = 1e9 + 100;
const ll llinf = 1e18 + 1000;
mt19937 mt(0);

vector<int> getVisionPattern1d() {
	return { 1, 1, 2, 1, 2, 2 };
}
int getMove1d(vector<int> a) {
	int len = a.size();
	int x = len / 2;
	if (x == 1) {
		if (a[0] != 1) return 0;
		else
			return 2;
	}
	else if (x == 2) {
		if (a[1] != 2 && a[3] != 2) {
			if (a[0] == 2) return 0;
			else
				return 4;
		}
		if (a[0] == 2) return 4;
		else if (a[4] == 2) return 0;
		else if (a[1] == 2) return 4;
		else
			return 0;
	}
}
vector<vector<int>> getVisionPattern2d() {
	return {
		{2, 1, 1, 2, 1},
		{1, 1, 1, 1, 1},
		{1, 1, 1, 2, 1},
		{1, 2, 1, 1, 1},
		{1, 1, 1, 1, 1}
	};
}
pair<int, int> getMove2d(vector<vector<int>> a) {
	int x = a.size() / 2;
	if (x == 1) {
		if (a[0][1] == 2) return { 0, 1 };
		if (a[1][0] == 2) return { 1, 0 };
		if (a[1][2] == 2) return { 1, 2 };
		if (a[2][1] == 2) return { 2, 1 };
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (a[i][j] == 2) return { i, j };
			}
		}
	}
	else {
		int cn = 0;
		for (int i = 0; i < 5; ++i) {
			for (int j = 0; j < 5; ++j) {
				if (a[i][j] == 2) ++cn;
			}
		}
		int crow = (a[2][0] == 2) + (a[2][1] == 2) + (a[2][3] == 2) + (a[2][4] == 2);
		int ccol = (a[0][2] == 2) + (a[1][2] == 2) + (a[3][2] == 2) + (a[4][2] == 2);
		if (crow == 1 && ccol == 1) {
			if (a[0][2] == 2) return { 0, 2 };
			else
				return { 4, 2 };
		}
		else if (crow == 1) {
			if (a[2][0] == 2) return { 2, 4 };
			else
				return { 2, 0 };
		}
		else if (ccol == 1) {
			if (a[0][2] == 2 && a[3][0] == 2) return { 4, 4 };
			else if (a[0][2] == 2 && a[3][4] == 2) return { 4, 0 };
			else if (a[4][2] == 2 && a[1][0] == 2) return { 0, 4 };
			else return { 0, 0 };
		}
		else {
			for (int i = 0; i < 5; ++i) {
				for (int j = 0; j < 5; ++j) {
					if (i == 2 && j == 2) continue;
					if (a[i][j] == 2) return { i, j };
				}
			}
		}
	}
}

void solve() {
	vector<vector<int>> a1 = getVisionPattern2d();
	vector<vector<int>> a(200, vector<int> (200));
	for (int i = 0; i < 200; ++i) {
		for (int j = 0; j < 200; ++j) {
			a[i][j] = a1[i % 5][j % 5];
		}
	}
	int x, y;
	cin >> x >> y;
	while (x > 10 && x < 100 && y > 10 && y < 100) {
		cout << x << ' ' << y << '\n';
		vector<vector<int>> b(a[x][y] * 2 + 1, vector<int> (a[x][y] * 2 + 1));
		for (int i = -a[x][y]; i <= a[x][y]; ++i) {
			for (int j = -a[x][y]; j <= a[x][y]; ++j) {
				b[i + a[x][y]][j + a[x][y]] = a[x + i][y + j];
			}
		}
		bool f1 = 0, f2 = 0;
		if (0) {
			reverse(all(b));
			f1 = 1;
		}
		if (1) {
			f2 = 1;
			for (auto& p : b) {
				reverse(all(p));
			}
		}
		pair<int, int> go = getMove2d(b);
		go.first -= a[x][y];
		go.second -= a[x][y];
		if (f1) {
			go.first *= -1;
		}
		if (f2) {
			go.second *= -1;
		}
		x += go.first;
		y += go.second;
	}
}

//signed main() {
//	ios_base::sync_with_stdio(0);
//	cin.tie(0);
//	int tt = 1;
//	//cin >> tt;
//	while (tt--) {
//		solve();
//		cout << '\n';
//		cout.flush();
//	}
//	return 0;
//}