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 <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <deque>
#include <map>
#include <queue>
#include <climits>
using namespace std;
using ll=long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<string> gotowe(5);

    gotowe[1] = "AP";
    gotowe[2] = "AAPP";
    gotowe[3] = "AAAPAPPP";
    //gotowe[4] = "AAAAPPAPAAPPPP";

    string s(1000000, 'A');
    string s2 = "";
    for (int i = 0; i < 83335*2+12; i++) {
        s2 += "PPAPAA";
    }
    int t;
    cin >> t;
    while(t--){
        int N, K;
        cin >> N >> K;
        if(K>=4){
            cout << s.substr(0, K) << s2.substr(0, N-K) << '\n';
        }
        else if(N <= gotowe[K].size()){
            cout << gotowe[K].substr(0, N) << '\n';
        }
        else{
            cout << "NIE" << '\n';
        }
    }

    return 0;
}