#d2500. 异或和或

异或和或

XOR and OR

Problem Description

You are given a 0101 sequence a1,a2,…,ana_1, a_2, \dots, a_n of length nn.

You may perform the following operation any number of times:

  • Choose two indices 1≤i,j≤n1 \le i, j \le n (i≠ji \ne j).
  • Let x=ai xor ajx = a_i \ \mathrm{xor}\ a_j, y=ai or ajy = a_i \ \mathrm{or}\ a_j, where xor\mathrm{xor} denotes bitwise XOR and or\mathrm{or} denotes bitwise OR.
  • Then set ai=x,aj=ya_i = x, a_j = y or ai=y,aj=xa_i = y, a_j = x.

Given two 0101 sequences ss and tt, determine whether you can turn ss into tt by a finite number (possibly zero) of operations.

Input Format

The first line contains an integer tt, the number of test cases (1≤t≤1031 \le t \le 10^3). Then follow tt test cases:

For each test case, the first line contains a 0101 string ss (1≤∣s∣≤1031 \le |s| \le 10^3), and the second line contains a 0101 string tt (1≤∣t∣≤1031 \le |t| \le 10^3).

Note: ∣s∣|s| may not be equal to ∣t∣|t|.

Output Format

If ss can be turned into tt by a finite number (possibly zero) of operations, output YES; otherwise output NO.

Sample Input

2
001
011
11
101

Sample Output

YES
NO

Sample Explanation

For the first test case, choose i=2,j=3i = 2, j = 3; then x=1,y=1x = 1, y = 1, and after setting ai=x,aj=ya_i = x, a_j = y we obtain the sequence tt.

For the second test case, ∣s∣=2|s| = 2 and ∣t∣=3|t| = 3, so the requirement clearly cannot be met.