Broken Keyboard

Submit solution

Points: 1
Time limit: 3.0s
Memory limit: 256M

Problem type
Allowed languages
C, C++, Java, Python

I have received an email from James but I know his keyboard is broken so pressing a key once may cause the corresponding symbol to appear more than once.

For example, after typing 'help', the following words could be printed: 'help', 'hhhelp', 'hheelp', 'hellllp' but the following could not be printed: 'hell', 'elp' and 'hllpp'.

Note that when you press a key, the corresponding symbol must appear (at least once). James' keyboard is so thoroughly broken that pressing the same key can result in different numbers of symbols in the result.

For each word in the email, I have guessed what word James wanted to send but I am not sure I am right, could you help me?

You are given a list of pairs of words. For each pair, determine if the second word could be printed by typing the first one in James' keyboard.

Input Specification

The first line contains one integer \(n (1 \leq n \leq 10^5)\), the number of pairs you need to check. Each of the subsequent \(n\) lines contains two space-separated words of lowercase English letters. The first word is a hypothetical input to James' keyboard, the second is the received output. The lengths of both strings are not greater than \(10^6\).

Output Specification

For each of the \(n\) cases print "YES" if the second word could be formed by typing the first on James' keyboard. Otherwise, print "NO".

Sample Input 1

hello hello
hello helloo
hello hlllloo
hello helo

Sample Output 1


Sample Input 2

aa bb
aaaa aaaab
abcdefghijklmnopqrstuvwxyz zabcdefghijklmnopqrstuvwxyz

Sample Output 2



There are no comments at the moment.