#Lutece0067. Restore Equations
Restore Equations
Migrated from Lutece 67 Restore Equations
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
An interstellar expedition team has recently discovered on planet Mars some multiplication equations, which are believed to be the proof that Mars has once been the home of some intellectual species. However these equations are incomplete where some digits are missing because of the eroding power of Mars' nature. Here is one example.
One way to restore this equation is to assume the missing digits are , , , respectively, obtaining x = , which indicates this equation may indeed be the intellectual output of Mars' ancient habitants, rather than just some random numbers.
There has been hot debate over this, because people aren't sure whether they can restore all the equations discovered on Mars, i.e. restore the missing digits such that the multiplication equation holds. As a programmer in NASA, you are assigned the task of checking if all the equations are restorable.
Input
The first line is an integer , number of equations to check. Next lines each contains three non-empty strings , and , separated by spaces. Each string contains digits(0
-9
) and/or asterisks *
only, where an asterisk stands for a missing digit. No string begins with the digit 0
.
Output
For each test case, output Yes
(Quotes for clarity only) on a line if one can replace the asterisks with digits such that afterwards the numbers represented by , and satisfy *
= . Otherwise output No
instead. Note that an asterisk must be replaced with exactly one digit(0
-9
) and the resulting numbers , and can't start with zeros(See sample input/output for more clarification).
The length of string and are at most 3, and the length of is at most 6.
The length of each string is greater than zero.
At least one *
will be present in each equation.
Samples
2
12* 45 *5*5
11 11 *121
Yes
No
Note
The first case is the example in the problem description. In the second case, one would have been able to obtain a legal equation *
= if it were not forbidden to replace the starting *
in C by a zero.
Resources
The 5th UESTC Programming Contest Preliminary