This page is still under construction.

Parts of this page are still being built. What you see may change.

Even Separation

Time limit1sMemory limit256 MB

Summary
Split the vertices of an undirected graph into two parts so that every vertex has even degree in the subgraph induced on its own part.
Level

Medium7 of 10

Topics
Graph, DFS, Math, Implementation
Solved
No attempts yet

Problem

The good king of the Even Kingdom is dying, and two of his sons, Alfred and Brian, have an equal right to rule the kingdom. The king has decided to split the kingdom into two parts so that each son can rule his part alone. Of course, the split must be even.

The kingdom has nn cities, some pairs of which are connected by bidirectional roads. No road connects a city to itself, and no two cities are connected by more than one road. After the split, each city belongs either to Alfred or to Brian. Every road connecting cities that belong to different brothers is then destroyed. The split is even if, after those roads are destroyed, every city is directly connected to an even number of other cities, that is, if every vertex of the graph representing the road network has even degree.

Time is short. Help the good king find an even separation of his kingdom.

Some pairs of cities may be unreachable from each other by roads to begin with, and in an even separation some cities within one part may be unreachable from each other by the remaining roads.

Input

The first line contains two space-separated integers nn and mm, the number of cities and roads in the Even Kingdom (1≤n≤5001 \leq n \leq 500, 0≤m≤n(n−1)20 \leq m \leq \frac{n (n - 1)}{2}).

The next mm lines describe the roads. The ii-th of these lines contains two space-separated integers, the numbers of the cities connected by the ii-th road. Cities are numbered starting from 1. No pair of cities is connected by more than one road, and no road connects a city to itself.

Output

If a separation is possible, print one line of nn characters. The ii-th character is "A" if the ii-th city belongs to Alfred and "B" if it belongs to Brian. If there are several possible answers, print any of them.

If no separation is possible, print one line containing "IMPOSSIBLE".

Hint

One of the brothers may receive no cities at all. Nobody ever said it had to be fair.

Examples2

  1. Example 1

    Input
    4 6
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    
    Expected output
    BAAA
    
  2. Example 2

    Input
    3 3
    1 2
    2 3
    3 1
    
    Expected output
    AAA