ASME to SAME

3.4

11 votes
String, , Basic Programming, Implementation
Problem

Problem

You are given 2 strings s and t both containing only lowercase English characters with s containing some ? as well. You can swap characters at positions i and j in the string s (j>i) any number of times and can also replace any ? with any lowercase English character. Can you convert s into t ?

Input Format

  • The first line contains an integer T denoting the number of test cases. 
  • The first line of each test case contains an integer N, the length of the strings.
  • The second line of each test case contains N lowercase English characters with some ?(possibly 0) denoting string s.
  • The third line of each test case contains N lowercase English characters denoting string t.

Output Format

For each test case, print 'Yes' (without quotation marks) if it is possible to convert s into t.Otherwise, print 'No' (without quotation marks). Print the output in a new line.

Constraints

1T10

1N105

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In the first sample, we can replace first 3 ? with characters a,m, a respectively to obtain the final string.

In the second sample, we can swap 3rd and 4th characters to get our final string.

In the third testcase, no matter what we do, we cannot convert s into t.

Editor Image

?