#C5223. Taco String Conversion

    ID: 48849 Type: Default 1000ms 256MiB

Taco String Conversion

Taco String Conversion

You are given two strings S and P. The string S consists of only lowercase Latin letters, whereas P consists of lowercase Latin letters and may include the character ? as a wildcard. You can replace each ? in P with the corresponding character from S (i.e. at the same position).

The task is to determine if it is possible to transform P into exactly S by making such replacements. If a mismatch occurs at any position where P has a letter (not a ?) that does not match the corresponding character in S, the conversion fails and you should output "No". Otherwise, output the converted string.

Note: The lengths of S and P must be the same for a valid conversion.

inputFormat

The input is read from standard input (stdin) and has the following format:

The first line contains an integer T denoting the number of test cases. For each test case, there are two lines:

  • The first line contains the target string S (only lowercase letters).
  • The second line contains the pattern string P (lowercase letters and possibly ? characters).

outputFormat

For each test case, print a single line to standard output (stdout) containing the result. If P can be transformed into S by replacing each ? with the corresponding character from S, output the transformed string. Otherwise, output "No".## sample

6
abc
a?c
banana
b?n?n?
abcd
?bcd
abcd
ab?d
abcdef
a?cd?f
test
xyz?
abc

banana abcd abcd abcdef No

</p>