You are given two strings $s$ and $t$. The string $s$ consists of lowercase Latin letters and at most one wildcard character '*', the string $t$ consists only of lowercase Latin letters. The length of the string $s$ equals $n$, the length of the string $t$ equals $m$.

The wildcard character '*' in the string $s$ (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase Latin letters. No other character of $s$ can be replaced with anything. If it is possible to replace a wildcard character '*' in $s$ to obtain a string $t$, then the string $t$ matches the pattern $s$.

For example, if $s=$"aba*aba" then the following strings match it "abaaba", "abacaba" and "abazzzaba", but the following strings do not match: "ababa", "abcaaba", "codeforces", "aba1aba", "aba?aba".

If the given string $t$ matches the given string $s$, print "YES", otherwise print "NO".


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 2 \cdot 10^5$) — the length of the string $s$ and the length of the string $t$, respectively.

The second line contains string $s$ of length $n$, which consists of lowercase Latin letters and at most one wildcard character '*'.

The third line contains string $t$ of length $m$, which consists only of lowercase Latin letters.


-----Output-----

Print "YES" (without quotes), if you can obtain the string $t$ from the string $s$. Otherwise print "NO" (without quotes).


-----Examples-----
Input
6 10
code*s
codeforces

Output
YES

Input
6 5
vk*cup
vkcup

Output
YES

Input
1 1
v
k

Output
NO

Input
9 6
gfgf*gfgf
gfgfgf

Output
NO



-----Note-----

In the first example a wildcard character '*' can be replaced with a string "force". So the string $s$ after this replacement is "codeforces" and the answer is "YES".

In the second example a wildcard character '*' can be replaced with an empty string. So the string $s$ after this replacement is "vkcup" and the answer is "YES".

There is no wildcard character '*' in the third example and the strings "v" and "k" are different so the answer is "NO".

In the fourth example there is no such replacement of a wildcard character '*' that you can obtain the string $t$ so the answer is "NO".

Difficulty: EASY

Solutions:
_ = input()
s = input()
t = input()
ans = None
star_ind = s.find('*')
if star_ind == -1:
	if s == t:
		ans = True
	else:
		ans = False
else:
	pref_len = star_ind
	suff_len = len(s) - star_ind - 1
	ans = True
	ans &= pref_len + suff_len <= len(t)
	if pref_len and s[:pref_len]:
		ans &= s[:pref_len] == t[:pref_len]
	if suff_len and t[-suff_len:]:
		ans &= s[-suff_len:] == t[-suff_len:]
print('YES' if ans else 'NO')


(n, k) = map(int, input().split())
s = input().split('*')
t = input()
if len(s) == 1:
	print('YES' if s[0] == t else 'NO')
else:
	print('YES' if t[:len(s[0])] == s[0] and (t[-len(s[1]):] == s[1] if s[1] != '' else True) and (n <= k + 1) else 'NO')


input()
a = input()
b = input()
if '*' in a:
	(x, y) = a.split('*')
	if b.startswith(x) and b.endswith(y) and (len(b) >= len(x) + len(y)):
		print('YES')
	else:
		print('NO')
