A permutation p of length n is an arrangement p=(p1,p2,…,pn) that contains each integer from 1 to n exactly once. Five criteria measure how close a permutation p is to the identity permutation (1,2,…,n):
We want to show that these criteria can vary independently. For any prescribed combination of relations — for each criterion, whether its value on p is less than, equal to, or greater than its value on q — the goal is a pair of permutations p and q of the same length that realizes exactly that combination.
For each prescribed relation set and a fixed length l, decide whether such a pair of permutations of length l exists.
The first line contains two integers n and l — the number of relation sets and the permutation length (1≤n≤243; 1≤l≤1000).
Each of the next n lines contains one relation set given as five characters. Each character is <, =, or >. In order, they prescribe the desired relation between a(p) and a(q), between b(p) and b(q), between c(p) and c(q), between d(p) and d(q), and between e(p) and e(q).
For each relation set, print Exists if there exist two permutations p and q, both of length l, that satisfy all five prescribed relations simultaneously; otherwise print Not exists.
Print one answer per relation set, in the input order, each on its own line.
All five relations must hold at once for the single pair (p,q).
For example, take p=(1,4,2,3) and q=(2,3,4,1). Then
so this pair realizes the relation set <==<> at length 4.