#条件をすべて満たすかチェック def generate_string(N, S): if len(S) == 3 * N: if check_conditions(S): return S else: for c in 'ABC': result = generate_string(N, S + c) if result is not None: return result return None def check_conditions(S): if 'AA' in S or 'BB' in S or 'CC' in S: return False if sorted(S) != sorted('ABC' * (len(S) // 3)): return False while 'ABC' in S: S = S.replace('ABC', '', 1) if S != '': return True return False T = int(input()) for _ in range(T): N = int(input()) result = generate_string(N, '') if result is not None: print(result)