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


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin>>T;
    while (T--){
        int N,K;
        cin>>N>>K;
        string konstrukcja="AAPAPP";
        
        if (K>=4){
            for (int i=0;i<K;i++){
                cout<<"P";
            }
            for (int i=K;i<N;i++){
                cout<<konstrukcja[(i-K)%6];
            }
            cout<<"\n";
        } else{
            if (K==1){
                if (N==1){
                    cout<<"A";
                } else if (N==2){
                    cout<<"AP";
                } else{
                    cout<<"NIE";
                }
            } else if (K==2){
                konstrukcja="AAPP";
                if (N<=4){
                    for (int i=0;i<N;i++){
                        cout<<konstrukcja[i];
                    }
                } else{
                    cout<<"NIE";
                }
            } else if (K==3){
                konstrukcja="AAAPAPPP";
                if (N<=8){
                    for (int i=0;i<N;i++){
                        cout<<konstrukcja[i];
                    }
                } else{
                    cout<<"NIE";
                }
            }
            cout<<"\n";
        }
    }
}