Election Frenzy

Given each table's visible set either explicitly or as a complement, build the visibility graph and 2-color each connected component by BFS distance parity.

Hard8GraphBFSImplementationNo attempts yetTime limit10sMemory limit512 MB

Problem

The campaign is over. Phong of the Sprites Party and Megabyte of the Viruses Party are waiting for the result, and all that is left is counting the votes.

The votes are counted in a room with tt tables. One counter sits at each table. Both parties may send people into the room to watch that the counting is done fairly, and such a person is called a scrutineer. One scrutineer from each party at every table would be ideal, but the room has space for only one scrutineer per table.

You have to assign the scrutineers. Every table gets exactly one scrutineer, either a Sprite or a Virus. Tables that stand close together can be watched together: a scrutineer watches the counting at their own table and at every table visible from it. An assignment is fair if every table is watched by at least one Sprite and by at least one Virus.

Each counter wrote down a list of table numbers. Some counters wrote the tables that are visible from their own table, and the rest wrote the tables that are not visible from it.

Find a fair assignment of scrutineers.

Input

The first line contains one integer tt (1t2000001 \le t \le 200\,000), the number of tables.

Each of the next tt lines holds the list handed in by one counter. The line starts with a letter pp, the type of the list, and an integer kk (0kt10 \le k \le t - 1), the length of the list. Then come kk distinct integers a1,,aka_1, \dots, a_k (1ait1 \le a_i \le t). The letter pp is either C or N.

If pp is C, the scrutineer at this table can watch the tables a1,,aka_1, \dots, a_k and no other table. If pp is N, the scrutineer at this table can watch every table except a1,,aka_1, \dots, a_k. A list never holds the number of its own table, because a scrutineer always watches the table they sit at.

The lines describe table 1 to table tt in this order. If the scrutineer at table xx can watch table yy, then the scrutineer at table yy can watch table xx. The lengths of all lists add up to at most 500000500\,000.

Output

If no fair assignment exists, print Impossible.

Otherwise print one string of length tt made of the letters S, for a Sprite scrutineer, and V, for a Virus scrutineer. The ii-th letter is the scrutineer at table ii.

Several fair assignments can exist, so print this one. Call two tables neighbours when each can watch the other, and group the tables that are joined by chains of neighbours. In every group let rr be the smallest table number, and let did_i be the smallest number of neighbour steps that lead from rr to table ii, so that dr=0d_r = 0. The ii-th letter is S when did_i is even, and V when did_i is odd.