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
#include <iostream>
#include <vector>
#include <string>
using namespace std;

// Within each group of 4: {4k-3,4k-2,4k-1,4k}
// Swap: 4k-3 <-> 4k-1, 4k-2 <-> 4k
int comp(int x) {
    if (x % 4 == 1) return x + 2;
    if (x % 4 == 3) return x - 2;
    if (x % 4 == 2) return x + 2;
    return x - 2; // x % 4 == 0
}

int group_of(int x) {
    return (x - 1) / 4;
}

pair<int,int> transform(int a, int b) {
    if (group_of(a) == group_of(b)) {
        // Within same group: output the other 2 elements of the group
        int base = group_of(a) * 4 + 1;
        vector<int> rem;
        for (int x = base; x < base + 4; x++)
            if (x != a && x != b) rem.push_back(x);
        // rem[0] < rem[1] always (iterated in order)
        return (a < b) ? make_pair(rem[0], rem[1])
                       : make_pair(rem[1], rem[0]);
    } else {
        // Different groups: apply comp to each
        return {comp(a), comp(b)};
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string role;
    cin >> role;

    int x, y;
    cin >> x >> y;

    auto [c, d] = transform(x, y);
    cout << c << " " << d << "\n";
    cout.flush();

    return 0;
}