else:
	print('YES' if a == b else 'NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if m < n - 1:
	print('NO')
elif s == '*':
	print('YES')
elif s.find('*') == -1:
	if s != t:
		print('NO')
	else:
		print('YES')
else:
	(st, dr) = s.split('*')
	tc = t
	t = t.replace(st, '', 1)
	t = t[len(t)::-1]
	dr = dr[len(dr)::-1]
	t = t.replace(dr, '', 1)
	t = t[len(t)::-1]
	if s.replace('*', t) == tc:
		print('YES')
	else:
		print('NO')


(N, M) = input().strip().split()
(s, t) = (input(), input())
if '*' in s:
	(a, b) = s.split('*')
	if t.startswith(a) and t.endswith(b) and (len(a) + len(b) <= len(t)):
		print('YES')
	else:
		print('NO')
else:
	print('YES' if s == t else 'NO')


gi = lambda : list(map(int, input().split()))
(n, m) = gi()
(s, t) = (input(), input())
v = [0] * m
if '*' in s:
	if m < n - 1:
		print('NO')
		exit()
	for k in range(s.index('*')):
		if s[k] != t[k]:
			print('NO')
			exit()
	for k in range(-1, -n, -1):
		if s[k] == '*':
			break
		if s[k] != t[k]:
			print('NO')
			exit()
	print('YES')
elif s == t:
	print('YES')
else:
	print('NO')


def solve(s, t):
	if len(s) > len(t) + 1:
		return False
	pos = s.find('*')
	if pos == -1:
		return s == t
	left = s[:pos] if pos > 0 else ''
	right = s[pos + 1:]
	if len(left) + len(right) > len(t):
		return False
	return t.startswith(left) and t.endswith(right)

def main():
	(n, m) = map(int, input().strip().split())
	s = input().strip()
	t = input().strip()
	result = solve(s, t)
	print('YES' if result else 'NO')
main()


def solve(a, b, n, m):
	if n - 1 > m:
		print('NO')
	else:
		if '*' in a:
			idx = a.index('*')
		else:
			idx = -1
		if idx == -1:
			print('YES') if a == b else print('NO')
		else:
			y = len(b) - len(a[idx + 1:])
			if len(a) - 1 <= len(b) and a[:idx] == b[:idx] and (a[idx + 1:] == b[y:]):
				print('YES')
			else:
				print('NO')
(n, m) = map(int, input().split())
a = input()
b = input()
solve(a, b, n, m)


(n, m) = map(int, input().split())
s = input()
t = input()
index = s.find('*')
pos = 'YES'
if index < 0:
	if s != t:
		pos = 'NO'
if index == len(s) - 1:
	if len(t) < len(s) - 1:
		pos = 'NO'
	if s[:index] != t[:index]:
		pos = 'NO'
	remainder = t[index:]
	for i in remainder:
		if ord(i) < ord('a') or ord(i) > ord('z'):
			pos = 'NO'
elif index >= 0:
	if len(t) < len(s) - 1:
		pos = 'NO'
	if s[:index] != t[:index]:
		pos = 'NO'
	if s[index + 1:] != t[-len(s[index + 1:]):]:
		pos = 'NO'
	remainder = t[index:index + 1 - len(s)]
	for i in remainder:
		if ord(i) < ord('a') or ord(i) > ord('z'):
			pos = 'NO'
print(pos)


(n, m) = map(int, input().split())
s = input()
t = input()
if s.find('*') == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif len(s) - 1 > len(t):
	print('NO')
else:
	k = s.find('*')
	f = 1
	for i in range(k):
		if s[i] != t[i]:
			f = 0
	ps = len(s) - 1
	pt = len(t) - 1
	i = 0
	while i != len(s) - k - 1:
		if s[ps - i] != t[pt - i]:
			f = 0
		i += 1
	if f:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
s = s.split('*')
if s[0] == '':
	if t[m - n + 1:] == s[1]:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
if n == 1 and s == '*':
	print('YES')
	exit()
if m < n:
	if t == s[0] + s[1]:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
if s[0] == t[:len(s[0])]:
	t = t[len(s[0]):]
else:
	print('NO')
	exit()
if t.find(s[1]) != -1:
	if t[t.find(s[1]):] == s[1]:
		print('YES')
		exit()
	elif s[1] == '':
		print('YES')
		exit()
	else:
		print('NO')
		exit()
else:
	print('NO')


input()
s1 = input()
s2 = input()
if '*' not in s1:
	if s1 == s2:
		print('YES')
	else:
		print('NO')
	exit(0)
(s11, s12) = s1.split('*')
if len(s2) >= len(s11) + len(s12) and (len(s11) == 0 or s11 == s2[:len(s11)]) and (len(s12) == 0 or s12 == s2[-len(s12):]):
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = input()
d = input()
if '*' not in c:
	if c == d:
		print('YES')
	else:
		print('NO')
else:
	z = c.index('*')
	r = len(c) - z - 1
	if c[:z] != d[:z] or c[z + 1:] != d[len(d) - r:] or z + r > len(d):
		print('NO')
	else:
		print('YES')


(a, b) = input().split()
n = int(a)
m = int(b)
s1 = input()
s2 = input()
if n == 1 and s1[0] == '*':
	print('YES')
elif '*' in s1:
	c = s1.index('*')
	if c == n - 1 and s1[:c] == s2[:c]:
		print('YES')
	elif n - 1 <= m and s1[:c] == s2[:c] and (s1[c + 1:] == s2[-(n - c - 1):]):
		print('YES')
	else:
		print('NO')
elif s1 == s2:
	print('YES')
else:
	print('NO')


def obtainString(lenS, lenT, stringS, stringT):
	wildcardExists = False
	if stringS == stringT:
		return True
	if lenS - lenT >= 2:
		return False
	if stringT.isalpha() == False:
		return False
	for i in range(0, lenS):
		if stringS[i] == '*':
			wildcardExists = True
			wildcardIndex = i
			difference = lenS - wildcardIndex - 1
			break
	if wildcardExists == False:
		if stringS != stringT:
			return False
	elif wildcardExists == True:
		tempstringS = stringS.replace('*', '')
		if tempstringS == stringT:
			return True
	if stringT[wildcardIndex:].isalpha():
		stringS = stringS[:wildcardIndex] + stringT[wildcardIndex:lenT - difference] + stringS[wildcardIndex:]
		stringS = stringS.replace('*', '')
		if stringS == stringT:
			return True
	return False
lengths = input().split(' ')
stringS = input()
stringT = input()
obtainable = obtainString(int(lengths[0]), int(lengths[1]), stringS, stringT)
if obtainable == True:
	print('YES')
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
s = str(input())
t = str(input())
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	sys.exit(0)
(l, r) = s.split('*')
if t.startswith(l) and t.endswith(r) and (len(t) >= len(l) + len(r)):
	print('YES')
else:
	print('NO')


def cout(x):
	if x:
		print('YES')
	else:
		print('NO')
(a, b) = map(int, input().split())
c = input()
d = input()
if '*' not in c:
	cout(c == d)
else:
	(x, y) = c.split('*')
	cout(d.startswith(x) and d[len(x):].endswith(y))


put = lambda : tuple(map(int, input().split()))
(n, m) = put()
s = input()
t = input()
x = s.count('*')
if x == 0 and s != t:
	print('NO')
elif n - x > m:
	print('NO')
elif x == 0 and s == t:
	print('YES')
else:
	ind = s.index('*')
	if s[:ind] == t[:ind]:
		sub = s[ind + 1:]
		if t.rfind(sub) == m - len(sub):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


(a, b) = [int(x) for x in input().split()]
s = str(input())
t = str(input())
wld = s.find('*')
if a > b + 1:
	print('NO')
elif wld == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	sbegin = s[0:wld]
	send = s[wld + 1:]
	tbegin = t[0:wld]
	tend = t[len(t) - len(send):]
	if sbegin == tbegin and send == tend:
		print('YES')
	else:
		print('NO')


(n, m) = [int(i) for i in input().split()]
s1 = input()
s2 = input()
i = 0
k = 0
if '*' in s1:
	t1 = s1[:s1.find('*')]
	t2 = s1[s1.find('*') + 1:]
	if m - len(t2) >= s1.find('*') and s2.find(t1) == 0 and (s2.rfind(t2) == m - len(t2)):
		print('YES')
	else:
		print('NO')
elif s1 == s2:
	print('YES')
else:
	print('NO')


(n, m) = (int(x) for x in input().split())
s = list(input())
t = list(input())
if n > m and s.count('*') == 0:
	print('NO')
	exit(0)
if n - m > 1:
	print('NO')
	exit(0)
k = -1
for i in range(n):
	if s[i] != '*':
		if s[i] != t[i]:
			print('NO')
			exit(0)
	else:
		k = i
		break
k1 = n - k - 1
if k == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit(0)
for i in range(0, k1):
	if s[-i - 1] != t[-i - 1]:
		print('NO')
		exit(0)
print('YES')


(n, m) = map(int, input().split())
a = list(input())
b = list(input())
count = 0
if '*' in a:
	if n > m + 1:
		print('NO')
	else:
		s = a.index('*')
		for i in range(s):
			if a[i] != b[i]:
				count = 1
				break
		for j in range(n - s - 1):
			if a[-j - 1] != b[-j - 1]:
				count = 1
				break
		if count == 0:
			print('YES')
		else:
			print('NO')
elif a == b:
	print('YES')
else:
	print('NO')


input()
s = input()
t = input()
if s.count('*'):
	for i in range(len(s)):
		if s[i] == '*':
			print('YES' if s[0:i] == t[0:i] and s[i + 1:] == t[len(t) - len(s[i + 1:]):] and (i <= len(t) - len(s[i + 1:])) else 'NO')
			exit(0)
else:
	print('YES' if s == t else 'NO')


(n, m) = [int(x) for x in input().split()]
a = input()
b = input()
if '*' not in a:
	if a == b:
		print('YES')
	else:
		print('NO')
else:
	(part1, part2) = a.split('*')
	if b.startswith(part1) and b.endswith(part2) and (len(part1) + len(part2) <= len(b)):
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
a = input()
b = input()
if len(a) > len(b) + a.count('*'):
	exit(print('NO'))
if '*' in a:
	k = a.index('*')
	for i in range(k):
		if a[i] != b[i]:
			exit(print('NO'))
	for i in range(n - k - 1):
		if a[~i] != b[~i]:
			exit(print('NO'))
	print('YES')
else:
	print('YES' if a == b else 'NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit(0)
z = s.index('*')
if m < n - 1:
	print('NO')
	exit(0)
if s[z + 1:] == t[len(t) - len(s[z + 1:]):] and s[:z] == t[:z]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = input('')
b = input('')
t = list(a)
l = list(b)
f = 1
p = 0
k = 0
if n - 1 > m:
	print('NO')
elif '*' in a:
	w = t.index('*')
	for i in range(w):
		if not t[p] == l[p]:
			f = 0
			print('NO')
			break
		p = p + 1
	if f == 1:
		t.reverse()
		l.reverse()
		q = t.index('*')
		for lt in range(q):
			if t[k] != l[k]:
				print('NO')
				f = 0
				break
			k = k + 1
		if f == 1:
			print('YES')
elif a == b:
	print('YES')
else:
	print('NO')


import sys
import re
input()
s1 = input()
s2 = input()

def judge(s1, s2):
	if not '*' in s1:
		return s1 == s2
	else:
		if len(s1) > len(s2) + 1:
			return False
		s = str.split(s1, '*')
		return str.startswith(s2, s[0]) and str.endswith(s2, s[1])
print('YES' if judge(s1, s2) else 'NO')


input()
(s, t) = (input(), input())
try:
	(a, b) = s.split('*')
	r = t.startswith(a) and t[len(a):].endswith(b)
except:
	r = s == t
print(['NO', 'YES'][r])


(n, m) = input().split()
(n, m) = (int(n), int(m))
s = input()
t = input()
if '*' in s:
	s = s.split('*')
	s1 = s[0]
	s2 = s[1]
	if t.startswith(s1) and t[len(s1):].endswith(s2):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


n = input()
s = input()
t = input()
p = s.find('*')
if p == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit(0)
sl = len(s) - p - 1
if s[:p] == t[:p] and t[len(t) - sl:] == s[p + 1:] and (len(t) >= len(s) - 1):
	print('YES')
else:
	print('NO')


def solve(N, M, S, T):
	p = S.find('*')
	if p == -1:
		return S == T
	pre = S[:p]
	post = S[p + 1:]
	if not T.startswith(pre) or not T.endswith(post):
		return False
	if len(pre) + len(post) > M:
		return False
	rest = T[p:M - len(post)]
	return len([c for c in rest if not 'a' <= c <= 'z']) == 0

def main():
	(N, M) = [int(e) for e in input().split(' ')]
	S = input()
	T = input()
	print('YES' if solve(N, M, S, T) else 'NO')
main()


(n, m) = map(int, input().split())
if n - 1 > m:
	print('NO')
	exit(0)
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit(0)
for i in range(n):
	if s[i] == '*':
		break
	if s[i] != t[i]:
		print('NO')
		exit(0)
i = n - 1
j = m - 1
while i >= 0 and j >= 0:
	if s[i] == '*':
		break
	if s[i] != t[j]:
		print('NO')
		exit(0)
	i -= 1
	j -= 1
print('YES')


input()
a = input()
b = input()
if '*' not in a:
	if a == b:
		print('YES')
	else:
		print('NO')
elif len(a) > len(b) + 1:
	print('NO')
else:
	i = a.find('*')
	l = a[:i]
	r = a[i + 1:]
	ind = b.find(l)
	if ind:
		print('NO')
	else:
		b = b[::-1]
		ind = b.find(r[::-1])
		if ind:
			print('NO')
		else:
			print('YES')


(n, m) = map(int, input().split())
s = input()
t = input()
f = 1
(i_, j_) = (-1, -1)
for i in range(n):
	if s[i] == '*':
		i_ = i
		break
if i_ == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif i_ > m:
	print('NO')
elif s[:i_] != t[:i_]:
	print('NO')
elif m - (n - i_ - 1) < 0:
	print('NO')
elif t[m - (n - i_) + 1:] != s[i_ + 1:]:
	print('NO')
else:
	j_ = m - n + i_
	if i_ - 1 <= j_:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s == t:
	print('YES')
elif '*' not in s:
	print('NO')
else:
	idx = s.find('*')
	if t.startswith(s[:idx]) and t.endswith(s[idx + 1:]) and (n <= m + 1):
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s1 = input()
s2 = input()
if m < n - 1:
	print('NO')
else:
	index = -1
	for i in range(n):
		if s1[i] == '*':
			index = i
	if index == -1:
		if n == m:
			flag = 0
			for i in range(n):
				if s1[i] != s2[i]:
					flag = 1
					break
			if flag == 1:
				print('NO')
			else:
				print('YES')
		else:
			print('NO')
	else:
		flag = 0
		for i in range(index):
			if s1[i] != s2[i]:
				flag = 1
				break
		if flag == 1:
			print('NO')
		else:
			for i in range(1, n - index):
				if s1[-i] != s2[-i]:
					flag = 1
					break
			if flag == 1:
				print('NO')
			else:
				print('YES')


firstinput = []
input_string = input()
list_a = input_string.split()
count = 0
while count < 2:
	firstinput.append(int(list_a[count]))
	count += 1
wordinput = str(input())
realword = str(input())
wordinputlist = list(wordinput.lower())
realwordlist = list(realword.lower())
if len(wordinputlist) - 1 > len(realwordlist):
	print('NO')
elif len(wordinputlist) == 1 and len(realwordlist) == 1:
	if wordinputlist[0] == '*':
		print('YES')
	elif wordinputlist[0] == realwordlist[0]:
		print('YES')
	else:
		print('NO')
elif '*' not in wordinputlist:
	if len(wordinputlist) == len(realwordlist):
		counter = 0
		start = 0
		while start < len(wordinputlist):
			if wordinputlist[start] != realwordlist[start]:
				counter += 1
			start += 1
		if counter > 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
elif wordinputlist[0] == '*':
	counter = 0
	start = 1
	realwordstart = len(realwordlist) - len(wordinputlist) + 1
	while start < len(wordinputlist):
		if wordinputlist[start] != realwordlist[realwordstart]:
			counter += 1
		start += 1
		realwordstart += 1
	if counter > 0:
		print('NO')
	else:
		print('YES')
elif wordinputlist[len(wordinputlist) - 1] == '*':
	counter = 0
	start = 0
	realwordstart = 0
	while start < len(wordinputlist) - 1:
		if wordinputlist[start] != realwordlist[realwordstart]:
			counter += 1
		start += 1
		realwordstart += 1
	if counter > 0:
		print('NO')
	else:
		print('YES')
else:
	counter = 0
	start = 0
	loop = 0
	end1 = len(wordinputlist) - 1
	while loop < len(wordinputlist):
		if loop != len(wordinputlist) - 1 and wordinputlist[loop + 1] == '*':
			end = loop
		elif wordinputlist[loop] == '*':
			start1 = loop + 1
		loop += 1
	realwordstart = 0
	while start <= end:
		if wordinputlist[start] != realwordlist[realwordstart]:
			counter += 1
		start += 1
		realwordstart += 1
	realwordstart = len(realwordlist) - (end1 - start1) - 1
	while start1 <= end1:
		if wordinputlist[start1] != realwordlist[realwordstart]:
			counter += 1
		start1 += 1
		realwordstart += 1
	if counter > 0:
		print('NO')
	else:
		print('YES')


def main():
	(n, m) = map(int, input().split())
	s = input()
	t = input()
	if n - 1 > m:
		print('NO')
		return
	if n < m:
		if '*' not in s:
			print('NO')
			return
	if n > m:
		if '*' not in s:
			print('NO')
			return
	before = []
	for i in s:
		if i == '*':
			break
		before.append(i)
	after = []
	for i in range(n - 1, -1, -1):
		if s[i] == '*':
			break
		after.append(s[i])
	after.reverse()
	for i in range(len(before)):
		if before[i] != t[i]:
			print('NO')
			return
	for i in range(len(after)):
		if after[len(after) - 1 - i] != t[len(t) - 1 - i]:
			print('NO')
			return
	print('YES')
main()


(n, m) = map(int, input().split())
s = input()
t = input()
flags1 = 0
sett = 0
flags2 = n - 1
flagt1 = 0
flagt2 = m - 1
temp = -1
for i in range(n):
	if s[i] == '*':
		temp = i
		break
if temp == -1:
	if m != n:
		print('NO')
	else:
		for i in range(n):
			if s[i] != t[i]:
				sett = 1
		if sett == 1:
			print('NO')
		else:
			print('YES')
elif n - 1 > m:
	print('NO')
else:
	for i in range(0, temp):
		if s[i] != t[i]:
			sett = 1
			break
	if sett == 1:
		print('NO')
	else:
		count1 = n - temp - 1
		i = n - 1
		j = m - 1
		while count1:
			if s[i] != t[j]:
				sett = 1
				break
			else:
				i -= 1
				j -= 1
				count1 -= 1
		if sett == 1:
			print('NO')
		else:
			print('YES')


(n, m) = input().split()
n = int(n)
m = int(m)
s = input()
t = input()
if n <= m + 1:
	if '*' in s:
		i = s.index('*')
		pres = s[:i]
		sufs = s[i + 1:]
		x = len(sufs)
		pret = t[:i]
		suft = t[-1 * x:]
		fins = pres + sufs
		fint = pret + suft
		if fins == fint:
			print('YES')
		elif fins == '':
			print('YES')
		elif pres == pret and sufs == '':
			print('YES')
		elif sufs == suft and pres == '':
			print('YES')
		else:
			print('NO')
	elif s == t:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	(left, right) = s.split('*')
	r = t.startswith(left) and t.endswith(right) and (len(t) >= len(s) - 1)
else:
	r = s == t
print('YES' if r else 'NO')


(n, m) = [int(x) for x in input().split()]
s = input()
t = input()
if s == t:
	print('YES')
	exit()
if len(s) > len(t) and s.count('*') == 0:
	print('NO')
	exit()
if len(s) > len(t) + 1:
	print('NO')
	exit()
if s.count('*') == 0:
	print('NO')
	exit()
for i in range(len(s)):
	if s[i] == '*':
		break
	if s[i] != t[i]:
		print('NO')
		exit()
i = len(s) - 1
j = len(t) - 1
while True:
	if s[i] == '*':
		break
	if s[i] != t[j]:
		print('NO')
		exit()
	i -= 1
	j -= 1
print('YES')


(a, b) = list(map(int, input().split()))
s = input()
t = input()
x = s.find('*')
if x == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif a > b + 1:
	print('NO')
else:
	sb4 = s[0:x]
	safter = s[x + 1:]
	tb4 = t[0:x]
	tafter = t[x:]
	if sb4 == tb4 and safter == tafter[len(tafter) - len(safter):]:
		print('YES')
	else:
		print('NO')


(a, b) = map(int, input().split())
(x, y) = (input(), input())
if '*' not in x:
	print('YES' if x == y else 'NO')
	exit()
if a > b + 1:
	print('NO')
else:
	(m, n) = x.split('*')
	print('YES' if (m == y[:len(m)] or len(m) == 0) and (len(n) == 0 or n == y[-len(n):]) else 'NO')


(n, m) = map(int, input().split())
s = input()
t = input()
k = s.find('*')
if k == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	tail_len = n - k - 1
	if tail_len == 0:
		tail = ''
	else:
		tail = t[-tail_len:]
	if s[:k] == t[:k] and s[k + 1:] == tail and (n - 1 <= m):
		print('YES')
	else:
		print('NO')


def main():
	insert = input().split()
	x = int(insert[0])
	y = int(insert[1])
	input1 = input()
	input2 = input()
	star_exists = False
	star_posiition = 0
	same = True
	for i in range(0, x):
		if input1[i] == '*':
			star_exists = True
			star_posiition = i
	dataDiff = y - x
	if dataDiff < -1:
		same = False
	elif star_exists:
		for i in range(0, star_posiition):
			if not input1[i] == input2[i]:
				same = False
				break
		for i in range(x - 1, star_posiition, -1):
			if not input2[i + dataDiff] == input1[i]:
				same = False
				break
	elif not input1 == input2:
		same = False
	if same == True:
		print('YES')
	else:
		print('NO')
main()


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if n > m + 1:
	print('NO')
elif '*' in s:
	(start, end) = s.split('*')
	print('YES' if t.startswith(start) and t.endswith(end) else 'NO')
else:
	print('YES' if s == t else 'NO')


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
(n, m) = rint()
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit()
if n == 1:
	print('YES')
	exit()
if s[-1] == '*':
	if s[:-1] == t[:n - 1]:
		print('YES')
	else:
		print('NO')
	exit()
if s[0] == '*':
	if s[1:] == t[m - (n - 1):m]:
		print('YES')
	else:
		print('NO')
	exit()
ss = []
ss = list(s.split('*'))
if ss[0] == t[0:len(ss[0])] and ss[1] == t[m - len(ss[1]):m] and (m >= n - 1):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s == t:
	print('YES')
elif '*' in s:
	i = s.index('*')
	if n <= m + 1 and s[:i] == t[:i] and (s[i + 1:] == t[m - (n - i) + 1:]):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
s = input()
t = input()
l = [-1]
ans = []
for i in range(n):
	if s[i] == '*':
		l.append(i)
a = max(l)
if max(l) == -1:
	if s == t:
		ans.append('YES')
	else:
		ans.append('NO')
elif n - a - 1 <= m - a:
	if s[:a] != t[:a]:
		ans.append('NO')
	else:
		p = s[n:a:-1]
		x = len(p)
		if x == 0:
			ans.append('YES')
			print(*ans)
			sys.exit()
		yu = t[m:m - x - 1:-1]
		if len(t[m:m - x - 1:-1]) == 0 and a == 0:
			yu = t
		if yu == p:
			ans.append('YES')
		else:
			ans.append('NO')
else:
	ans.append('NO')
print(*ans)


(n, m) = map(int, input().split())
s = input()
t = input()
if n - 1 > m:
	print('NO')
	exit()
try:
	c = s.index('*')
except ValueError:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit()
if c == 0:
	if s[::-1][:len(s) - 1] == t[::-1][:len(s) - 1]:
		print('YES')
	else:
		print('NO')
elif c == len(s) - 1:
	if s[:len(s) - 1] == t[:len(s) - 1]:
		print('YES')
	else:
		print('NO')
elif s[:c] == t[:c] and s[c + 1:][::-1] == t[::-1][:len(s) - 1 - c]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' not in s:
	print('YES' if s == t else 'NO')
elif s[-1] == '*':
	print('YES' if t.startswith(s[:-1]) else 'NO')
else:
	(u, v) = s.split('*')
	print('YES' if t[:-len(v)].startswith(u) and t[len(u):].endswith(v) else 'NO')


(n, m) = map(int, input().split())
s = input()
t = input()
sp = s.split('*')
print(('NO', 'YES')[t.startswith(sp[0]) and t.endswith(sp[-1]) and (s == t) * ('*' not in s) + (len(t) >= len(sp[0]) + len(sp[-1]) * ('*' in s)) * ('*' in s)])


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if n > m + 1:
	print('NO')
elif s == t:
	print('YES')
elif '*' not in s:
	print('NO')
elif s == '*':
	print('YES')
else:
	l = s.split('*')
	(a, b) = (0, 0)
	if t[:len(l[0])] == l[0] or l[0] == '':
		a += 1
	if t[-len(l[-1]):] == l[-1] or l[-1] == '':
		b += 1
	if a == 1 and b == 1:
		print('YES')
	else:
		print('NO')


input()
s = input()
t = input()
s = ' ' + s + ' '
t = ' ' + t + ' '
if '*' in s:
	idx = s.find('*')
	(prefix, suffix) = (s[:idx], s[idx + 1:])
	print('YES' if len(s) - 1 <= len(t) and prefix == t[:len(prefix)] and (suffix == t[-len(suffix):]) else 'NO')
else:
	print('YES' if s == t else 'NO')


(n, m) = map(int, input().split())
stroka1 = str(input())
stroka2 = str(input())
if '*' in stroka1:
	per = stroka1[:stroka1.index('*')]
	vtor = stroka1[stroka1.index('*') + 1:]
	if len(stroka1) - len(stroka2) <= 1 and stroka2[:len(per)] == per and (stroka2[::-1][:len(vtor)][::-1] == vtor):
		print('YES')
	else:
		print('NO')
elif stroka1 == stroka2:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = input()
b = input()
gwiazdka = a.find('*')
if n > m + 1:
	print('NO')
	exit()
if gwiazdka == -1:
	print('YES' if a == b else 'NO')
	exit()
for i in range(gwiazdka):
	if a[i] != b[i]:
		print('NO')
		exit()
for i in range(n - gwiazdka - 1):
	if a[-i - 1] != b[-i - 1]:
		print('NO')
		exit()
print('YES')


import sys, string
(n, m) = map(int, sys.stdin.readline().split())
s = list(sys.stdin.readline().rstrip())
t = list(sys.stdin.readline().rstrip())
idx = -1
for i in range(n):
	if s[i] == '*':
		idx = i
if idx == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif m < n - 1:
	print('NO')
else:
	s_left = s[0:idx]
	s_right = s[idx + 1:n]
	a = len(s_left)
	b = len(s_right)
	t_left = []
	t_right = []
	for i in range(a):
		t_left.append(t[i])
		t[i] = ''
	for i in range(b):
		t_right.append(t[m - i - 1])
	if s_left == t_left and s_right == t_right[::-1]:
		print('YES')
	else:
		print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
s = input()
t = input()
star = s.find('*')
if star > -1 and m >= n - 1:
	r = t.rfind(s[star + 1:])
	if r > -1 and r + len(t[r:]) == m and (t[:star] + '*' + t[star + m - n + 1:] == s):
		print('YES')
	else:
		print('NO')
elif star == -1 and m == n:
	if t == s:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if n - 1 > m:
	print('NO')
else:
	x = s.find('*')
	if x == -1:
		if s != t:
			print('NO')
		else:
			print('YES')
	elif s[:x] == t[:x] and s[x + 1:] == t[x + (m - n) + 1:]:
		print('YES')
	else:
		print('NO')


def patternMatching(first, second):
	if first == second:
		return 'YES'
	if len(second) < len(first) - 1 or first.find('*') == -1:
		return 'NO'
	stop = None
	for i in range(len(first)):
		if first[i] == '*':
			stop = len(second) - i - 1
			break
		if i >= len(second) or first[i] != second[i]:
			return 'NO'
	first = first[::-1]
	second = second[::-1]
	for i in range(len(first)):
		if first[i] == '*':
			break
		if i > stop or first[i] != second[i]:
			return 'NO'
	return 'YES'
lengths = input().split(' ')
(a, b) = (lengths[0], lengths[1])
first = input()
second = input()
print(patternMatching(first, second))


n = input()
s = input()
t = input()
if '*' in s:
	arr = s.split('*')
	if t.startswith(arr[0]) and t.endswith(arr[1]) and (len(arr[0]) + len(arr[1]) <= len(t)):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


readints = lambda : map(int, input().strip('\n').split())
readstr = lambda : input().strip('\n')

def printlist(lst):
	buf = ''
	for i in range(len(lst) - 1):
		buf += str(lst[i]) + ' '
	buf += str(lst[-1])
	print(buf)
(n, m) = readints()
s = readstr()
t = readstr()

def isMatch(s, t):
	if '*' not in s:
		return s == t
	star = s.find('*')
	left = s[:star]
	right = s[star + 1:]
	l = len(left)
	r = len(t) - len(right)
	if r < 0 or r - l < 0:
		return False
	middle = t[l:r]
	return left + middle + right == t
if isMatch(s, t):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
s = list(s)
t = list(t)
if '*' in s:
	p = s.index('*') + 1
	q = len(s[s.index('*') + 1:])
	if len(s) > len(t) + 1:
		print('NO')
	elif s[0:s.index('*')] == t[0:s.index('*')] and s[s.index('*') + 1:] == t[len(t) - q:len(t)]:
		print('YES')
	else:
		print('NO')
elif '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
a = input().split('*')
b = input()
print('YES' if n == m and a[0] == b else 'YES' if len(a) == 2 and m - n >= -1 and (b[:len(a[0])] == a[0]) and (b[m - len(a[1]):] == a[1]) else 'NO')


n_m = input().split()
n = int(n_m[0])
m = int(n_m[1])
s = input()
t = input()
answer = 'YES'
symbol = '*'
if symbol in s:
	s_list = list(s)
	if len(s_list) == 1:
		answer = 'YES'
	else:
		star_index = s_list.index(symbol)
		if star_index == 0:
			s_right = s[1:]
			if not t.endswith(s_right):
				answer = 'NO'
		elif star_index == n - 1:
			s_left = s[:-1]
			if not t.startswith(s_left):
				answer = 'NO'
		else:
			s_left = s[:star_index]
			s_right = s[star_index + 1:]
			if not (t.startswith(s_left) and t.endswith(s_right)):
				answer = 'NO'
			elif n - m > 1:
				answer = 'NO'
elif s != t:
	answer = 'NO'
print(answer)


(n, m) = [int(s) for s in input().split()]
s = input()
t = input()
gg = -1
gg = s.find('*')
if gg == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit()
s1 = s[:gg]
s2 = s[gg + 1:]
if t.find(s1) == 0 and t[::-1].find(s2[::-1]) == 0 and (len(t) + 2 > len(s)):
	print('YES')
else:
	print('NO')


num = input()
(num1, num2) = num.split()
num1 = int(num1)
num2 = int(num2)
word1 = input()
word2 = input()
if num1 > num2 + 1:
	print('NO')
elif not '*' in word1:
	if word1 == word2:
		print('YES')
	else:
		print('NO')
else:
	(word1_1, word1_2) = word1.split('*')
	len_word1_1 = len(word1_1)
	len_word1_2 = len(word1_2)
	if word2[:len_word1_1] == word1_1 and word2[num2 - len_word1_2:] == word1_2:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if not '*' in s:
	print(s == t and 'YES' or 'NO')
else:
	(s1, s2) = s.split('*')
	print(t.islower() and len(s) - 1 <= len(t) and t.startswith(s1) and t.endswith(s2) and 'YES' or 'NO')


def fitSearch(S, T):
	parts_S = S.split('*')
	if len(parts_S) == 1:
		if S == T:
			return 'YES'
		else:
			return 'NO'
	try:
		firstIndex = 0
		while firstIndex < len(parts_S[0]):
			if T[firstIndex] != parts_S[0][firstIndex]:
				return 'NO'
			firstIndex += 1
		secondIndex = len(parts_S[1]) - 1
		secondIndexT = len(T) - 1
		while secondIndex >= 0:
			if T[secondIndexT] != parts_S[1][secondIndex]:
				return 'NO'
			secondIndex -= 1
			secondIndexT -= 1
		if len(parts_S[0]) + len(parts_S[1]) > len(T):
			return 'NO'
	except:
		return 'NO'
	return 'YES'
(sizeS, sizeT) = tuple(map(int, input().split(' ')))
S = input()
T = input()
print(fitSearch(S, T))


(n, m) = map(int, input().split())
(a, b) = (input(), input())
if '*' not in a:
	print('YES' if a == b else 'NO')
else:
	(l, r) = a.split('*')
	if b.startswith(l) and b.endswith(r) and (len(l) + len(r) <= len(b)):
		print('YES')
	else:
		print('NO')


(n, m) = [int(x) for x in input().split()]
s = str(input())
t = str(input())
if s.count('*') == 0:
	if s == t:
		print('YES')
	else:
		print('NO')
elif n == m + 1 and s[:s.index('*')] + s[s.index('*') + 1:] == t:
	print('YES')
elif n > m + 1:
	print('NO')
elif n < m + 1 and s[:s.index('*')] + s[s.index('*') + 1:] == t[:s.index('*')] + t[s.index('*') + 1 + m - n:]:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
input = lambda : stdin.readline().rstrip()
write = stdout.write

def main():
	(N, M) = map(int, input().split())
	S = input()
	T = input()
	if not T.isalpha():
		print('NO')
		return
	if '*' in S:
		if N - 1 > M:
			print('NO')
			return
	elif S != T:
		print('NO')
		return
	s = S.split('*')
	for (i, s_) in enumerate(s[0]):
		if not s_:
			continue
		if s_ != T[i]:
			print('NO')
			return
	if len(s) > 1:
		for (i, s_) in enumerate(s[1], start=1):
			if not s_:
				continue
			if s[1][-i] != T[-i]:
				print('NO')
				return
	print('YES')
main()


(n, m) = map(int, input().strip().split())
s = input().strip()
t = input().strip()
try:
	(start, end) = s.split('*')
	if t.startswith(start):
		t = t[len(start):]
		print('YES' if t.endswith(end) else 'NO')
	else:
		print('NO')
except ValueError:
	print('YES' if s == t else 'NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s.find('*') == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif m < n - 1:
	print('NO')
else:
	x = s.find('*')
	l2 = len(s[x + 1:n])
	l1 = len(s[0:x])
	if s[x + 1:n] == t[m - l2:m] and s[0:x] == t[0:l1]:
		print('YES')
	else:
		print('NO')


(a, b) = map(int, input().split())
s1 = str(input())
s2 = str(input())
try:
	l = s1.index('*')
	if s1[0:l:1] == s2[0:l:1] and s1[-1:-len(s1) + l:-1] == s2[-1:-len(s1) + l:-1]:
		if len(s2) >= len(s1) - 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
except:
	if s1 == s2:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if m < n - 1:
	print('NO')
elif '*' in s:
	i = 0
	f = 1
	while i < n and s[i] != '*':
		if s[i] != t[i]:
			f = 0
			break
		else:
			i = i + 1
	if f == 1:
		i = n - 1
		j = m - 1
		while s[i] != '*':
			if s[i] != t[j]:
				f = 0
				break
			else:
				i = i - 1
				j = j - 1
		if f == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s == t:
	print('YES')
elif s.count('*') > 0:
	k = s.find('*')
	s1 = s[:k]
	s2 = t[:k]
	s3 = s[k + 1:]
	s4 = t[m - n + k + 1:]
	if n > m + 1:
		print('NO')
		exit()
	if s1 == s2 and s3 == s4:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def cin(obj=list, type=int, sep=' '):
	return obj(map(type, input().split(sep)))
(n, m) = cin()
(s, t) = (input(), input())
pos = s.find('*')
if pos == -1:
	if n != m:
		print('NO')
		quit()
	else:
		pos = n
if t.startswith(s[:pos]) and t.endswith(s[pos + 1:]) and (pos + n - pos - 1 <= m):
	print('YES')
else:
	print('NO')


numbers = list(map(int, input().split()))
n = numbers[0]
m = numbers[1]
s = input()
t = input()
if n > m + 1:
	print('NO')
elif n == 1 and n == m and (s != '*') and (s != t):
	print('NO')
elif n == m and s == '*':
	print('YES')
elif n == m and s == t:
	print('YES')
else:
	newS = s.split('*')
	if len(newS) == 1:
		if newS[0] == t:
			print('YES')
		elif n == m and t[0:len(newS[0])] == newS[0]:
			print('YES')
		else:
			print('NO')
	else:
		lenSt = len(newS[0])
		lenDr = len(newS[1])
		if t[0:lenSt] == newS[0] and t[-lenDr:] == newS[1]:
			print('YES')
		elif t[0:lenSt] == newS[0] and lenDr == 0:
			print('YES')
		elif n == m and lenDr == 0 and (t[0:lenSt - 1] == newS[0]):
			print('YES')
		else:
			print('NO')


(n, m) = [int(x) for x in input().split()]
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	sp1 = s[:s.index('*')]
	sp2 = s[s.index('*') + 1:]
	if t[0:len(sp1)] == sp1 and t[m - len(sp2):] == sp2 and (len(sp1) - 1 < m - len(sp2)):
		print('YES')
	else:
		print('NO')


(n, m) = [int(j) for j in input().split()]
s = input()
t = input()
if s == '*':
	print('YES')
	exit(0)
if len(s) - 1 > len(t):
	print('NO')
	exit(0)
a = s.split('*')
if len(a) == 1 and s != t:
	print('NO')
	exit(0)
elif len(a) == 1 and s == t:
	print('YES')
	exit(0)
if len(a) == 2:
	s1 = t[:len(a[0])]
	s2 = t[-len(a[1]):]
	if len(a[0]) == 0:
		if s2 == a[0] + a[1]:
			print('YES')
			exit(0)
		else:
			print('NO')
			exit(0)
	if len(a[1]) == 0:
		if s1 == a[0] + a[1]:
			print('YES')
			exit(0)
		else:
			print('NO')
			exit(0)
	if s1 + s2 == a[0] + a[1]:
		print('YES')
	else:
		print('NO')


(formatLen, toCheckLen) = [int(x) for x in input().split(' ')]
format = input()
toCheck = input()
if '*' not in format:
	if format == toCheck:
		print('YES')
	else:
		print('NO')
	exit()
if not toCheck.isalpha():
	print('NO')
	exit()
(start, end) = format.split('*')
if toCheckLen - len(end) <= len(start) - 1:
	print('NO')
	exit()
if not toCheck.startswith(start) or not toCheck.endswith(end):
	print('NO')
	exit()
print('YES')


import re
(n, m) = map(int, input().split())
s = input()
t = input()
if s.find('*') == -1:
	print('YES' if s == t else 'NO')
	exit(0)
s = s.split('*')
if t.startswith(s[0]) and t.endswith(s[1]) and (len(t) >= sum(map(len, s))):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = list(input())
t = list(input())
a = s.count('*')
c = n
if a == 1:
	c = s.index('*')
b = m - n
if c != n:
	if s[:c] == t[:c] and s[c + 1:] == t[m - (n - c - 1):] and (m - n + c + 1 >= c):
		print('YES')
		exit(0)
	else:
		print('NO')
		exit(0)
elif s == t:
	print('YES')
	exit(0)
else:
	print('NO')
	exit(0)


(s, t) = map(int, input().split())
str_1 = str(input())
str_2 = str(input())
if s < t:
	try:
		str_1 = str_1[:str_1.index('*') + 1] + '*' * abs(s - t) + str_1[str_1.index('*') + 1:]
		is_redact = 'YES'
		for i in range(t):
			if str_1[i] != '*':
				if str_1[i] == str_2[i]:
					pass
				else:
					is_redact = 'NO'
		print(is_redact)
	except:
		print('NO')
elif s > t:
	str_1b = str_1.replace('*', '')
	if str_1b == str_2:
		print('YES')
	else:
		print('NO')
elif str_1 == str_2:
	print('YES')
else:
	is_redact = 'YES'
	for i in range(t):
		if str_1[i] != '*':
			if str_1[i] == str_2[i]:
				pass
			else:
				is_redact = 'NO'
	print(is_redact)


(n, m) = [int(i) for i in input().split()]
menor = min(n, m)
s = input()
t = input()

def verifica():
	if not '*' in s:
		if s == t:
			return 'YES'
		else:
			return 'NO'
	if n - m > 1:
		return 'NO'
	for i in range(menor):
		if not s[i] == '*':
			if s[i] != t[i]:
				return 'NO'
		if s[i] == '*':
			break
	for i in range(1, menor):
		if not s[-i] == '*':
			if s[-i] != t[-i]:
				return 'NO'
		if s[-i] == '*':
			break
	return 'YES'
print(verifica())


import sys
a = input()
a = input()
b = input()
index = a.find('*')
tail = len(a) - index - 1
if index == -1 or len(b) < len(a) - 1:
	print('YES' if a == b else 'NO')
elif a[:index] == b[:index] and (a[-tail:] == b[-tail:] or tail == 0):
	print('YES')
else:
	print('NO')


def sol():
	(S, T) = [int(x) for x in input().split(' ')]
	s = input()
	t = input()
	if not '*' in s:
		return s == t
	(one, two) = s.split('*')
	if T < S - 1:
		return False
	t_one = t[:len(one)] == one or one == ''
	t_two = t[-1 * len(two):] == two or two == ''
	return t_one and t_two
ans = sol()
print('YES' if ans else 'NO')


from string import printable
(n, m) = input().split(' ')
s = input()
t = input()
if int(n) > int(int(m) + 1):
	print('NO')
	exit(0)
if int(n) <= int(int(m) + 1):
	if '*' in s:
		x = s.split('*')
		h = len(x[1])
		z = len(x[0])
		if x[0] == t[:z] and x[1] == t[len(t) - h:]:
			print('YES')
		else:
			print('NO')
	elif s != t:
		print('NO')
	else:
		print('YES')


(a, b) = input().split()
a = input()
b = input()
if '*' in a:
	(c, d) = a.split('*')
	print('YES' if b.startswith(c) and b.endswith(d) and (len(a) - 1 <= len(b)) else 'NO')
else:
	print('YES' if a == b else 'NO')


_ = input()
s = input()
t = input()
p = s.find('*')
l = len(s) - p - 1
print('YES' if (s == t if p < 0 else p + l <= len(t) and (not p or s[:p] == t[:p]) and (not l or s[-l:] == t[-l:])) else 'NO')


(n, m) = input().split(' ')
n = int(n)
m = int(m)
s = input()
t = input()
ck = 0
res = 0
mark1 = 0
mark2 = 0
for i in range(0, n):
	if s[i] == '*':
		ck = 1
if ck == 0:
	if s == t:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
for i in range(0, n):
	if s[i] == '*':
		mark1 = i - 1
		break
	if i < m and s[i] != t[i]:
		print('NO')
		exit()
for i in range(n - 1, -1, -1):
	if s[i] == '*':
		mark2 = m - (n - i)
		break
	if m - (n - i) >= 0:
		if s[i] != t[m - (n - i)]:
			print('NO')
			exit()
if mark1 > mark2:
	print('NO')
	exit()
print('YES')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	ind = s.index('*')
	if s[0:ind] + s[ind + 1:] == t:
		print('YES')
	else:
		tmp = s[0:ind] + t[ind:m - n + ind + 1] + s[ind + 1:]
		if tmp == t:
			print('YES')
		else:
			print('NO')


(n, m) = [int(x) for x in input().split()]
s = str(input())
t = str(input())
if n > m + 1:
	print('NO')
elif not '*' in s and s != t:
	print('NO')
else:
	no = False
	for i in range(n):
		if s[i] != '*':
			if s[i] != t[i]:
				print('NO')
				no = True
				break
		else:
			if i < m and (not t[i].isalpha()):
				print('NO')
				no = True
			break
	if not no:
		min = min(m, n)
		for i in range(1, min):
			if s[-i] != '*':
				if s[-i] != t[-i]:
					print('NO')
					no = True
					break
			else:
				break
		if not no:
			print('YES')


(n, m) = map(int, input().split())
s = list(map(str, input().split('*')))
t = input()
if len(s) == 1:
	if s[0] == t:
		print('YES')
	else:
		print('NO')
elif m - n < -1:
	print('NO')
elif s[0] == t[0:len(s[0])] and s[1] == t[m - len(s[1]):m]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
try:
	i = s.index('*')
	(Ls, Rs) = (s[:i], s[i + 1:])
	(Lt, Rt) = (t[:i], t[len(t) - len(Rs):])
	if Ls == Lt and Rs == Rt:
		if len(Lt + Rt) > len(t):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
except:
	if s == t:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if '*' not in s or m < n - 1:
	print('YES' if s == t else 'NO')
else:
	a = s.index('*')
	s = s[a + 1:] + s[:a]
	t = t[m - n + a + 1:] + t[:a]
	print('YES' if s == t else 'NO')


l = list(map(int, input().split()))
s1 = input().split('*')
s2 = input()
if len(s1) == 1:
	if s1[0] == s2:
		print('YES')
	else:
		print('NO')
elif s1[0] == '':
	if s1[1] == s2[len(s2) - len(s1[1]):len(s2)]:
		print('YES')
	else:
		print('NO')
elif s1[1] == '':
	if s1[0] == s2[0:len(s1[0])]:
		print('YES')
	else:
		print('NO')
elif len(s1[0]) + len(s1[1]) > len(s2):
	print('NO')
elif s1[0] == s2[0:len(s1[0])] and s1[1] == s2[len(s2) - len(s1[1]):len(s2)]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if '*' in s:
	(x, y) = s.split('*')
	r = t.startswith(x) and t[len(x):].endswith(y)
else:
	r = s == t
print(('NO', 'YES')[r])


def mmhaxor(s, t, n, m):
	(fo, bk) = (0, 0)
	if s == t:
		print('YES')
	elif n - m > 1:
		print('NO')
	elif n == 1 and m == 1:
		if s != t and s != '*':
			print('NO')
		if s != t and s == '*':
			print('YES')
	elif s.count('*') > 1:
		print('NO')
	elif s.count('*') == 0 and s != t:
		print('NO')
	else:
		flag = True
		for i in range(m):
			if s[i] != t[i] and s[i] == '*':
				fo = i
				break
			elif s[i] != t[i] and s[i] != '*':
				flag = False
				break
		for (i, j) in zip(range(n - 1, -1, -1), range(m - 1, -1, -1)):
			if s[i] != t[j] and s[i] == '*':
				bk = j + 1
				break
			elif s[i] != t[j] and s[i] != '*':
				flag = False
				break
		if flag == False:
			print('NO')
		elif t[fo:bk].isalpha() or fo == bk:
			print('YES')
		else:
			print('NO5')
(n, m) = map(int, input().split())
s = input()
t = input()
mmhaxor(s, t, n, m)


input()
s = input()
t = input()
sl = s.split('*')
if len(sl) == 1:
	if s == t:
		print('YES')
	else:
		print('NO')
else:

	def Equal(a, b):
		if a == '' or b == '':
			return True
		return a == b
	if len(s) - 1 > len(t):
		print('NO')
	elif Equal(sl[0], t[:len(sl[0])]) and Equal(sl[1], t[-len(sl[1]):]):
		print('YES')
	else:
		print('NO')


(n, m) = list(map(int, input().split()))
s = input()
t = input()
if '*' not in s:
	if s != t:
		print('NO')
	else:
		print('YES')
else:
	(first, second) = s.split('*')
	if m + 1 >= n and t[:len(first)] == first and (t[-len(second):] == second or second == ''):
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s == t:
	print('YES')
	exit(0)
if n - 2 >= m:
	print('NO')
	exit(0)
ma = 0
for i in range(max(n, m)):
	if i < n and (s[i] == '*' or i < m):
		if s[i] != '*':
			if s[i] != t[i]:
				print('NO')
				exit(0)
		else:
			ma = i
			break
	else:
		print('NO')
		exit(0)
for i in range(max(n, m) - ma):
	if s[n - i - 1] != '*':
		if s[n - i - 1] != t[m - i - 1]:
			print('NO')
			exit(0)
	else:
		break
print('YES')


(N, M) = list(map(int, input().split()))
S = input().split('*')
T = input()
if len(S) == 1:
	print('YES' if S[0] == T else 'NO')
else:
	print('YES' if S[0] == T[:len(S[0])] and S[1] == T[len(T) - len(S[1]):] and (len(S[0]) + len(S[1]) <= len(T)) else 'NO')


def ans(s, t, n, m):
	if n > m:
		if s[0:s.find('*')] + s[s.find('*') + 1:] == t:
			return 'YES'
		else:
			return 'NO'
	if s.find('*') == -1:
		if s == t:
			return 'YES'
		else:
			return 'NO'
	s1 = s[0:s.find('*')]
	s2 = s[s.find('*') + 1:]
	a = t.find(s1)
	b = t.rfind(s2)
	if a == 0 and len(t) == b + len(s2):
		return 'YES'
	else:
		return 'NO'
(n, m) = map(int, input().split())
s = input()
t = input()
print(ans(s, t, n, m))


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	(s1, s2) = s.split('*')
	if n > m + 1:
		print('NO')
	elif t.startswith(s1) and t.endswith(s2):
		t = t.replace(s1, '', 1)
		t = t.replace(s2, '', -1)
		if t.isalpha() and t.islower() or t == '':
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


def get_problem_data():
	global n, m, s, t
	M = lambda : list(map(int, input().split()))
	(n, m) = M()
	s = input()
	t = input()

def solve(n, m, s, t):
	if '*' in s:
		(l, r) = s.split('*')
		return len(l) + len(r) <= len(t) and t.startswith(l) and t.endswith(r)
	else:
		return s == t
get_problem_data()
print(['NO', 'YES'][solve(n, m, s, t)])


input()
a = input()
b = input()
i = a.find('*')
if i == -1:
	if a == b:
		print('YES')
	else:
		print('NO')
else:
	left = a[:i]
	right = a[i + 1:]
	if len(right) == 0:
		rp = ''
	else:
		rp = b[-len(right):]
	if len(a) - 1 <= len(b) and b[:len(left)] == left and (rp == right):
		print('YES')
	else:
		print('NO')


(a, b) = [int(x) for x in input().split()]
tmp = input()
s = input()
if '*' in tmp:
	(x, y) = tmp.split('*')
	l = len(x)
	r = len(y)
	if l + r > b:
		print('NO')
	elif x == s[:l] and y == s[b - r:]:
		print('YES')
	else:
		print('NO')
elif tmp == s:
	print('YES')
else:
	print('NO')


def isValid(n, m, s, t):
	if n > m + 1:
		return 'NO'
	if '*' not in s:
		if s == t:
			return 'YES'
		return 'NO'
	ind = s.index('*')
	for i in range(ind):
		if s[i] != t[i]:
			return 'NO'
	i = n - 1
	j = m - 1
	while i > ind and j >= ind:
		if s[i] != t[j]:
			return 'NO'
		i -= 1
		j -= 1
	return 'YES'
(n, m) = map(int, input().split())
s = input()
t = input()
print(isValid(n, m, s, t))


(n, m) = map(int, input().split())
s = input()
t = input()

def f(n, m, s, t):
	i = s.find('*')
	if i == -1:
		return s == t
	if m < n - 1:
		return False
	c = 0
	while c < i:
		if s[c] != t[c]:
			return False
		c += 1
	d = 1
	while n - d > i:
		if s[-d] != t[-d]:
			return False
		d += 1
	while c + d < m + 1:
		if not t[c].islower():
			return False
		c += 1
	return True
if f(n, m, s, t):
	print('YES')
else:
	print('NO')


input()
s = input()
t = input()
if '*' not in s:
	print('YES' if s == t else 'NO')
else:
	(l, r) = s.split('*')
	if t.startswith(l) and t.endswith(r) and (len(l) + len(r) <= len(t)):
		print('YES')
	else:
		print('NO')


z1 = input()
a = input()
b = input()
if '*' in a:
	(q1, q2) = a.split('*')
	d = b[len(q1):len(b) - len(q2)]
	if q1 + d + q2 == b:
		print('YES')
	else:
		print('NO')
elif a == b:
	print('YES')
else:
	print('NO')


l = list(map(int, input().split()))
n = l[0]
m = l[1]
s1 = input()
s2 = input()
f = s1.find('*')
rs1 = s1[::-1]
rs2 = s2[::-1]
f2 = rs1.find('*')
if f == -1:
	if s1 == s2:
		print('YES')
	else:
		print('NO')
elif s1[:f] == s2[:f] and rs1[:f2] == rs2[:f2] and (n - 1 <= m):
	print('YES')
else:
	print('NO')


n = input()
s = input()
t = input()
p = s.find('*')
if p == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
	return
sl = len(s) - p - 1
if s[:p] == t[:p] and t[len(t) - sl:] == s[p + 1:] and (len(t) >= len(s) - 1):
	print('YES')
else:
	print('NO')


(n, m) = input().split()
m = int(m)
n = int(n)
s = str(input())
q = 0
t = str(input())
try:
	k = s.index('*')
	if n <= m + 1 and s[:k] == t[:k]:
		if s[k + 1:] == t[m + 1 - n + k:]:
			print('YES')
			q = 1
	if q == 0:
		print('NO')
except:
	if s == t:
		print('YES')
	else:
		print('NO')


from collections import *
from math import *
(n, m) = list(map(int, input().split()))
s = input()
t = input()
if s.count('*') == 0:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	ind = s.index('*')
	if s[:ind] != t[:ind]:
		print('NO')
	else:
		no = n - (ind + 1)
		if m - no < ind:
			print('NO')
		elif s[n - no:] == t[m - no:]:
			print('YES')
		else:
			print('NO')


(n, m) = map(int, input().split())
s1 = input()
s2 = input()
if '*' not in s1:
	if s1 == s2:
		print('YES')
	else:
		print('NO')
else:
	(a, b) = s1.split('*')
	if a == s2[:len(a)] and b == s2[m - len(b):] and (len(a) + len(b) <= m):
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if '*' not in s:
	print('YES' if s == t else 'NO')
else:
	(l, r) = s.split('*')
	if t.startswith(l) and t.endswith(r) and (len(l) + len(r) <= len(t)):
		print('YES')
	else:
		print('NO')


insert = input()
insert = insert.split()
first = int(insert[0])
second = int(insert[1])
firstInput = input()
secondInput = input()
starExist = False
starPosition = 0
same = True
for i in range(0, first):
	if firstInput[i] == '*':
		starExist = True
		starPosition = i
dataDiff = second - first
if dataDiff < -1:
	same = False
elif starExist:
	for i in range(0, starPosition):
		if not firstInput[i] == secondInput[i]:
			same = False
			break
	for i in range(first - 1, starPosition, -1):
		if not secondInput[i + dataDiff] == firstInput[i]:
			same = False
			break
elif not firstInput == secondInput:
	same = False
if same == True:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
a = input()
b = input()
if a.count('*') == 0:
	if a == b:
		print('YES')
	else:
		print('NO')
elif n - 1 > m:
	print('NO')
else:
	i = 0
	j = 0
	while i < m and j < n and (a[i] == b[j]):
		i += 1
		j += 1
	k = n - 1
	l = m - 1
	while k >= 0 and l >= 0 and (a[k] == b[l]):
		k -= 1
		l -= 1
	if i == k:
		print('YES')
	else:
		print('NO')


input()
s = input()
t = input()
if '*' in s:
	(a, b) = s.split('*')
	ans = t.startswith(a) and t[len(a):].endswith(b)
else:
	ans = s == t
print(['NO', 'YES'][ans])


(n, m) = map(int, input().split())
s = input()
t = input()
wi = 0
for e in s:
	if e == '*':
		break
	wi += 1
if len(t) >= len(s) - 1:
	if wi == len(s):
		if s == t:
			print('YES')
		else:
			print('NO')
	elif wi == len(s) - 1 and s[:wi] == t[:wi]:
		print('YES')
	elif t[:wi] == s[:wi] and s[wi + 1:] == t[-len(s[wi + 1:]):] and (len(s[:wi]) + len(s[wi + 1:]) <= len(t)):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


l = [int(i) for i in input().split()]
n = l[0]
m = l[1]
s = input()
t = input()
st = -1
if '*' in s:
	st = s.index('*')
if len(s) > len(t) + 1:
	print('NO')
	exit()
if st >= 0 and st < len(s) - 1 and (s[0:st] == t[0:st]) and (s[st + 1:] == t[-(len(s) - st - 1):]):
	print('YES')
elif st == len(s) - 1 and s[0:st] == t[0:st]:
	print('YES')
elif st < 0 and s == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	b = s.index('*')
	st = s[:b]
	st1 = s[b + 1:]
	st2 = t[:b]
	st3 = t[max(len(t) - len(st1), b):]
	if st == st2 and st1 == st3:
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


input()
(s, t) = (input(), input())
if '*' in s:
	(x, y) = s.split('*')
	r = t.startswith(x) and t[len(x):].endswith(y)
else:
	r = t == s
print(('NO', 'YES')[r])


(n, m) = [int(x) for x in input().split(' ')]
s = input()
t = input()
if '*' in s:
	s = s.split('*')
	if (s[0] == t[0:len(s[0])] or len(s[0]) == 0) and (s[1] == t[-len(s[1]):] or len(s[1]) == 0) and (len(s[0]) + len(s[1]) <= len(t)):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


def f():
	input()
	s = input()
	t = input()
	if '*' not in s:
		return s == t
	if len(s) - len(t) > 1:
		return False
	star_index = s.index('*')
	return s[:star_index] == t[:star_index] and t.endswith(s[star_index + 1:])
res = f()
print('YES' if res else 'NO')


(n, m) = map(int, input().split())
s = input()
t = input()
res = 0
if '*' not in s:
	res = s == t
else:
	i = s.index('*')
	l = s[:i]
	r = s[i + 1:]
	if t.startswith(l):
		t = t[i:]
		if t.endswith(r):
			res = 1
print('YES' if res else 'NO')


a = input().split(' ')
b = input()
c = input()
if len(c) < len(b) - 1:
	print('NO')
elif b.find('*') != -1:
	x = b.index('*')
	if b[:x] == c[:x] and b[x + 1:] == c[len(c) - len(b) + x + 1:]:
		print('YES')
	else:
		print('NO')
elif b == c:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if n == 1:
	if s == t or s == '*':
		print('YES')
	else:
		print('NO')
elif s.count('*') == 0:
	if s == t:
		print('YES')
	else:
		print('NO')
elif n > m + 1:
	print('NO')
else:
	l = s.split('*')
	x = t[:len(l[0])]
	y = t[-len(l[1]):]
	if l[0] == x and l[1] == y or (s[:1] == '*' and l[1] == y) or (l[0] == x and s[-1:] == '*'):
		print('YES')
	else:
		print('NO')


(m, n) = map(int, input().split())
a = list(input())
b = list(input())
star = 0
for i in range(m):
	if a[i] == '*':
		star = 1
		break
if a[:i] == b[:i]:
	if a[i] == '*' and i == m - 1:
		print('YES')
	elif a[i - m + 1:] == b[i - m + 1:] and n - m + star >= 0:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if len(s) - 1 > len(t):
	print('NO')
elif s[0] == '*':
	if s[1:n] == t[m - n + 1:m]:
		print('YES')
	else:
		print('NO')
elif '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	star = s.index('*')
	if s[0:star] != t[0:star]:
		print('NO')
	elif s[star + 1:n] != t[m - n + star + 1:m]:
		print('NO')
	else:
		print('YES')


q = input()
(n, m) = q.split()
n = int(n)
m = int(m)
s = input()
t = input()
if s.count('*') == 1:
	w = s.find('*')
	b = 0
	e1 = s[0:w]
	e2 = s[w + 1:]
	if len(e2) != 0:
		if t[0:w] != e1 or t[len(e2) * -1:] != e2:
			b = 1
	elif t[0:w] != e1:
		b = 1
	if n > m and n - m > 1:
		print('NO')
	elif b == 0:
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	(n, m) = mi()
	a = si()
	b = si()
	f = a.count('*')
	if f == 0:
		if a == b:
			print('YES')
		else:
			print('NO')
		return
	if n - 1 > m:
		print('NO')
		return
	x = ''
	y = ''
	for i in range(n):
		if a[i] == '*':
			x = a[:i]
			y = a[i + 1:]
			break
	f = 1
	for i in range(len(x)):
		if x[i] != b[i]:
			f = 0
			break
	if f == 0:
		print('NO')
		return
	l = len(y) - 1
	r = m - 1
	while l >= 0 and r >= 0:
		if y[l] != b[r]:
			f = 0
			break
		l -= 1
		r -= 1
	if f == 0:
		print('NO')
		return
	print('YES')
	return
	p1 = -1
	p2 = -1
	f = 1
	for i in range(min(n, m)):
		if a[i] != b[i] and a[i] == '*':
			p1 = i
			break
		elif a[i] != b[i]:
			f = 0
			break
	if f == 0:
		print('NO')
		return
	l = n - 1
	r = m - 1
	while l >= 0 and r >= 0:
		if a[l] != b[r] and a[l] == '*':
			p2 = l
			break
		elif a[l] != b[r]:
			f = 0
			break
		l -= 1
		r -= 1
	if f == 0:
		print('NO')
		return
	if p1 <= p2:
		print('YES')
	else:
		print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


i = input().split(' ')
n = int(i[0])
m = int(i[1])
s = input()
t = input()

def check():
	n_wildcard = s.count('*')
	if n_wildcard > 1 or n > m + 1:
		return False
	elif n_wildcard == 0:
		if s != t:
			return False
	else:
		index = s.index('*')
		for i in range(0, index):
			if s[i] != t[i]:
				return False
		selisih = m - n
		for i in range(index + 1, len(s)):
			if s[i] != t[i + selisih]:
				return False
	return True
res = check()
if res == False:
	print('NO')
else:
	print('YES')


z = lambda : map(int, input().split())
zz = lambda : list(map(int, input().split()))
(n, m) = z()
aa = 0
q = []
w = []
qq = []
ww = []
rr = False
s = list(map(str, input()))
if '*' in s:
	a = s.index('*')
t = list(map(str, input()))
c = False
if '*' in s:
	if n >= m + 2:
		c = False
	else:
		q = s[:a]
		w = s[a + 1:]
		xxx = len(w)
		if a == 0:
			qq = q
		else:
			qq = t[:a]
		if a == len(s) - 1:
			ww = w
		else:
			ww = t[-xxx:]
		if qq == q and ww == w:
			c = True
		else:
			c = False
elif t == s:
	c = True
else:
	c = False
print('YES' if c else 'NO')


def solve(s, t):
	if s == '*':
		return True
	i = s.find('*')
	if i < 0:
		return t == s
	elif len(t) < len(s) - 1:
		return False
	else:
		a = s[:i]
		b = s[i + 1:]
		if a == t[:i] and (b == t[-len(b):] or len(b) == 0):
			return True
		else:
			return False
(n, m) = map(int, input().split())
s = input()
t = input()
if solve(s, t):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
pos_x = s.find('*')
if pos_x == -1:
	print('NO' if s != t else 'YES')
elif n - m > 1 or s[:pos_x] != t[:pos_x]:
	print('NO')
else:
	end_s = s[pos_x + 1:]
	end_t = t[len(t) - len(end_s):]
	if end_s != end_t:
		print('NO')
	else:
		print('YES')


addr1 = 'C:\\Users\\admin\\Desktop\\python_in.txt'
addr2 = 'C:\\Users\\admin\\Desktop\\python_out.txt'
input()
(s, t) = (input(), input())
if '*' in s:
	(x, y) = s.split('*')
	r = t.startswith(x) and t[len(x):].endswith(y)
else:
	r = t == s
print(('NO', 'YES')[r])


i = input
i()
s = i()
t = i()

def go():
	if '*' not in s:
		return s != t
	(a, b) = s.split('*')
	return len(a + b) > len(t) or not (t.startswith(a) and t.endswith(b))
print('YNEOS'[go()::2])


import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = num()
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	zz = s.index('*')
	pp = s[0:zz]
	kk = t[0:zz]
	lk = s[zz + 1:]
	lz = t[m - len(lk):]
	if pp == kk and lk == lz and (m - len(lk) >= zz):
		print('YES')
	else:
		print('NO')


(n, m) = list(map(int, input().strip().split()))
r = input()
s = input()
if '*' not in r:
	if r == s:
		print('YES')
	else:
		print('NO')
	return
(r1, r2) = r.split('*')
if len(s) < len(r1) + len(r2):
	print('NO')
else:
	l1 = len(r1)
	l2 = len(r2)
	if s[0:l1] == r1 and s[len(s) - l2:] == r2:
		print('YES')
	else:
		print('NO')


import bisect
(n, m) = list(map(int, input().strip().split()))
s = input().strip()
t = input().strip()
x = s.find('*')
if len(s) > len(t) + 1:
	print('NO')
elif x == 0:
	if s[1:] == t[len(t) - len(s) + 1:len(t)]:
		print('YES')
	else:
		print('NO')
elif x == len(s) - 1:
	if s[:len(s) - 1] == t[0:len(s) - 1]:
		print('YES')
	else:
		print('NO')
elif s[:x] == t[0:x] and s[x + 1:] == t[len(t) + x - len(s) + 1:len(t)]:
	print('YES')
else:
	print('NO')


a = list(map(int, input().split(' ')))
s = input()
t = input()
if a[1] + 1 < a[0]:
	print('NO')
elif not '*' in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	z = s.index('*')
	if t[:z] == s[:z] and t[z - a[0] + 1:] == s[z - a[0] + 1:]:
		print('YES')
	elif t[:z] == s[:z] and z + 1 == a[0]:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	if m < n - 1:
		print('NO')
	elif s[0] == '*':
		if s[1:n] == t[m - n + 1:m]:
			print('YES')
		else:
			print('NO')
	elif s[n - 1] == '*':
		if s[0:n - 1] == t[0:n - 1]:
			print('YES')
		else:
			print('NO')
	else:
		p = s.split('*')
		if p[0] == t[0:len(p[0])] and p[1] == t[m - len(p[1]):m]:
			print('YES')
		else:
			print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = list(input())
t = list(input())
starPos = -1
for i in range(n):
	if s[i] == '*':
		starPos = i
		break
if starPos == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif m + 1 >= n and s[:starPos] == t[:starPos] and (s[starPos + 1:] == t[m - (n - starPos - 1):]):
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
s = input()
t = input()
x = s.find('*')
if s == t:
	print('YES')
elif x == -1:
	print('NO')
elif n - 1 > m:
	print('NO')
elif s[:x] == t[:x]:
	z = s[x + 1:]
	z = z[::-1]
	p = t[::-1]
	p = p[:len(z)]
	if p == z:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
temp = s.split('*')
if len(temp) == 1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif t.startswith(temp[0]) and t.endswith(temp[-1]) and (n - 1 <= m):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
i = s.find('*')
start = end = ''
if i == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	start = s[:i]
	end = s[i + 1:]
	match = True
	if len(start) > 0:
		if not t.startswith(start):
			match = False
		else:
			t = t[len(start):]
	if len(end) > 0 and match:
		if not t.endswith(end):
			match = False
	if match:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
idx = -1
for i in range(len(s)):
	if s[i] == '*':
		idx = i
		break
if idx == -1:
	if m < n:
		print('NO')
		exit()
elif m < n - 1:
	print('NO')
	exit()
s1 = s[:idx]
if idx == n - 1:
	if s1 == t[:idx]:
		print('YES')
	else:
		print('NO')
	exit()
s2 = s[idx + 1:]
if t[:idx] == s1 and t[m - n + idx + 1:] == s2:
	print('YES')
else:
	print('NO')


input()
a = input()
b = input()
a = a.split('*')
if len(a) == 1:
	if a[0] == b:
		print('YES')
	else:
		print('NO')
elif len(b) < len(a[0]) + len(a[1]) or (a[0] != b[:len(a[0])] and len(a[0]) > 0) or (a[1] != b[-len(a[1]):] and len(a[1]) > 0):
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
s = str(input())
t = str(input())
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit()
(a, b) = s.split('*')
if len(t) < len(a) + len(b):
	print('NO')
	exit()
if t[:len(a)] == a and t[len(t) - len(b):] == b:
	print('YES')
else:
	print('NO')


num = input()
latin = input()
string = input()
latin1 = []
latin2 = []
counter = 0
nums = num.split()
if int(nums[0]) > int(nums[1]) + 1:
	bool = False
else:
	test = True
	for i in latin:
		if i == '*':
			counter += 1
		if counter == 0:
			latin1.append(i)
		elif counter == 1 and i != '*':
			latin2.append(i)
	index = 0
	bool = True
	if counter == 0:
		if latin != string:
			bool = False
			test = False
	for i in latin1:
		if test == False:
			break
		if string[index] == i:
			latin1[index] = 0
			index += 1
		else:
			bool = False
			break
	index -= 1
	back = -1
	index2 = len(string) - 1
	for _ in range(0, len(latin2)):
		if latin2[back] == string[back] and index2 != index:
			latin2[back] = 0
			back -= 1
			index2 -= 1
		else:
			bool = False
			break
if bool == True:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s.find('*') == -1 and s != t:
	print('NO')
else:
	q = s.find('*')
	z = n - q - 1
	if s[:q] == t[:q] and s[q + 1:] == t[m - z:] and (n - 1 <= m):
		print('YES')
	else:
		print('NO')


input()
s = input()
t = input()
if '*' in s:
	part = s.split('*')
	if part[0] in t[:len(part[0])] and t.endswith(part[1]) and (len(s) - 1 <= len(t)):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	(a, b) = s.split('*')
	if len(a) + len(b) <= len(t) and t.startswith(a) and t.endswith(b):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


def solve(n, m, s, t):
	if '*' in s:
		(l, r) = s.split('*')
		return len(l) + len(r) <= len(t) and t.startswith(l) and t.endswith(r)
	else:
		return s == t
(n, m) = map(int, input().split())
s = input()
t = input()
print(['NO', 'YES'][solve(n, m, s, t)])


(n, m) = map(int, input().strip().split())
pattern = input()
string = input()
if '*' not in pattern:
	if pattern == string:
		print('YES')
	if pattern != string:
		print('NO')
	exit(0)
(r1, r2) = pattern.split('*')
if len(string) < len(r1) + len(r2):
	print('NO')
else:
	l1 = len(r1)
	l2 = len(r2)
	if string[0:l1] == r1 and string[len(string) - l2:] == r2:
		print('YES')
	else:
		print('NO')


(n, m) = [int(i) for i in input().split()]
s = str(input())
t = str(input())
p = s.find('*')
z = n - p
if p == -1 and s != t:
	print('NO')
elif s == t:
	print('YES')
elif t[:p] == s[:p] and t[::-1][:n - p - 1][::-1] == s[p + 1:] and (n <= m + 1):
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
a = input()
b = input()
if '*' in a:
	if n - 1 > m:
		print('NO')
	else:
		i = a.index('*')
		if a[:i] == b[:i] and a[i + 1:] == b[m - (n - i - 1):]:
			print('YES')
		else:
			print('NO')
elif a == b:
	print('YES')
else:
	print('NO')


ar_count = input().split()
lenS = int(ar_count[0])
lenT = int(ar_count[1])
stringS = input()
stringT = input()
go = True
if lenS > lenT + 1:
	go = False
elif '*' not in stringS and stringS != stringT:
	go = False
else:
	for i in range(lenS):
		if stringS[i] == '*':
			if i == lenS - 1:
				go = True
				break
			else:
				pos = -1 * (lenS - i - 1)
				pos2 = -1 * (lenT - i)
				tempString = stringS[pos:]
				tempOtherString = stringT[pos2:]
				if len(tempOtherString) < len(tempString):
					go = False
					break
				else:
					pos2 = -1 * len(tempString)
					tempOtherString = tempOtherString[pos2:]
					if tempString == tempOtherString:
						go = True
					else:
						go = False
					break
		elif stringS[i] != stringT[i]:
			go = False
			break
if go:
	print('YES')
else:
	print('NO')


(n, m) = input().split(' ')
n = int(n)
s = input()
t = input()
f = 0
for i in s:
	if i == '*':
		f = 1
		break
if f == 1:
	s = s.split('*')
	if len(s) < 2:
		s.append('')
	t1 = t[0:len(s[0])]
	t2 = t[len(t) - len(s[1]):len(t)]
	if t1 == s[0] and t2 == s[1] and (len(t) >= len(s[0]) + len(s[1])):
		print('YES')
	else:
		print('NO')
elif t == s:
	print('YES')
else:
	print('NO')


(num1, num2) = map(int, input().split())
a = input()
b = input()
if '*' not in a:
	if a == b:
		print('YES')
	else:
		print('NO')
else:
	(q, h) = a.split('*')
	if (b.startswith(q) and b.endswith(h)) and len(q) + len(h) <= len(b):
		print('YES')
	else:
		print('NO')


input()
exp = input()
check = input()
if '*' not in exp:
	if exp == check:
		print('YES')
	else:
		print('NO')
else:
	str = exp.split('*')
	if check.startswith(str[0]) and check.endswith(str[-1]) and (len(str[0]) + len(str[-1]) <= len(check)):
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
a = input()
b = input()
if '*' in a:
	print('YES' if b.startswith(a[:a.find('*')]) and b.endswith(a[a.find('*') + 1:]) and (n <= m + 1) else 'NO')
elif a == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
idx = s.find('*')
if idx == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	(first, second) = s.split('*')
	res = first + t[idx:idx + (m - n + 1)] + second
	if res == t:
		print('YES')
	else:
		print('NO')


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
(n, m) = mi()
s = input().strip()
t = input().strip()
ok = 0
if '*' not in s:
	ok = s == t
else:
	i = s.index('*')
	l = s[:i]
	r = s[i + 1:]
	if t.startswith(l):
		t = t[i:]
		if t.endswith(r):
			ok = 1
print('YES' if ok else 'NO')


(a, b) = input().split(' ', 2)
a = int(a)
b = int(b)
stra = input().split()[0]
strb = input().split()[0]
flag = 0
(x, y) = (0, 0)
if not strb.isalpha():
	print('NO')
	exit()
if a - 1 > b:
	print('NO')
	exit()
global i
for i in range(a):
	if stra[i] == '*':
		flag = 1
		break
if flag:
	x = len(stra[i + 1:a])
	if stra[0:i] == strb[0:i] and stra[i + 1:a] == strb[b - x:b]:
		print('YES')
	else:
		print('NO')
elif stra == strb:
	print('YES')
else:
	print('NO')


(x, y) = map(int, input().split())
a = input()
b = input()
while 1:
	if '*' not in a and a == b:
		print('YES')
		break
	if '*' not in a and a != b:
		print('NO')
		break
	ch = ''
	c = len(a[a.index('*') + 1:])
	ch = a[0:a.index('*')] + b[a.index('*'):len(b) - c] + a[a.index('*') + 1:]
	if ch == b:
		print('YES')
		break
	else:
		print('NO')
		break


def readNums(type=int):
	return list(map(type, input().split()))
(n, m) = readNums()
(a, b) = (input(), input())
p = a.find('*')
if p == -1:
	print('YES' if a == b else 'NO')
else:
	print('YES' if a[:p] == b[:p] and m - (n - p - 1) >= p and (a[p + 1:] == b[m - (n - p - 1):]) else 'NO')


nums = input()
nums = nums.split()
n = int(nums[0])
m = int(nums[1])
first = input()
second = input()
if first == '*':
	print('YES')
elif '*' not in first:
	if first == second:
		print('YES')
	else:
		print('NO')
else:
	first = first.split('*')
	fleft = first[0]
	fright = first[1]
	sleft = second[0:len(fleft)]
	if m < n:
		sright = second[len(fleft):]
	else:
		sright = second[-1 * len(fright):]
	if not fleft:
		if fright == sright:
			print('YES')
		else:
			print('NO')
	elif not fright:
		if fleft == sleft:
			print('YES')
		else:
			print('NO')
	elif fleft == sleft and fright == sright:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if m < n - 1:
	print('NO')
elif '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
elif s[0] == '*':
	s1 = s[1:]
	t1 = t[m - n + 1:]
	if s1 == t1:
		print('YES')
	else:
		print('NO')
elif s[n - 1] == '*':
	s1 = s[:n - 1]
	t1 = t[:n - 1]
	if s1 == t1:
		print('YES')
	else:
		print('NO')
else:
	index = s.find('*')
	s1 = s[:index] + s[index + 1:]
	temp = n - index
	t1 = t[:index] + t[m - temp + 1:]
	if s1 == t1:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
c = 10000
t += '!' * c
if s == t[:-c]:
	print('YES')
	exit(0)
if '*' not in s:
	print('NO')
	exit(0)
if len(s) - 1 > len(t) - c:
	print('NO')
	exit(0)
pref = ''
suf = ''
f = 0
for i in s:
	if i == '*':
		f = 1
	elif f == 0:
		pref += i
	else:
		suf += i
if t[:len(pref)] == pref and t[-len(suf) - c:-c] == suf:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
s = input()
t = input()
if not '*' in s:
	if n == m and s == t:
		print('YES')
	else:
		print('NO')
	exit()
if n > m + 1:
	print('NO')
	exit()
i = 0
while i < n and i < m and (s[i] != '*'):
	if s[i] != t[i]:
		print('NO')
		exit()
	i += 1
i = 1
while i <= n and i <= m and (s[len(s) - i] != '*'):
	if s[len(s) - i] != t[len(t) - i]:
		print('NO')
		exit()
	i += 1
print('YES')


(n, m) = map(int, input().split())
s = list(str(input()))
t = list(str(input()))
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
elif n == 1:
	print('YES')
elif n > m:
	s.remove('*')
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	indexOfAst = s.index('*')
	var1 = len(s[indexOfAst + 1:])
	if t[:indexOfAst] == s[:indexOfAst]:
		if s[indexOfAst + 1:] == t[-var1:]:
			print('YES')
		elif indexOfAst == len(s) - 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = 1
for test in range(1, t + 1):
	(n, m) = map(int, input().split())
	s = input()
	t = input()
	if n - m > 1:
		print('NO')
		continue
	tmp = s.find('*')
	if tmp == -1:
		if s == t:
			print('YES')
		else:
			print('NO')
	elif s[:tmp] == t[:tmp] and s[tmp + 1:] == t[m - (n - tmp - 1):]:
		print('YES')
	else:
		print('NO')


[n, m] = [int(x) for x in input().split()]
s = input()
t = input()
ind = s.find('*')
if ind == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif m < n - 1:
	print('NO')
elif s[:ind] == t[:ind] and s[ind + 1:] == t[m - (n - ind - 1):]:
	print('YES')
else:
	print('NO')


(n, m) = (int(x) for x in input().split())
a = input()
b = input()
if '*' not in a:
	if a == b:
		print('YES')
	else:
		print('NO')
	quit()
(l, r) = a.split('*')
if len(b) >= len(a) - 1:
	if l == b[:len(l)] and r == b[len(b) - len(r):]:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
a = input()
b = input()
c = 1
if n != m and a.count('*') == 0:
	c = 0
if a.count('*') != 0 and n > m + 1:
	c = 0
for i in range(len(a)):
	if c == 0:
		continue
	if a[i] == '*':
		break
	if a[i] != b[i]:
		c = 0
ind = 1
for i in range(len(b) - 1, -1, -1):
	if c == 0:
		continue
	if a[len(a) - ind] == '*':
		break
	if a[len(a) - ind] != b[i]:
		c = 0
	ind += 1
if c == 1 and len(a) <= len(b) + 1:
	print('YES')
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
(s, t) = (line.strip() for line in sys.stdin)
p = s.find('*')
if p == -1:
	print(('NO', 'YES')[s == t])
elif len(s) - 1 > len(t):
	print('NO')
else:
	print(('NO', 'YES')[t.startswith(s[:p]) and t.endswith(s[p + 1:])])


(n, m) = map(int, input().split())
s = input()
t = input()
if len(s) - 1 > m:
	print('NO')
elif s == '*':
	print('YES')
elif '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	for i in range(len(s)):
		if s[i] == '*':
			pos = i
			break
	if s[0:pos] == t[0:pos] and s[pos + 1:] == t[m - (n - pos) + 1:]:
		print('YES')
	else:
		print('NO')


s = input()
s = input()
if s == '*':
	print('YES')
elif s.find('*') == -1:
	ss = input()
	if s == ss:
		print('YES')
	else:
		print('NO')
else:
	s = s.split('*')
	l = s[0]
	r = s[1]
	s = input()
	if l == '':
		if s[-len(r):] == r:
			print('YES')
		else:
			print('NO')
	elif r == '':
		if s[:len(l)] == l:
			print('YES')
		else:
			print('NO')
	elif len(l) + len(r) > len(s):
		print('NO')
	elif s[:len(l)] == l and s[-len(r):] == r:
		print('YES')
	else:
		print('NO')


import sys
from collections import deque
import bisect
for _ in range(1):
	(n, m) = map(int, input().split())
	s = input()
	t = input()
	if s == t:
		print('YES')
		continue
	if s.count('*') == 1:
		e = list(s.split('*'))
		flag = 1
		visited = set()
		for i in range(len(e[0])):
			x = e[0][i]
			if i >= m:
				flag = 0
				break
			y = t[i]
			visited.add(i)
			if x != y:
				flag = 0
				break
		i = m - 1
		j = len(e[1]) - 1
		while j > -1:
			if i in visited:
				flag = 0
				break
			x = e[1][j]
			if i < 0:
				flag = 0
				break
			if x != t[i]:
				flag = 0
				break
			j -= 1
			i -= 1
		if flag:
			print('YES')
			continue
	print('NO')


def solve(s, t):
	ss = s.split('*')
	if len(ss) == 1:
		return ss[0] == t
	else:
		return t.startswith(ss[0]) and t.endswith(ss[1]) and (len(t) >= len(s) - 1)
input()
s = input()
t = input()
if solve(s, t):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
k = -1
ans = 'YES'
for i in range(min(n, m)):
	if s[i] == '*':
		k = i
		break
	if s[i] != t[i]:
		ans = 'NO'
		break
if k == -1:
	if n == m + 1 and s[n - 1] == '*':
		pass
	elif n != m:
		ans = 'NO'
elif k != -1:
	for i in range(n - k - 1):
		if s[n - i - 1] != t[m - i - 1]:
			ans = 'NO'
			break
		if m - i - 1 < k:
			ans = 'NO'
			break
print(ans)


(n, m) = map(int, input().split())
x = input()
y = input()
if x.count('*') == 1 and len(x) <= len(y) + 1:
	z = x.index('*')
	if ''.join(x[:z]) == ''.join(y[:z]) and ''.join(x[z + 1:]) == ''.join(y[len(y) - len(x[z + 1:]):]):
		print('YES')
	else:
		print('NO')
elif x.count('*') == 0:
	if x == y:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
from sys import exit
if '*' in s:
	if n - m > 1:
		print('NO')
		exit()
elif n - m != 0:
	print('NO')
	exit()
for i in range(min(n, m)):
	if s[i] != t[i]:
		if s[i] != '*':
			print('NO')
			exit()
		break
(e, r) = (n - 1, m - 1)
for i in range(min(n, m)):
	if s[e] != t[r]:
		if s[e] != '*':
			print('NO')
			exit()
		break
	(e, r) = (e - 1, r - 1)
print('YES')


(n, m) = map(int, input().split())
s = input()
t = input()
if n > m + 1:
	print('NO')
elif s == t:
	print('YES')
elif '*' not in s:
	print('NO')
else:
	(front, back) = s.split('*')
	match = 1
	for i in range(len(front)):
		if front[i] != t[i]:
			match = 0
			break
	if match == 0:
		print('NO')
	else:
		for j in range(len(back)):
			if back[len(back) - 1 - j] != t[len(t) - 1 - j]:
				match = 0
				break
		if match == 0:
			print('NO')
		else:
			print('YES')


_ = input()
s = input()
s1 = input()
if '*' in s:
	s = s.split('*')
	s[1] = s[1][::-1]
	s2 = s1[::-1]
	if len(s[0]) + len(s[1]) > len(s1):
		print('NO')
	elif s1[:len(s[0])] == s[0] and s2[:len(s[1])] == s[1]:
		print('YES')
	else:
		print('NO')
elif s == s1:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	(a, b) = s.split('*')
	if t[0:len(a)] == a and t[len(t) - len(b):len(t)] == b and (len(t) >= len(s) - 1):
		print('YES')
	else:
		print('NO')


from enum import *
from copy import *
from sys import *
from collections import *
from itertools import *
from functools import *
from math import *

def l2i(fr=None):
	return map_type_to_fr(int, fr)[0]

def i2i(fr=None):
	return l2i(fr)

def dbg(*args):
	print(*args, file=stderr)

def dbv(var_name):
	print(f'{var_name} = {eval(var_name)}', file=stderr)

def map_type_to_fr(t, fr):
	global GETLINE_OFFSET
	if fr is None:
		if RUNNING_ON_MY_PC:
			fr = TEST_INP[GETLINE_OFFSET].split()
			GETLINE_OFFSET += 1
		else:
			fr = input().split()
	return list(map(t, fr))

def mis(fr=None):
	return map_type_to_fr(int, fr)

def mbs(fr=None):
	return map_type_to_fr(bool, fr)

def gs(fr=None):
	return map_type_to_fr(str, fr)[0]
import os
import sysconfig
RUNNING_ON_MY_PC = os.name == 'nt' and platform == 'win32' and (sysconfig.get_platform() == 'win-amd64')
GETLINE_OFFSET = 0
TEST_INP = '9 6\ngfgf*gfgf\ngfgfgf\n\n'.split('\n')
(n, m) = mis()
s = gs()
t = gs()
idx = s.find('*')
if idx == -1:
	print('YES' if s == t else 'NO')
else:
	if s[:idx] != t[:idx]:
		print('NO')
		exit()
	t_from = m - (n - idx - 1)
	if t_from < idx:
		print('NO')
		exit()
	if s[idx + 1:] != t[t_from:]:
		print('NO')
	else:
		print('YES')


(n, m) = map(int, input().split())
s = input()
t = input()
k = 0
j = 0
if s.count('*') == 0:
	if t == s:
		print('YES')
	else:
		print('NO')
else:
	k = s.find('*')
	l = s[k + 1:]
	q = t[k:]
	if t[:k] == s[:k] and q[::-1].find(l[::-1]) == 0:
		print('YES')
	else:
		print('NO')


input()
s = input()
t = input()
if '*' in s:
	(s1, s2) = s.split('*')
	if (t[:len(s1)] == s1 or s1 == '') and (t[-len(s2):] == s2 or s2 == '') and (len(t) >= len(s1) + len(s2)):
		print('YES')
	else:
		print('NO')
elif t == s:
	print('YES')
else:
	print('NO')


(x, y) = input().split()
(n, m) = (int(x), int(y))
s = input()
t = input()
if '*' not in s and s != t:
	print('NO')
elif '*' not in s and s == t:
	print('YES')
elif len(s) > len(t) + 1:
	print('NO')
elif s == '*':
	print('YES')
else:
	ok = True
	i = 0
	while s[i] != '*':
		if s[i] != t[i]:
			print('NO')
			ok = False
			break
		i += 1
	(j, k) = (len(t) - 1, len(s) - 1)
	while s[k] != '*' and ok:
		if s[k] != t[j]:
			ok = False
			print('NO')
			break
		k -= 1
		j -= 1
	if ok:
		print('YES')


from sys import stdin, stdout, setrecursionlimit
from gc import disable
gets = input
puts = print
input = stdin.readline
print = stdout.write

def main() -> int:
	disable()
	(n, m) = map(int, input().split())
	s = gets()
	t = gets()
	if n - 1 > m:
		print('NO')
		return 0
	dot = s.find('*')
	if dot == -1:
		print('YES' if s == t else 'NO')
		return 0
	if s[:dot] + t[dot:m - (n - dot - 1)] + s[dot + 1:] == t:
		print('YES')
	else:
		print('NO')
	return 0
main()


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' not in s:
	res = s == t
else:
	(a, b) = s.split('*')
	res = len(a) + len(b) <= len(t)
	res &= not a or a == t[:len(a)]
	res &= not b or t[-len(b):] == b
print('YES' if res else 'NO')


(n, m) = list(map(int, input().split()))

def reverse(s):
	b = []
	b.extend(s)
	b.reverse()
	return b
if m < n - 1:
	print('NO')
else:
	a = input()
	if '*' in a:
		(st, nd) = a.split('*')
		rd = input()
		len_2 = len(nd)
		len_1 = len(st)
		if rd[:len_1] == st and reverse(rd)[:len_2] == reverse(nd):
			print('YES')
		else:
			print('NO')
	else:
		st = a
		rd = input()
		if st == rd:
			print('YES')
		else:
			print('NO')


(n, m) = map(int, input().split())
s = str(input())
t = str(input())
if s.count('*') == 0 and s != t:
	print('NO')
elif s.count('*') == 0 and s == t:
	print('YES')
elif s.count('*') != 0:
	k = int(s.find('*'))
	s1 = s[::-1]
	t1 = t[::-1]
	if s[0:k] == t[0:k] and s1[0:n - k - 1] == t1[0:n - k - 1] and (m - n >= -1):
		print('YES')
	else:
		print('NO')


input()
s = input()
t = input()
l = s.split('*')
n = len(s)
m = len(t)
if len(l) == 1:
	if l[0] != t:
		print('NO')
		exit()
	else:
		print('YES')
		exit()
if m < n - 1:
	print('NO')
	exit()
if t.startswith(l[0]) is False:
	print('NO')
	exit()
k = len(t) - len(l[0])
t = t[-k:]
if t.endswith(l[1]):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	return
s1 = s[:s.find('*')]
s2 = s[s.find('*') + 1:]
if t[:len(s1)] == s1 and t[len(t) - len(s2):] == s2 and (len(s1) + len(s2) <= len(t)):
	print('YES')
else:
	print('NO')


import sys
input()
A = str(input())
B = str(input())
if '*' not in A:
	if A == B:
		print('YES')
	else:
		print('NO')
	sys.exit(0)
(p1, p2) = A.split('*')
if (B[0:len(p1)] == p1 or len(p1) == 0) and (B[len(p1):][-len(p2):] == p2 or len(p2) == 0):
	print('YES')
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
mask = input()
file = input()
if '*' not in mask:
	if mask == file:
		print('YES')
	else:
		print('NO')
	sys.exit()
inx = mask.index('*')
s1 = mask[:inx]
s2 = mask[inx + 1:]
if s1 in file and s2 in file:
	ix1 = file.index(s1)
	ix2 = file.rindex(s2)
	if ix1 == 0 and ix2 == m - len(s2) and (ix1 + len(s1) - 1 < ix2):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	(front, back) = s.split('*')
	if len(t) >= len(s) - 1 and t.startswith(front) and t.endswith(back):
		print('YES')
	else:
		print('NO')
else:
	print('YES' if s == t else 'NO')


inpt = [int(i) for i in input().split()]
word_1 = '123' + input() + '123'
word_2 = '123' + input() + '123'
if len(word_1) - len(word_2) > 1:
	print('NO')
else:
	word_1 = word_1.split('*')
	has = True
	for word in word_1:
		if word_2.find(word) == -1:
			has = False
	if has:
		print('YES')
	else:
		print('NO')


def main():
	input()
	regex = input()
	str = input()
	if '*' not in regex:
		if str == regex:
			print('YES')
		else:
			print('NO')
		exit(0)
	(a, b) = regex.split('*')
	if len(a + b) <= len(str) and str.startswith(a) and str.endswith(b):
		print('YES')
	else:
		print('NO')
main()


import sys
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math

def solve():
	(N, M) = getInts()
	S = listStr()
	T = listStr()
	if '*' not in S:
		return 'YES' if S == T else 'NO'
	if len(T) < len(S) - 1:
		return 'NO'
	w = S.index('*')
	if w == 0:
		return 'YES' if S[1:] == T[M - (N - 1):] else 'NO'
	if w == N - 1:
		return 'YES' if S[:-1] == T[:N - 1] else 'NO'
	S1 = S[:w]
	S2 = S[w + 1:]
	T1 = T[:len(S1)]
	T2 = T[-len(S2):]
	return 'YES' if S1 == T1 and S2 == T2 else 'NO'
print(solve())


(n, m) = map(int, input().split())
s = input()
t = input()
k = -1
for i in range(n):
	if s[i] == '*':
		k = i
		break
if s[0:i] == t[0:i] and s[i + 1:n] == t[m - n + i + 1:m]:
	if k == -1 and s != t or n > m + 1:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


while True:
	eminems = input().split()
	n = int(eminems[0])
	m = int(eminems[1])
	s = input()
	t = input()
	s = s.split('*')
	if len(s) == 1:
		if s[0] == t:
			print('YES')
		else:
			print('NO')
	elif (t[0:len(s[0])] == s[0] or len(s[0]) == 0) and (t[-len(s[1]):] == s[1] or len(s[1]) == 0) and (n <= m + 1):
		print('YES')
	else:
		print('NO')
	break


(n, m) = list(map(int, input().split(' ')))
s = str(input())
t = str(input())
if s == '*':
	print('YES')
elif s.replace('*', '') == t:
	print('YES')
elif s[0] == '*':
	s = s.replace('*', '')
	if t.rfind(s) == len(t) - len(s):
		print('YES')
	else:
		print('NO')
elif s[len(s) - 1] == '*':
	s = s.replace('*', '')
	if t.find(s) == 0:
		print('YES')
	else:
		print('NO')
elif '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	(s1, s2) = s.split('*')
	if s1 in t:
		index1 = t.index(s1)
		if index1 == 0 and s2 in t[index1 + len(s1):]:
			index2 = t.index(s2, index1 + len(s1))
			if index2 > index1 and index2 + len(s2) == len(t):
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
s1 = s[::-1]
d = -1
if n > m + 1:
	print('NO')
else:
	for i in range(0, n):
		if s[i] == '*':
			d = i
	if d != -1:
		if s[0:d] == t[0:d] and s[d + 1:n] == t[m - n + d + 1:m]:
			print('YES')
		else:
			print('NO')
	elif s == t:
		print('YES')
	else:
		print('NO')


h = input().split(' ')
n = int(h[0])
m = int(h[1])
s = input()
t = input()
if n > m + 1:
	print('NO')
	exit()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit()
arr = s.split('*')
lt = len(t)
if arr[0] == t[:len(arr[0])] and arr[1] == t[lt - len(arr[1]):lt]:
	print('YES')
else:
	print('NO')


def SWPM():
	n_m = input()
	x1 = n_m.find(' ')
	n = int(n_m[:x1])
	m = int(n_m[x1 + 1:])
	s = input()
	t = input()
	q = s.find('*')
	p = q + 1
	o = p + m - n
	if q == -1 and s == t:
		print('YES')
	elif q != -1 and n - m <= 1 and (s[:q] == t[:q]) and (s[p:] == t[o:]):
		print('YES')
	else:
		print('NO')
SWPM()


import re
(n, m) = input().split(' ')
s = input()
t = input()
l = s.split('*')
regex_start = '^' + l[0]
if len(l) > 1:
	regex_end = '' + l[1] + '$'
if len(l) == 1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif len(l[0]) + len(l[1]) > len(t):
	print('NO')
elif re.search(regex_start, t) and re.search(regex_end, t):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if '*' in s:
	x = s.index('*')
	if t[:x] == s[:x] and t[x:].endswith(s[x + 1:]):
		print('YES')
	else:
		print('NO')
else:
	print('YES' if s == t else 'NO')


(N, M) = map(int, input().split())
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
elif len(s) - 1 > len(t):
	print('NO')
else:
	s = s.split('*')
	try:
		if s[0] == t[:len(s[0])] and s[1] == t[len(t) - len(s[1]):]:
			print('YES')
		else:
			print('NO')
	except:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if n - 1 > m:
	print('NO')
else:
	try:
		a = s.index('*')
	except:
		a = -1
	if a == -1:
		if s == t:
			print('YES')
		else:
			print('NO')
	else:
		f = True
		for i in range(a):
			if s[i] != t[i]:
				print('NO')
				exit()
		i = 1
		while m - i >= a and n - i > a:
			if s[n - i] != t[m - i]:
				print('NO')
				exit()
			i += 1
		print('YES')


(a, b) = [*open(0)][1:]
if '*' in a:
	(x, y) = a.split('*')
	r = b.startswith(x) and b[len(x):].endswith(y)
else:
	r = a == b
print('NYOE S'[r::2])


import sys

def input():
	return sys.stdin.readline()[:-1]
from collections import deque
(n, m) = [int(x) for x in input().split()]
s = deque([x for x in input()])
t = deque([x for x in input()])
while s and t and (s[0] == t[0]):
	s.popleft()
	t.popleft()
while s and t and (s[-1] == t[-1]):
	s.pop()
	t.pop()
if not s and (not t) or (len(s) == 1 and s[0] == '*'):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
if s.count('*') == 1:
	if t.startswith(s[:s.index('*')]) & t[len(s[:s.index('*')]):].endswith(s[s.index('*') + 1:]):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
tmp = s.find('*')
len_ = len(s) - tmp - 1
if len_ == 0:
	if s[:tmp] == t[:tmp]:
		print('YES')
	else:
		print('NO')
	exit()
if tmp != -1:
	if len(s) - 1 > len(t):
		print('NO')
		exit()
	if t[:tmp] == s[:tmp] and t[-len_:] == s[-len_:]:
		print('YES')
		exit()
elif s == t:
	print('YES')
	exit()
print('NO')


(n, m) = input().strip().split(' ')
(n, m) = (int(n), int(m))
s = input().strip()
t = input().strip()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	(x, y) = s.split('*')
	if t.startswith(x) and t.endswith(y) and (len(x) + len(y) <= len(t)):
		print('YES')
	else:
		print('NO')


(n, m) = [int(j) for j in input().split()]
s = input()
t = input()
if '*' in s:
	star = s.find('*')
	if n <= m + 1 and s[:star] == t[:star] and (s[star + 1:] == t[m - (n - 1 - star):]):
		print('YES')
	else:
		print('NO')
elif s == t:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
(n, m) = (int(n), int(m))
s = input()
t = input()
quit = False
if not len(s) - 1 <= len(t):
	print('NO')
	quit = True
if '*' not in s and len(s) != len(t):
	print('NO')
	quit = True
if not quit:
	index = 0
	for i in s:
		if i == '*':
			break
		index += 1
	s1 = s[:index]
	s2 = s[index + 1:]
	if s1 == t[:len(s1)]:
		if s2 == t[len(t) - len(s2):]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
orgt = t
if n == 2 and '*' in s:
	print('YES' if s.replace('*', t[:m - 1]) == t or s.replace('*', t[1:]) == t else 'NO')
	exit(0)
if '*' not in s or n - m >= 1:
	if s == t:
		print('YES')
	elif n - m == 1:
		if s.replace('*', '') == t:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
else:
	for i in range(n - 1):
		if s[i + 1] == '*':
			t = t.replace(s[:i + 1], '', 1)
			break
	for i in range(n - 1, -1, -1):
		if s[i - 1] == '*':
			t = t.replace(s[i:], '', 1)
			break
	if s.replace('*', t) == orgt:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
q = t[::-1]
if n > m + 1:
	print('NO')
	exit(0)
if not '*' in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	k = s.index('*')
	l = n - k - 1
	if s[:k] == t[:k] and s[k + 1:][::-1] == q[:l]:
		print('YES')
	else:
		print('NO')


temp = input()
s = input()
t = input()
flag = 0
if '*' in s:
	ans = []
	for x in s.split('*'):
		ans.append(x)
	if ans[0] == '' and ans[1] == '':
		flag = 1
	elif ans[0] == '':
		if ans[1] == t[-len(ans[1]):]:
			flag = 1
	elif ans[1] == '':
		if ans[0] == t[:len(ans[0])]:
			flag = 1
	elif ans[0] == t[:len(ans[0])] and ans[1] == t[-len(ans[1]):] and (len(s) - 1 <= len(t)):
		flag = 1
elif s == t:
	flag = 1
if flag:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
s = input()
t = input()
idx = 0
ans = 0
if m < n - 1:
	print('NO')
	exit(0)
if not '*' in s:
	if s == t:
		print('YES')
	else:
		print('NO')
	exit(0)
for x in range(n):
	if s[x] == '*':
		idx = x
		break
lol = m - (n - idx) + 1
if s[:idx] == t[:idx] and s[idx + 1:] == t[lol:]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
a = s.find('*')
s = s.replace('*', t[a:a + m - n + 1])
if s == t:
	print('YES')
else:
	print('NO')


_ = input()
s = str(input())
t = str(input())
pos = s.find('*')
if s == t:
	print('YES')
elif s == '*':
	print('YES')
elif pos == -1:
	print('NO')
elif s[:pos] == t[:pos] and t.find(s[pos + 1:], pos) >= 0 and (s[pos + 1:] == t[-len(s[pos + 1:]):] or pos + 1 == len(s)):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split(' '))
s = input()
t = input()
a = []
b = []
for i in s:
	a.append(i)
for i in t:
	b.append(i)
s = a
t = b
if m < n or s.count('*') == 0:
	if s.count('*') != 0:
		s.remove('*')
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	i = 0
	j = n - 1
	while i < n and s[i] != '*':
		if s[i] != t[i]:
			print('NO')
			exit()
		i += 1
	i = n - 1
	j = m - 1
	while i >= 0 and s[i] != '*':
		if s[i] != t[j]:
			print('NO')
			exit()
		i -= 1
		j -= 1
	print('YES')


(a, b) = map(int, input().split())
s = input()
t = input()
num = -1
for i in range(a):
	if s[i] == '*':
		num = i
		break
if num == -1:
	if s == t:
		print('YES')
	else:
		print('NO')
elif a - b > 1:
	print('NO')
elif s[0:num] == t[0:num] and s[num + 1:a] == t[b - a + num + 1:b]:
	print('YES')
else:
	print('NO')


x = list(map(int, input().strip().split()))
s = input()
t = input()
if '*' not in s:
	if s == t:
		print('YES')
	else:
		print('NO')
else:
	(p, q) = s.split('*')
	x = len(p)
	y = len(q)
	if t[:x] == p and t[::-1][:y][::-1] == q and (len(t) >= len(s) - 1):
		print('YES')
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	(s, t) = (input().strip(), input().strip())
	if s.find('*') >= 0:
		ai = s.find('*')
		if t.find(s[:ai]) != 0:
			print('NO')
			return
		if ai == n - 1:
			print('YES')
		else:
			t2 = t[ai:]
			i2 = t2.rfind(s[ai + 1:])
			print('YES' if 0 <= i2 and t2[i2:] == s[ai + 1:] else 'NO')
	else:
		print('YES' if s == t else 'NO')
solve()


(n, m) = list(map(int, input().split()))
padrao = input()
string = input()
if n > m + 1:
	print('NO')
elif '*' in padrao:
	(front, end) = padrao.split('*')
	if len(end) != 0:
		aux = string[-len(end):]
	else:
		aux = ''
	if aux != end:
		print('NO')
	else:
		aux = string[:len(front)]
		if aux == front:
			aux = string[len(front):-len(end)]
			flag = True
			if len(aux) != 0 and aux.islower() == False:
				flag = False
			for i in range(len(aux)):
				if not aux[i].isalpha():
					flag = False
					break
			if flag:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
elif padrao == string:
	print('YES')
else:
	print('NO')


def solve():
	(n, m) = map(int, input().split())
	s = input()
	t = input()
	if s == t:
		return 'YES'
	star = s.find('*')
	s1 = s[:star]
	s2 = s[star + 1:]
	if s1 == t[:star]:
		if len(s2) == 0 or s2 == t[star:][-len(s2):]:
			return 'YES'
	return 'NO'
print(solve())


(n, m) = map(int, input().split())
x = input()
y = input()
a = []
b = []
c = 0
for i in range(len(x)):
	if x[i] != '*':
		a.append(x[i])
	else:
		c += 1
		break
for j in range(i + 1, n):
	b.append(x[j])
if c == 0:
	f = 1
	if n != m:
		f = 0
	else:
		for i in range(n):
			if x[i] != y[i]:
				f = 0
				break
	if f == 0:
		print('NO')
	else:
		print('YES')
elif len(x) - 1 > len(y):
	print('NO')
else:
	i = x.index('*')
	a = x[0:i]
	b = y[0:i]
	c = x[i + 1:]
	d = y[len(y) - (len(x) - i - 1):]
	if a == b and c == d:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
s = input()
t = input()
b = False
for e in s:
	if e == '*':
		b = True
		break
if b == False and s != t or len(s) - 1 > len(t):
	print('NO')
elif b == False and s == t:
	print('YES')
else:
	i = 0
	while s[i] != '*':
		if s[i] != t[i]:
			print('NO')
			break
		i += 1
	else:
		i = -1
		while s[i] != '*':
			if s[i] != t[i]:
				print('NO')
				break
			i -= 1
		else:
			print('YES')


(n, m) = map(int, input().split())
(s, t) = (input(), input())
if s.count('*') == 0:
	if s == t:
		exit(print('YES'))
	else:
		exit(print('NO'))
(a, b) = s.split('*')
l1 = len(a)
l2 = len(b)
if a == t[:l1]:
	if m + 1 >= n:
		if b == t[m - l2:m]:
			exit(print('YES'))
		else:
			exit(print('NO'))
	else:
		exit(print('NO'))
else:
	exit(print('NO'))