100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet.

The following game was chosen for the fights: initially there is a polynomial P(x) = a_{n}x^{n} + a_{n} - 1x^{n} - 1 + ... + a_1x + a_0,  with yet undefined coefficients and the integer k. Players alternate their turns. At each turn, a player pick some index j, such that coefficient a_{j} that stay near x^{j} is not determined yet and sets it to any value (integer or real, positive or negative, 0 is also allowed). Computer moves first. The human will be declared the winner if and only if the resulting polynomial will be divisible by Q(x) = x - k.

Polynomial P(x) is said to be divisible by polynomial Q(x) if there exists a representation P(x) = B(x)Q(x), where B(x) is also some polynomial.

Some moves have been made already and now you wonder, is it true that human can guarantee the victory if he plays optimally?


-----Input-----

The first line of the input contains two integers n and k (1 ≤ n ≤ 100 000, |k| ≤ 10 000) — the size of the polynomial and the integer k.

The i-th of the following n + 1 lines contain character '?' if the coefficient near x^{i} - 1 is yet undefined or the integer value a_{i}, if the coefficient is already known ( - 10 000 ≤ a_{i} ≤ 10 000). Each of integers a_{i} (and even a_{n}) may be equal to 0.

Please note, that it's not guaranteed that you are given the position of the game where it's computer's turn to move.


-----Output-----

Print "Yes" (without quotes) if the human has winning strategy, or "No" (without quotes) otherwise.


-----Examples-----
Input
1 2
-1
?

Output
Yes

Input
2 100
-10000
0
1

Output
Yes
Input
4 5
?
1
?
1
?

Output
No


-----Note-----

In the first sample, computer set a_0 to  - 1 on the first move, so if human can set coefficient a_1 to 0.5 and win.

In the second sample, all coefficients are already set and the resulting polynomial is divisible by x - 100, so the human has won.

Difficulty: VERY_HARD
Tags: Mathematics

Starter code:

Solutions:
(n, k) = map(int, input().split())
a = []
for i in range(n + 1):
	a.extend(input().split())
if k == 0:
	if a[0] == '0':
		print('Yes')
	elif a[0] == '?' and (n - a.count('?')) % 2 == 0:
		print('Yes')
	else:
		print('No')
elif '?' in a:
	if n % 2 == 0:
		print('No')
	else:
		print('Yes')
else:
	a = list(map(int, a))[::-1]
	res = a[0]
	for i in range(1, n + 1):
		res = a[i] + res * k
		if res > 10 ** 11 or res < -10 ** 11:
			print('No')
			exit(0)
	if res == 0:
		print('Yes')
	else:
		print('No')


def solve():
	modx = 179426080107
	(n, m) = map(int, input().split())
	cnt = 0
	a = []
	for i in range(n + 1):
		s = input()
		if s == '?':
			cnt += 1
		a.append(s)
	if m == 0:
		if a[0] == '0':
			return 1
		if a[0] == '?' and (n + 1 - cnt) % 2 == 1:
			return 1
		return 0
	if cnt:
		if n % 2 == 1:
			return 1
		return 0
	for i in range(n + 1):
		a[i] = int(a[i])
	now = a[n]
	tmp = 1
	ans = 0
	for i in range(n + 1):
		ans = ans + tmp * a[i] % modx
		ans %= modx
		tmp = tmp * m % modx
	if ans == 0:
		return 1
	else:
		return 0
if solve() == 1:
	print('Yes')
else:
	print('No')


(n, k) = map(int, input().split())
a = []
check = 0
for _ in range(n + 1):
	new_a = input()
	if new_a == '?':
		check += 1
	else:
		new_a = int(new_a)
	a.append(new_a)
if check > 0:
	if k != 0:
		if (n + 1) % 2 == 0:
			print('Yes')
		else:
			print('No')
	elif (n + 1 - check) % 2 == 1 and a[0] == '?' or a[0] == 0:
		print('Yes')
	else:
		print('No')
else:
	module1 = 2 ** 58 - 203
	module2 = 2 ** 64 - 59
	result1 = result2 = result3 = 0
	for c in a[::-1]:
		result1 = (result1 * k + c) % module1
		result2 = (result2 * k + c) % module2
		result3 = (result3 * k + c) % (module1 + module2)
	if result1 == 0 and result2 == 0 and (result3 == 0):
		print('Yes')
	else:
		print('No')


import sys
import math

def calculate(A, k, x):
	res = 0
	if abs(k) >= 2:
		for a in reversed(A):
			res = k * res + a
			if abs(res) > x:
				return float('inf')
		return res
	else:
		for a in reversed(A):
			res = k * res + a
		return res

def solve():
	(n, k) = [int(x) for x in input().split()]
	A = ['?' if line == '?\n' else int(line) for line in sys.stdin]
	if k == 0:
		return A[0] == 0 or (A[0] == '?' and (n + 1 - A.count('?')) % 2 == 1)
	elif '?' in A:
		return n % 2 == 1
	else:
		return calculate(A, k, 10000) == 0
print('Yes' if solve() else 'No')


