Juggle with Criteria

No attempts yetTime limit1sMemory limit128 MB

Problem

A permutation pp of length nn is an arrangement p=(p1,p2,,pn)p = (p_1, p_2, \ldots, p_n) that contains each integer from 11 to nn exactly once. Five criteria measure how close a permutation pp is to the identity permutation (1,2,,n)(1, 2, \ldots, n):

  • a(p)a(p) — the number of inversions in pp: pairs of indices (i,j)(i, j) with i<ji < j and pi>pjp_i > p_j.
  • b(p)b(p) — the number of local inversions in pp: indices ii with pi>pi+1p_i > p_{i+1}.
  • c(p)c(p) — the length of the longest increasing subsequence of pp: a sequence of indices i1<i2<<iki_1 < i_2 < \cdots < i_k with pi1<pi2<<pikp_{i_1} < p_{i_2} < \cdots < p_{i_k}.
  • d(p)d(p) — the length of the longest increasing substring of pp: a contiguous block pi<pi+1<<pjp_i < p_{i+1} < \cdots < p_j.
  • e(p)e(p) — the number of fixed points of pp: indices ii with pi=ip_i = i.

We want to show that these criteria can vary independently. For any prescribed combination of relations — for each criterion, whether its value on pp is less than, equal to, or greater than its value on qq — the goal is a pair of permutations pp and qq of the same length that realizes exactly that combination.

For each prescribed relation set and a fixed length ll, decide whether such a pair of permutations of length ll exists.

Input

The first line contains two integers nn and ll — the number of relation sets and the permutation length (1n2431 \le n \le 243; 1l10001 \le l \le 1000).

Each of the next nn lines contains one relation set given as five characters. Each character is <\texttt{<}, =\texttt{=}, or >\texttt{>}. In order, they prescribe the desired relation between a(p)a(p) and a(q)a(q), between b(p)b(p) and b(q)b(q), between c(p)c(p) and c(q)c(q), between d(p)d(p) and d(q)d(q), and between e(p)e(p) and e(q)e(q).

Output

For each relation set, print Exists\texttt{Exists} if there exist two permutations pp and qq, both of length ll, that satisfy all five prescribed relations simultaneously; otherwise print Not exists\texttt{Not exists}.

Print one answer per relation set, in the input order, each on its own line.

Note

All five relations must hold at once for the single pair (p,q)(p, q).

For example, take p=(1,4,2,3)p = (1, 4, 2, 3) and q=(2,3,4,1)q = (2, 3, 4, 1). Then

  • a(p)=2<3=a(q)a(p) = 2 < 3 = a(q),
  • b(p)=1=1=b(q)b(p) = 1 = 1 = b(q),
  • c(p)=3=3=c(q)c(p) = 3 = 3 = c(q),
  • d(p)=2<3=d(q)d(p) = 2 < 3 = d(q),
  • e(p)=1>0=e(q)e(p) = 1 > 0 = e(q),

so this pair realizes the relation set <==<>\texttt{<==<>} at length 44.