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<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef double db;
typedef pair<int, int> pii;
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define rep(i, l, r) for(int i=l; i<(r); i++)

ll nxt(){
    ll x;
    cin >> x;
    return x;
}

string male[4] = {"", "PA", "PPAA", "PPPAPAAA"};

void solve(){
    int n, k;
    cin >> n >> k;
    if(k > n) {
        cout << "NIE\n";
        return;
    }
    if(k <= 3) {
        if(n <= male[k].size()) {
            cout << string(male[k].begin(), male[k].begin()+n) << "\n";
        }
        else cout << "NIE\n";
    }
    else {
        string ans;
        for(int i=0; i<k; i++) {
            ans += 'P';
        }
        while(ans.size() < n) ans.append("APAAPP");
        cout << string(ans.begin(), ans.begin()+n) << "\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}