Codeforces Round 947 (Div. 1 + Div. 2)
G
Zimpha Fan Club
Codeforces
3000
原题
← FH →
翻译中…

One day, Zimpha casually came up with a problem. As a member of "Zimpha fan club", you decided to solve that problem.

翻译中…

You are given two strings $s$ and $t$ of length $n$ and $m$, respectively. Both strings only consist of lowercase English letters, - and *.

翻译中…

You need to replace all occurrences of * and -, observing the following rules:

翻译中…
  • For each -, you must replace it with any lowercase English letter.
  • For each *, you must replace it with a string of any (possibly, zero) length which only consists of lowercase English letters.
翻译中…

Note that you can replace two different instances of - with different characters. You can also replace each two different instances of * with different strings.

翻译中…

Suppose $s$ and $t$ have been transformed into $s'$ and $t'$. Now you're wondering if there's a replacement that makes $s'=t'$.

翻译中…

Input

翻译中…

The first line of input contains two integers $n$ and $m$ ($1 \leq n, m \leq 2 \cdot 10^6$) — the length of the strings $s$ and $t$, respectively.

翻译中…

The second line contains the string $s$ of length $n$. It is guaranteed that $s$ only consists of lowercase English letters, - and *.

翻译中…

The third line contains the string $t$ of length $m$. It is guaranteed that $t$ only consists of lowercase English letters, - and *.

翻译中…

Output

翻译中…

For each test case, output "Yes" if there is a replacement that makes $s'=t'$, and output "No" otherwise.

翻译中…

You can output "Yes" and "No" in any case (for example, strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive response).

翻译中…

Note

翻译中…

In the second test case, we can transform both strings into ttklwxx. In $s$, - will be replaced with l. In $t$, * will be replaced by the empty string with the first and second - will be replaced with k and w respectively.

翻译中…

In the fifth test case, we can transform both strings into bulijiojioxdibuliduo.

翻译中…

样例

Input #1
10 10
justmonika
j-stsayori
Output #1
No
InputCopy OutputCopy
Input #2
7 8
ttk-wxx
*tt-l-xx
Output #2
Yes
InputCopy OutputCopy
Input #3
13 11
asoulwangziji
-soulg*z-y-
Output #3
No
InputCopy OutputCopy
Input #4
7 3
abc*cba
a*c
Output #4
No
InputCopy OutputCopy
Input #5
20 18
bulijiojio-dibuliduo
*li*ji-*ox*i*-du*-
Output #5
Yes
InputCopy OutputCopy
题目信息
题号
1975G
时间限制
12 s
内存限制
512 MB
标签
FFT
贪心
数学
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。