 # DCP-94: Coin puzzle Back to All Problems

Rahim and Karim are good friends. One day Karim gives Rahim a challenge of coins. Karim gives Rahim N coins but there was no integer number written on each coin’s body (So Rahim can’t understand each coin's value). Then Karim gives Rahim Q queries, from these query Rahim has to determine the coin's value and has to rearrange the coins serially in increasing order on the table. If it is impossible to rearrange the coins say “Impossible”. But Rahim is confused of queries so he needs your help. Write a program that helps Rahim. ***Constraints : 2<=N<=26 , 2<=Q<=35*** Input Specification: -------------------- You will be given an integer **T** denoting the number of test cases, then **T** lines followes: In each test case there will be two numbers **N** and **Q**, denoting number of queries. Then there will **Q** lines, in each line there will be a String. For example : **“A>B”** here **A** means a coin , **B** means another coin. **A>B** means **A** is greater than **B** in value. Output Specification: --------------------- For each test case print the rearrangements of coins in increasing order. If it is impossible to rearrange the coins, print **“Impossible”** without quotes. See the simple input/output for better understanding. Sample Input : ------- 2 3 3 A>B C<B A>C 3 3 A<C B<A B>C Sample Output: ------- CBA Impossible **EXPLANATION :** In first test case, Since A>B , B>C , A>C So answer is CBA, means C is the smallest value coin, then B is greater than C but smaller than A, then A is the greatest coin than C and B. C is smallest , B is little bit greater, A is the greatest coin in value. In the second test case, it is impossible because we cannot create an increasing sequence.

### Problem Limits

 Language Time Limit (seconds) C 2.00 C++ 2.00 C++14 2.00 C# 2.00 Go 2.00 Java 3.00 JavaScript 2.00 Objective-C 2.00 Perl 2.00 PHP 2.00 Python 2.00 Python3 2.00 Ruby 2.00 VB.Net 2.00

# 22/73

Solve/Submission

### Ranking

# User Language Timing
01 moshiur_cse15 Cpp14 0.00s
02 FahimSifnatul Cpp14 0.00s
03 Morass Cpp14 0.00s
04 feodorv C 0.00s
05 dipu98 Cpp14 0.00s
06 daihan_mbstu Cpp14 0.00s
07 Robbinb1993 Cpp 0.00s
08 tariqiitju Cpp14 0.00s
09 simantaturja Cpp 0.01s
10 RandyWaterhouse Python3 0.03s
11 nafiz0080 Cpp14 0.58s
12 Foyaz05 Cpp14 0.60s
13 Optimus_primeV2 Cpp14 0.61s
14 prantacse14 Cpp14 0.62s
15 HR_Habib Cpp14 0.65s
16 swapnil Cpp14 0.66s
17 Roll_Number_27 Cpp14 0.71s
Feedback