(n, k) = map(int, input().split())
a = [input() for _ in range(n + 1)]
c = len([_ for _ in a if _ == '?'])
print('Yes' if k == 0 and (a[0] == '0' or (a[0] == '?' and (n + 1 - c) % 2 == 1)) or (k != 0 and (c > 0 and n % 2 == 1 or (c == 0 and sum([_ * pow(k, i, 10 ** 15 + 91) for (i, _) in enumerate(map(int, a))]) % (10 ** 15 + 91) == 0))) else 'No')


(n, k) = map(int, input().split(' '))
mas = [-100000000000000] * (n + 1)
d = 0
limit = 10 ** 10
for i in range(n + 1):
	s = input()
	if s == '?':
		d += 1
	else:
		mas[i] = int(s)
if k == 0 and mas[0] == 0:
	print('Yes')
elif k == 0 and mas[0] != 0:
	if mas[0] == -100000000000000:
		if (n - d) % 2 != 0:
			print('No')
		else:
			print('Yes')
	else:
		print('No')
elif d != 0:
	if n % 2 == 0:
		print('No')
	else:
		print('Yes')
else:
	b = mas[n]
	for i in range(n - 1, 0, -1):
		b = mas[i] + b * k
		if abs(b) > limit:
			print('No')
			break
	else:
		print('Yes') if b * k == -mas[0] else print('No')


(n, k) = [int(x) for x in input().split()]
L = []
done = 0
for i in range(n + 1):
	c = input()
	if c is '?':
		L.append('?')
	else:
		L.append(int(c))
		done += 1
left = n + 1 - done
if done % 2 == 0:
	chance = 0
else:
	chance = 1
if k == 0:
	if L[0] is '?':
		print('Yes' if chance == 1 else 'No')
	else:
		print('Yes' if L[0] == 0 else 'No')
elif left == 0:
	for i in range(n, 0, -1):
		L[i - 1] += L[i] * k
		if not -10000000000 < L[i - 1] < 10000000000:
			L[0] = -1
			break
	print('Yes' if L[0] == 0 else 'No')
elif left % 2 == 0:
	if chance == 0:
		print('Yes')
	else:
		print('No')
elif chance == 1:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
coeff = [str(input().strip()) for _ in range(n + 1)]
if coeff.count('?') == 0:
	total = 0
	for s in range(n + 1)[::-1]:
		total = total * k + int(coeff[s])
		if abs(total) > 1000000000000:
			break
	if total == 0:
		print('Yes')
	else:
		print('No')
elif k == 0:
	if coeff[0] == '?':
		if (n + 1 - coeff.count('?')) % 2 == 1:
			print('Yes')
		else:
			print('No')
	elif coeff[0] == '0':
		print('Yes')
	else:
		print('No')
elif (n + 1) % 2 == 0:
	print('Yes')
else:
	print('No')


(n, k) = map(int, input().split())
s = 0
a = 0
l = []
f = False
for i in range(n + 1):
	v = input()
	if v == '?':
		a += 1
		if k == 0 and i == 0:
			f = True
	elif a == 0:
		l.append(int(v))
l.reverse()
if a == 0 and k != 0:
	for i in l:
		s = k * s + i
		if s > 10 ** 18 or s < -10 ** 18:
			break
if k == 0 and (not f and l[-1] == 0 or (f and (n - a) % 2 == 0)):
	print('Yes')
elif k == 0:
	print('No')
elif a == 0 and s == 0 or (n % 2 == 1 and a > 0):
	print('Yes')
else:
	print('No')


def main():
	(n, k) = list(map(int, input().split()))
	aa = []
	for i in range(n + 1):
		s = input()
		aa.append(None if s == '?' else int(s))
	qm_cnt = aa.count(None)
	if k:
		if qm_cnt:
			print('Yes' if n & 1 else 'No')
		else:
			x = 0
			for a in reversed(aa):
				x = (x * k + a) % 999999937
			print('No' if x else 'Yes')
	else:
		print('Yes' if aa[0] is None and (not n - qm_cnt & 1) or aa[0] == 0 else 'No')

def __starting_point():
	main()
__starting_point()


p = 1048583
q = 1048589
modd = p * q * p * q
(n, k) = tuple(map(int, input().split()))
a = [0]
wenhao = 0
gai = 0
for i in range(n + 1):
	m = input()
	if m[0] == '?':
		a.append('?')
		wenhao += 1
	else:
		a.append(int(m))
		gai += 1
if k == 0:
	if a[1] == '?' and gai & 1 == 1 or a[1] == 0:
		print('Yes')
	else:
		print('No')
elif wenhao != 0:
	if n & 1 == 1:
		print('Yes')
	else:
		print('No')
else:
	m = a[n + 1]
	nn = a[n]
	for i in range(n, 0, -1):
		(m, nn) = ((nn + k * m) % modd, a[i - 1])
	if m == 0:
		print('Yes')
	else:
		print('No')


(n, k) = map(int, input().split())
a = [input() for i in range(n + 1)]
z = 0
for i in a:
	if i == '?':
		z += 1
if k == 0:
	if a[0] == '0':
		print('Yes')
	elif a[0] == '?' and (n - z + 1) % 2 == 1:
		print('Yes')
	else:
		print('No')
elif z == 0:
	d = 0
	for i in a[::-1]:
		d = (d * k + int(i)) % 7272763523821
	if d == 0:
		print('Yes')
	else:
		print('No')
elif n % 2 == 0:
	print('No')
else:
	print('Yes')