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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <vector>
#include <cassert>
#include <cstring>

#define BAJ "Bajtek"
#define ALG "Algosia"

std::pair<int, int> encode(int a, int b)
{
	int c, d;

	--a; --b;

	if (a%2 == b%2) {
		c = a+1;
		d = b+1;
	} else {
		c = a+2;
		d = b+2;
	}

	return std::make_pair(c%1000+1, d%1000+1);
}

std::pair<int, int> decode(int c, int d)
{
	int a, b;

	--c; --d;

	if (c%2 == d%2) {
		a = c-1;
		b = d-1;
	} else {
		a = c-2;
		b = d-2;
	}

	if (a < 0) a += 1000;
	if (b < 0) b += 1000;

	return std::make_pair(a%1000+1, b%1000+1);
}

int main()
{
	int a, b, c, d;
	int i, j;
	char buf[128];
	std::pair<int, int> ret;

	a = 0; b = -1;

	fgets(buf, 127, stdin);
	scanf("%d%d", &a, &b);
	
	if (strncmp(buf, ALG, strlen(ALG)) == 0)
		ret = encode(a,b);
	else
		ret = decode(a,b);

	fprintf(stdout, " %u %u", ret.first, ret.second);
	fflush(stdout);
	fflush(stdout);
	fflush(stdout);
	return 0;
}