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
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;

void solve(string s, int n) {
    int i = 0;
    int score = 0;
    int opponentScore = 0;
    char response, our;
    string ans;
    while (i < n) {
        if (abs(opponentScore - score) < 1) {
            if (s[i] == '0') {
                our = 'K';
            } else {
                our = 'P';
            }
            cout << our << "\n";
            cin >> response;
            if (response == 'K') {
                ans += '0';
                if (our != response) {
                    score++;
                }
            } else {
                ans += '1';
                if (our != response) {
                    opponentScore++;
                }
            }
            i++;
        } else {
            if (opponentScore > score) {
                cout << 'P' << "\n";
                cin >> response;
                score++;
            } else {
                cout << 'K' << "\n";
                cin >> response;
                opponentScore++;
            }
        }
    }

    cout << "! " << ans << "\n";
    cout.flush();
}

int main() {
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    
    string name, s;
    int n, t;
    
    cin >> name >> n >> t;

    while (t--) {
        cin >> s;
        solve(s, n);
    }
}