#K49682. Correct the Received Message

    ID: 28697 Type: Default 1000ms 256MiB

Correct the Received Message

Correct the Received Message

You are given several test cases. In each test case, you are provided with two binary strings: a received message and a known valid message. Your task is to determine whether the received message can be corrected to match the valid message by flipping at most one bit. More formally, let ( M ) be the received message and ( V ) be the valid message. If (|M| \neq |V|), the answer is automatically "NO". Otherwise, if the number of positions where ( M ) and ( V ) differ is at most one, then the received message can be corrected (output "YES"); if it differs in more than one bit, then it cannot be corrected (output "NO").

inputFormat

The input begins with an integer ( T ) (the number of test cases). Each of the next ( T ) lines contains two space-separated binary strings. The first string is the received message and the second is the known valid message.

outputFormat

For each test case, print a single line containing either "YES" if the received message can be corrected to the valid message by flipping at most one bit, or "NO" otherwise.## sample

3
1010 1010
1101 1001
1111 0000
YES

YES NO

</p>