CF1571A.Sequence of Comparisons

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Sequence of Comparisons

Once upon a time, Petya had an array of integers aa of length nn. But over time, the array itself was lost, and only n1n-1 results of comparisons of neighboring array elements remained. In other words, for every ii from 11 to n1n-1, Petya knows exactly one of these three facts:

  • ai<ai+1a_i \lt a_{i+1};
  • ai=ai+1a_i = a_{i+1};
  • ai>ai+1a_i \gt a_{i+1}.

Petya wonders if it is possible to uniquely determine the result of comparing a1a_1 and ana_n.

You have to help Petya determine the result of comparing a1a_1 and ana_n or report that the result cannot be determined unambiguously.

Input

The first line contains a single integer tt (1t5001 \le t \le 500) — the number of test cases.

The only line of the test case contains the string ss (1s1001 \le |s| \le 100), where sis_i is:

  • <, if ai<ai+1a_i \lt a_{i + 1};
  • >, if ai>ai+1a_i \gt a_{i + 1};
  • =, if ai=ai+1a_i = a_{i + 1}.

Output

For each test case, print a single string equal to:

  • <, if a1<ana_1 \lt a_n;
  • >, if a1>ana_1 \gt a_n;
  • =, if a1=ana_1 = a_n;
  • ?, if it is impossible to uniquely determine the result of the comparison.

Note

Consider the test cases of the example:

  • in the first test case, it's easy to see that a1>a4a_1 \gt a_4 since a1>a2>a3>a4a_1 \gt a_2 \gt a_3 \gt a_4;
  • in the second test case, both sequences [1,2,0,10,10,15][1, 2, 0, 10, 10, 15] and [10,11,1,2,2,5][10, 11, 1, 2, 2, 5] meet the constraints; in the first one, a1<a6a_1 \lt a_6, and in the second one, a1>a6a_1 \gt a_6, so it's impossible to compare a1a_1 and a6a_6;
  • in the third test case, we already know that a1=a2a_1 = a_2;
  • in the fourth test case, it's easy to see that a3=a4=a5a_3 = a_4 = a_5, and a1<a2<a3a_1 \lt a_2 \lt a_3, so a1<a5a_1 \lt a_5.

Samples

4
>>>
<><=<
=
<<==
>
?
=
<

在线编程 IDE

建议全屏模式获得最佳体验