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
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using lld= long double;
#define v vector
#define pb  push_back
#define FF first
#define SS second
#define ALL(a) a.begin(), a.end()
#define R resize
#define debug(x) cerr<< #x << " " << x << "\n"
#define tak cout<<"YES\n"
#define nie cout<<"NO\n"
#define LINIJKI ios_base::sync_with_stdio(0);cin.tie(0)
//_------------_-------------_-------------_

void solve(){
    ll a, b;
    cin>>a>>b;
    if(b == 3 && 8 >= a){
        cout<<string(b, 'P');
        string pom = "APAAA";
        for(ll i=0;i<a-b;i++){
            cout<<pom[i];
        }
        cout<<"\n";
        return;
    }
    if(b >= 4){
        cout<<string(b, 'A');
        string pom = "PAPPAA";
        for(ll i=0;i<a-b;i++){
            cout<<pom[i%6];
        }
        cout<<"\n";
        return;
    }
    if(2*b >= a){
        cout<<string(b, 'P') + string(a-b, 'A')<<"\n";
        return;
    }
    cout<<"NIE\n";
}

int main()
{
    LINIJKI;
    ll k;
    cin>>k;
    while(k--)solve();
}