#!/usr/bin/env python3
import sys
def main():
pattern = "APAAPP"
T = int(input())
for _ in range(T):
N, K = [int(x) for x in input().split()]
match N, K:
case n, 1 if n >= 3:
print("NIE")
case 2, 2:
print("AA")
case 3, 2:
print("AAP")
case 4, 2:
print("AAPP")
case n, 2 if n >= 5:
print("NIE")
case 5, 3:
print("APAPP")
case 6, 3:
print("APAPPP")
case 7, 3:
print("AAPAPPP")
case 8, 3:
print("AAAPAPPP")
case n, 3 if n >= 9:
print("NIE")
case 4, 4:
print("AAAA")
case _:
print(
(
("P" * K if K >= 5 else "")
+ (pattern * (1 + N // (len(pattern))))
)[:N]
)
if __name__ == "__main__":
if len(sys.argv) == 2:
sys.stdin = open(sys.argv[1])
main()
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 | #!/usr/bin/env python3 import sys def main(): pattern = "APAAPP" T = int(input()) for _ in range(T): N, K = [int(x) for x in input().split()] match N, K: case n, 1 if n >= 3: print("NIE") case 2, 2: print("AA") case 3, 2: print("AAP") case 4, 2: print("AAPP") case n, 2 if n >= 5: print("NIE") case 5, 3: print("APAPP") case 6, 3: print("APAPPP") case 7, 3: print("AAPAPPP") case 8, 3: print("AAAPAPPP") case n, 3 if n >= 9: print("NIE") case 4, 4: print("AAAA") case _: print( ( ("P" * K if K >= 5 else "") + (pattern * (1 + N // (len(pattern)))) )[:N] ) if __name__ == "__main__": if len(sys.argv) == 2: sys.stdin = open(sys.argv[1]) main() |
English