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
#include <iostream>

constexpr int N = 1000;

bool are_consecutive(int a, int b) {
    return ((a + 1) % N == b%N) || ((b+1)%N==a%N);
}

std::pair<int, int> my_enc(std::pair<int, int> x) {
    const auto [a, b] = x;
    if (are_consecutive(a, b)) {
        return {(a+1)%N+1, (b+1)%N+1};
    } else {
        return {a%N+1,b%N+1};
    }
}

std::pair<int, int> my_dec(std::pair<int, int> x) {
    auto [c,d] = x;
    c += N;
    d += N;
    if (are_consecutive(c, d)) {
        return {(c-3)%N+1, (d-3)%N+1};
    } else {
        return {(c-2)%N+1,(d-2)%N+1};
    }
}

inline void pr(std::pair<int, int> x) {
    const auto [a,b] = x;
    std::cout << a << ' ' << b << '\n';
}

int main() {
    std::string who;
    std::cin >> who;
    int a,b;
    std::cin >> a >> b;
    if (who == "Algosia") {
        pr(my_enc({a,b}));
    } else {
        pr(my_dec({a,b}));
    }
    std::cout.flush();
}