Strange Simplification
题号:NC294485
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You are given two fractions: an original fraction a/b and a target fraction c/d.

We define "Strange Simplification" as follows. You can simplify the original fraction by removing one digit from both the numerator and denominator in each step. The operation must satisfy these rules:
  •  After removal, neither numerator nor denominator can have leading zeros.
  • The order of remaining digits must be preserved.
  • You must remove exactly one digit from numerator and one digit from denominator in each operation.
  • The removed two digits must be the same.

For example, 210/420 can be simplified as 1/4 because of 210/420 \to 21/42 \to 1/4, but cannot be simplified as 1/2 (although numerically the two numbers are indeed equal). 102/204 cannot be simplified to 10/04 because the denominator has one leading zero.

Determine if the original fraction a/b can be simplified to the target fraction c/d through one or more such operations (or do nothing).

输入描述:

The first line contains an integer T (1 \le T \le 10), denoting the number of test cases.

For each test case, input two fractions a/b, c/d formed as x/y (1 \le a, b, c, d \le 10^{10000}). It is guaranteed that any number does not have any leading zero.

输出描述:

For each test case, if a/b can be simplified as c/d, print \text{Yes}. Otherwise, print \text{No}.
示例1

输入

复制
6
20250517/20250516 7/6
20250517/5557 202017/57
2100/4200 21/42
1002/2004 100/4
31415/926 31415/926
10/100 1/1

输出

复制
Yes
Yes
Yes
No
Yes
No