Parliament Party Split

No attempts yetTime limit1sMemory limit64 MB

Problem

A parliament in a faraway country has NN members. From Monday to Friday of this week every member came to work and argued all day about the amendment to the new referendum law.

A reporter photographed the chamber once a day for those five days, each time in the middle of the argument. One photograph holds the pairs of members quarreling face to face. You analyze all five photographs.

Every member belongs to one of two parties, written A and B. Decide the party of each member so that no member quarreled with more than two members of their own party.

The same pair can appear in the photographs of several days. Such a pair still counts as one quarreling partner for each of the two members.

Input

The first line contains the number of members NN (2N2000002 \le N \le 200000). Members are numbered from 1 to NN.

The next five lines describe the photographs of Monday to Friday in that order. Each line lists the pairs of quarreling members in that day's photograph. First comes the number of pairs PP (1PN/21 \le P \le N/2), then PP pairs in the form "KK LL", where KK and LL are the numbers of the two members quarreling with each other. Two spaces come before each pair. A member appears at most once per line.

Output

Print one line with a string of length NN made of the characters A and B. The KKth character is the party of member KK.

Many assignments satisfy the condition, so only the assignment this procedure produces is accepted.

  1. Put every member in party A.
  2. If some member quarreled with three or more members of their own party, take the smallest numbered such member and move that member to the other party.
  3. Repeat step 2 until no such member is left.

A member appears at most once per photograph, so a member has at most five quarreling partners. A member who moves therefore has at most two quarreling partners in the new party right after the move, and the number of pairs that quarreled inside one party drops with every move. The procedure ends.