Logical Equivalence

An ACM ICPC team wants to determine whether the two logical expressions are equivalent. Equivalent means that their truth tables are the same. Can you help them? Your task is to determine whether the two logical expressions are equivalent. Input The first line of input data is the number of data inputs, N (N ≤ 1000). Then for the following N lines, each line includes two expressions. The expression is composed of the 26 characters of ‘a’..‘z’ and the operators of ‘| & ^ ~ ()’. Where ‘| & ^ ~’ denote ‘or’, ‘and’, ‘exclusive or’ and ‘not’ respectively. Priority from high to low are ‘() ~ & ^ |’. You need to ignore any other characters. There may be no separation between the two expressions, and you need to judge their own separation. Each expression has a maximum of 10 different variables (letters), an expression of no more than 100 operators, the length of the expression does not exceed 1000. Each line of input is guaranteed to be uniquely separable into 2 syntactically valid expressions. Output Output n lines, corresponding to each input, if the two expressions are equivalent, then the output ‘Yes’, otherwise the output ‘No’. Sample Input

3
a ^b&(b|a)~b^ a
a^b&(b|a)(a^(b&(b|a)))
~~~~z~~z

Sample Output No Yes Yes