#K67297. Constructing a String with a Balanced Substring

    ID: 32611 Type: Default 1000ms 256MiB

Constructing a String with a Balanced Substring

Constructing a String with a Balanced Substring

Given a positive integer \(n\), construct a string \(S\) of length \(n\) consisting only of the characters 'A' and 'B', such that there exists at least one substring with an equal number of 'A's and 'B's.

For example, when \(n = 2\), the string "AB" contains the substring "AB" where 'A' and 'B' appear exactly once. Similarly, when \(n = 5\), the string "ABABA" contains several substrings such as "BA" or "AB" that are balanced.

The input starts with an integer \(T\) denoting the number of test cases, followed by \(T\) lines each containing a single positive integer \(n\). For each test case, print a valid constructed string on a new line.

inputFormat

The input is read from standard input and has the following format:

  • The first line contains an integer \(T\), the number of test cases.
  • Each of the next \(T\) lines contains a single integer \(n\) representing the length of the string to be constructed.

outputFormat

For each test case, output the constructed string of length \(n\) that satisfies the condition, each on a separate line. The output is written to standard output.

## sample
2
2
5
AB

ABABA

</p>