#K10321. Backspace String Compare

    ID: 23221 Type: Default 1000ms 256MiB

Backspace String Compare

Backspace String Compare

You are given two strings s and t. In the string s, the character '#' represents a backspace, which deletes the character immediately before it (if any). After processing all backspace characters, determine if the resulting string equals the string t.

For example, if s = "ab#c", after processing the backspace the string becomes "ac". Your task is to output YES if the processed string s is equal to t, and NO otherwise.

Formally, let the backspace operation be defined as follows: whenever a character # is encountered, if there is at least one character in the current string, delete the last character. In LaTeX, we represent the backspace symbol as $\#$.

inputFormat

The input is given from stdin as follows:

  1. The first line contains an integer T which denotes the number of test cases.
  2. For each test case, there are two subsequent lines: the first line contains the string s and the second line contains the string t.

Note that the strings can contain lowercase letters and the backspace character #.

outputFormat

For each test case, output a single line containing YES if the string obtained after processing s is equal to t, or NO otherwise. The results of different test cases should be printed on separate lines to stdout.

## sample
3
ab#c
ac
ab##
c
a#c
b
YES

NO NO

</p>