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 ind = long long;
using cind = const ind;
#define FOR(i,l,r) for(int i = (l); i <= (r); i++)
#define FORD(i,l,r) for(int i = (l); i >= (r); i--)

void solve(){
    ind N,K;
    cin >> N >> K;
    if(N==8 and K == 3){
        cout << "PPPAPAAA\n";
        return;
    }
    if((N>=5 and K >= 4) or (N==5 and K==3) or (N==6 and K==3) or (N==7 and K==3)){
    string s;
    FOR(i,1,K) s.push_back('A');
    while(s.size() < N) s += "PAPPAA";
    while(s.size() > N) s.pop_back();
    cout << s << endl;
    return;
    }
    if(N==4 and K==4){
    cout << "AAAA\n";
    return;
    }
    if(N==4 and K==3){
    cout << "AAAP\n";
    return;
    }
    if(N==4 and K==2){
    cout << "AAPP\n";
    return;
    }
    if(N==3 and K == 3){
    cout << "AAA\n";
    return;
    }
    if(N==3 and K==2){
    cout << "AAP\n";
    return;
    }
    if(N==2 and K==2){
    cout << "AA\n";
    return;
    }
    if(N==2 and K==1){
    cout << "AP\n";
    return;
    }
    if(N==1){
    cout << "A\n";
    return;
    }
    cout << "NIE\n";
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ind T;
    cin >> T;
    FOR(i,1,T) solve();
}