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
#include <bits/stdc++.h>
#define pii pair<int, int>
#define For(i, l, r) for (int i=l;(l<=r?i<=r:i>=r);(l<=r?i++:i--))
#define DEBUG
#ifdef DEBUG
auto operator<<(auto &o,auto p)->decltype(p.first,o){return o<<'('<<p.first<<", "<<p.second<<')';}
auto operator<<(auto &o,auto x)->decltype(x.end(),o){o<<'{';int i=2;for(auto &e:x)o<<(", ")+i<<e,i=0;return o<<'}';}
#define LOG(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X);
#else
#define LOG(x...)(void)0
#endif
#define int long long
using namespace std;

const int M = 100005;

void solve(){
    int n, k;
    cin >> n >> k;
    string ress[] = {"", "PA", "PPAA", "PPPAPAAA"};
    if (k <= 3){
        string a = ress[k];
        while (a.size() > n)
            a.pop_back();
        if (a.size() < n)
            cout << "NIE";
        else
            cout << a;
        cout << '\n';
        return;
    }
    string res(k, 'P');
    while (res.size() < n)
        res += "AAPAPP";
    while (res.size() > n)
        res.pop_back();
    cout << res << '\n';
}

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