# import sys
# sys.stdin = open("tra.txt", "r")
reszta = [ 'P'+ i *'A' for i in range(1,1000) ]
t = int(input())
for i in range(t):
n, k = list(map(int,input().split()))
slowo = (("A"*k) + "".join(reszta[:2*k]))[:n]
if len(slowo) == n:
if k == 1 and n > 2:
print('NIE')
continue
if k == n:
print(slowo)
continue
if k == 1 and n==2:
print(slowo)
continue
if k == 2 and n == 3:
print(slowo)
continue
if n - k < 3:
print(slowo)
continue
ser_a = slowo.split('P')
sa = len(ser_a[-1])
sb = len(ser_a[-2])
if sa >= sb:
l = 2*sb+1
else:
l = 2*(sb-1)+1
if l > k:
print('NIE')
else:
print(slowo)
else:
print('NIE')
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 | # import sys # sys.stdin = open("tra.txt", "r") reszta = [ 'P'+ i *'A' for i in range(1,1000) ] t = int(input()) for i in range(t): n, k = list(map(int,input().split())) slowo = (("A"*k) + "".join(reszta[:2*k]))[:n] if len(slowo) == n: if k == 1 and n > 2: print('NIE') continue if k == n: print(slowo) continue if k == 1 and n==2: print(slowo) continue if k == 2 and n == 3: print(slowo) continue if n - k < 3: print(slowo) continue ser_a = slowo.split('P') sa = len(ser_a[-1]) sb = len(ser_a[-2]) if sa >= sb: l = 2*sb+1 else: l = 2*(sb-1)+1 if l > k: print('NIE') else: print(slowo) else: print('NIE') |
English