1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <bits/stdc++.h>
using namespace std;

const int M = 1000;
int main() {
	string typ; cin >> typ;
	if (typ == "Algosia") {
		int x, y; cin >> x >> y;
		--x; --y;
		if ((x + 1) % M == y || (y + 1) % M == x) {
			cout << (x + 2) % M + 1 << ' ' << (y + 2) % M + 1 << '\n';
		}
		else {
			cout << (x + 1) % M + 1 << ' ' << (y + 1) % M + 1 << '\n';
		}
	}
	else {
		int x, y; cin >> x >> y;
		--x; --y;
		if ((x + 1) % M == y || (y + 1) % M == x) {
			cout << (x + M - 2) % M + 1 << ' ' << (y + M - 2) % M + 1 << '\n';
		}
		else {
			cout << (x + M - 1) % M + 1 << ' ' << (y + M - 1) % M + 1 << '\n';
		}
	}
}