On the distant island of Googlia there are two cities, Truthtown and Liarville. Everyone from Truthtown always tells the truth, and everyone from Liarville always lies. While exploring Googlia you have met a group of N inhabitants, and you want to work out which city each one came from.
Number the inhabitants 1 through N. You question each of them and record their M statements in the shorthand below.
| Shorthand | Meaning |
|---|---|
i T j | Person i says that person j is from Truthtown. |
i L j | Person i says that person j is from Liarville. |
i S j k | Person i says that persons j and k are from the same city. |
i D j k | Person i says that persons j and k are from different cities. |
A person may talk about themselves, so i can be equal to j or to k. At least one assignment of cities that agrees with every statement always exists.
Decide, for each inhabitant, which city they came from.
For example, suppose the statements are 1 D 2 3, 1 D 2 4, 1 D 3 4, and 2 L 1. Then you can reason as follows.
The first line holds the number of test cases, T. T test cases follow. Each case begins with a line holding the integers N and M. The next M lines each hold one statement from one inhabitant, written in the shorthand above.
For each test case print one line of the form "Case #x: y1 y2 ... yN", where x is the case number starting from 1 and yi is a single letter for inhabitant number i.
T if the statements force person i to be from Truthtown.L if the statements force person i to be from Liarville.- if the statements leave both cities possible for person i.Separate the letters with a single space.