#K85877. Construct Key String

    ID: 36739 Type: Default 1000ms 256MiB

Construct Key String

Construct Key String

You are given a base string and a pattern string. In the base string, some positions are marked with a question mark character '?'. Your task is to replace each occurrence of '?' in the base string with the corresponding character from the pattern string, in order.

For example, if the base string is a?c?e and the pattern string is bd, then each '?' should be replaced: the first '?' is replaced by 'b' and the second by 'd', giving abcde.

In the process, if you have a situation where the number of '?' characters in the base string matches the length of the pattern string, then the replacement is exact. Formally, if we denote the base string as \(S\) and the pattern string as \(P\), and if the number of occurrences of '?' in \(S\) is equal to \(|P|\) then the constructed key string \(K\) is obtained from \(S\) by replacing the \(i^{th}\) occurrence of '?' with \(P[i]\) (using 0-indexing).

inputFormat

The input is provided via standard input (stdin) as follows:

  • The first line contains an integer T, representing the number of test cases.
  • For each test case, two lines follow:
    • The first line contains the base string.
    • The second line contains the pattern string.

outputFormat

For each test case, output the constructed key string on a new line to the standard output (stdout).

## sample
3
a?c?e
bd
he??o
ll
a???
bcd
abcde

hello abcd

</p>