Corrupted File

시간 제한2초메모리 제한2048 MB

요약
이진 문자열 B와 C가 주어질 때, 인접한 두 비트를 AND로 합치는 연산을 반복해 B에서 C를 만들 수 있는지 판정한다.
난이도

보통10점 중 6점

유형
그리디, 문자열, 구현
정답자
아직 제출이 없습니다

문제

The WannaLaugh malware is a new computer malware that is spreading on the internet. If a computer is infected by this malware, then the malware will corrupt all files in the computer. A file in a computer contains zero or more bits. The malware corrupts a file by performing zero or more operations. In one operation, the malware randomly picks two consecutive bits and replaces them with a single bit. The new bit is 1 if both of the replaced bits are 1, or 0 otherwise.

For example, the malware might corrupt a file with bits 11011011 as follows:

  1. The malware picks the first and second bits: 11011011 → 1011011.
  2. The malware picks the second and third bits: 1011011 → 101011.
  3. The malware picks the third and fourth bits: 101011 → 10011.

Alternatively, the malware might first pick the third and fourth bits: 11011011 → 1101011.

At the start of the day, you have a file containing nn bits, denoted by BB. You spend the day surfing the internet, including checking on your favorite programming contest website, just like many ICPC contestants would do. At the end of the day, the same file contains mm bits, denoted by CC. You want to determine whether this file could have been corrupted by the WannaLaugh malware, or if it must have changed for other reasons.

입력

The first line of input contains one integer tt (1≤t≤10,0001 ≤ t ≤ 10\\, 000) representing the number of test cases. After that, tt test cases follow. Each of them is presented as follows.

The first line of input contains two integers nn and mm (1≤m≤n≤100,0001 ≤ m ≤ n ≤ 100\\, 000). The second line contains a string with nn characters, each is either 0 or 1, representing the bits BB. The third line contains a string with mm characters, each is either 0 or 1, representing the bits CC.

The sum of nn across all test cases in one input file does not exceed 100,000100\\, 000.

출력

For each test case, output yes if the file with bits BB could have been corrupted by the WannaLaugh malware into bits CC, or no otherwise.

예제1

  1. 예제 1

    입력
    3
    8 5
    11011011
    10011
    3 3
    101
    101
    3 2
    101
    00
    
    예상 출력
    yes
    yes
    no