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
28
29
30
31
32
33
34
35
36
#include <cstdio>
#include <set>
#include <algorithm>

int main() {
	int a;
	int b;
	
	scanf("%*s %d %d", &a, &b);
	--a;
	--b;
	
	int ra = a % 4;
	int rb = b % 4;
	int rc;
	int rd;
	
	if (ra == rb) {
		rc = 3-ra;
		rd = rc;
	} else {
		std::set<int> reszty{0,1,2,3};
		reszty.erase(ra);
		reszty.erase(rb);
		rc = *std::min_element(reszty.cbegin(), reszty.cend());
		rd = *std::max_element(reszty.cbegin(), reszty.cend());
		if (rb < ra) {
			std::swap(rc, rd);
		}
	}
	
	int c = a - ra + rc + 1;
	int d = b - rb + rd + 1;
	printf("%d %d", c, d);
	fflush(stdout);
}