$n$ distinct integers $x_1,x_2,\ldots,x_n$ are written on the board. Nezzar can perform the following operation multiple times.

Select two integers $x,y$ (not necessarily distinct) on the board, and write down $2x-y$. Note that you don't remove selected numbers.

Now, Nezzar wonders if it is possible to have his favorite number $k$ on the board after applying above operation multiple times.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^5$) — the number of test cases.

The first line of each test case contains two integers $n,k$ ($2 \le n \le 2 \cdot 10^5$, $-10^{18} \le k \le 10^{18}$).

The second line of each test case contains $n$ distinct integers $x_1,x_2,\ldots,x_n$ ($-10^{18} \le x_i \le 10^{18}$).

It is guaranteed that the sum of $n$ for all test cases does not exceed $2 \cdot 10^5$.


-----Output-----

For each test case, print "YES" on a single line if it is possible to have $k$ on the board. Otherwise, print "NO".

You can print each letter in any case (upper or lower).


-----Examples-----

Input
6
2 1
1 2
3 0
2 3 7
2 -1
31415926 27182818
2 1000000000000000000
1 1000000000000000000
2 -1000000000000000000
-1000000000000000000 123
6 80
-5 -20 13 -14 -2 -11
Output
YES
YES
NO
YES
YES
NO


-----Note-----

In the first test case, the number $1$ is already on the board.

In the second test case, Nezzar could perform the following operations to write down $k=0$ on the board:

Select $x=3$ and $y=2$ and write down $4$ on the board.

Select $x=4$ and $y=7$ and write down $1$ on the board.

Select $x=1$ and $y=2$ and write down $0$ on the board.

In the third test case, it is impossible to have the number $k = -1$ on the board.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Number theory

Mathematics

Constructive algorithms


Solutions:
import math

def gcd(a, b):
	return math.gcd(a, b)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	g = 0
	l.sort()
	for i in range(1, n):
		g = gcd(g, l[i] - l[0])
	if (k - l[0]) % g == 0:
		print('YES')
	else:
		print('NO')


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

def main():
	t = int(input())
	allAns = []
	for _ in range(t):
		(n, k) = readIntArr()
		a = readIntArr()
		cumugcd = 0
		for i in range(1, n):
			cumugcd = gcd(cumugcd, abs(a[i] - a[0]))
		if abs(k - a[0]) % cumugcd == 0:
			ans = 'YES'
		else:
			ans = 'NO'
		allAns.append(ans)
	multiLineArrayPrint(allAns)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


import sys
from math import gcd
input = sys.stdin.readline
for nt in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	g = 0
	for x in a:
		g = gcd(x - a[0], g)
	if (k - a[0]) % g == 0:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def answer():
	g = 0
	for i in range(n - 1):
		g = gcd(g, abs(a[i] - a[i + 1]))
	for i in a:
		if (k - i) % g == 0:
			return 'YES'
	return 'NO'
for T in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print(answer())


import math

def find_gcd(x, y):
	d = math.gcd(abs(x), abs(y))
	if x * y < 0:
		return -1 * d
	else:
		return d
for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort()
	gcd = 0
	for i in range(len(l)):
		gcd = find_gcd(gcd, l[i] - l[0])
	if (y - l[0]) % gcd == 0:
		print('YES')
	else:
		print('NO')


def hcf(a, b):
	if b == 0:
		return a
	else:
		return hcf(b, a % b)
for i in range(int(input().strip())):
	(n, k) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	m = l[0]
	o = 0
	y = True
	for j in range(1, n):
		s = l[j] - l[j - 1]
		o = hcf(o, s)
		if (k - m) % o == 0:
			y = False
			break
	if y:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
from math import gcd

def main():
	(n, k) = map(int, input().split())
	xlst = list(map(int, input().split()))
	g = 0
	x0 = xlst[0]
	for x in xlst:
		g = gcd(g, x - x0)
	if (k - x0) % g == 0:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	main()


import sys
from math import gcd
input = sys.stdin.readline
out = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	kk = k - l[0]
	g = 0
	for v in l:
		g = gcd(g, v - l[0])
	if kk == 0 and g == 0 or (g != 0 and kk % g == 0):
		out.append('YES')
	else:
		out.append('NO')
print('\n'.join(out))


import sys
from math import gcd
t = int(input())
for _ in range(t):
	v = []
	(n, k) = map(int, input().split())
	v = list(map(int, input().split()))
	v.sort()
	g = 0
	F = False
	for i in range(1, n):
		g = gcd(g, v[i] - v[0])
	if (k - v[0]) % g == 0:
		print('YES')
	else:
		print('NO')


import io
import os
from math import gcd
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	x = sorted(x)
	diffs = [abs(a - b) for (a, b) in zip(x, x[1:])]
	g = diffs[0]
	for v in diffs[1:]:
		g = gcd(g, v)
	for v in x:
		if abs(v - k) % g == 0:
			print('YES')
			break
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

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 SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	g = 0
	for i in range(1, len(a)):
		g = math.gcd(g, a[i] - a[0])
	if (k - a[0]) % g == 0:
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	xlist = list(map(int, input().split()))
	lm = 0
	for i in xlist:
		lm = gcd(lm, i - xlist[0])
	flag = False
	for x in xlist:
		if abs(x - k) % lm == 0:
			print('YES')
			flag = True
			break
	if not flag:
		print('NO')


from math import gcd
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	even = 0
	odd = 0
	g = a[1] - a[0]
	for j in range(1, n):
		g = gcd(g, a[j] - a[j - 1])
	print('YES') if (k - a[0]) % g == 0 else print('NO')


import math, sys
from functools import reduce
input = sys.stdin.readline
for _ in range(int(input())):
	(_, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print('NO' if (k - a[0]) % reduce(math.gcd, [v - a[0] for v in a[1:]]) else 'YES')


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(sys.stdin.readline())

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, k) = In()
		l = list(In())
		l.sort()
		su = 0
		for i in range(1, n):
			su = math.gcd(su, l[i] - l[0])
		if (k - l[0]) % su == 0:
			yes()
		else:
			no()
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


def gcd(a, b):
	if a > b:
		return gcd(b, a)
	elif a <= 0:
		return b
	elif a == b:
		return b
	return gcd(b % a, a)
T = int(input())
for t in range(T):
	(n, k) = tuple([int(x) for x in input().split()])
	xx = [int(x) for x in input().split()]
	xx = sorted(xx)
	cur_gcd = xx[1] - xx[0]
	for i in range(2, len(xx)):
		cur_gcd = gcd(cur_gcd, xx[i] - xx[0])
	if abs(k - xx[0]) % cur_gcd == 0:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	even = 0
	odd = 0
	a.sort()
	g = a[1] - a[0]
	for j in range(1, n):
		g = gcd(g, a[j] - a[j - 1])
	if (k - a[0]) % g == 0:
		print('YES')
	else:
		print('NO')


import sys, io, os, math
from math import ceil, log, gcd, sqrt
from itertools import permutations
import operator
mod = 1000000007
mod1 = 998244353

def intinp():
	return int(sys.stdin.readline())

def strinp():
	return sys.stdin.readline()

def arrinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def mulinp():
	return map(int, sys.stdin.readline().strip().split())

def flush():
	return stdout.flush()

def power_two(x):
	return 1 << x

def lcm(a, b):
	return a * b // gcd(a, b)

def solve():
	(n, k) = mulinp()
	t = arrinp()
	res = 0
	t.sort()
	for i in range(1, n):
		res = gcd(res, t[i] - t[0])
	if (k - t[0]) % res:
		print('NO')
		return
	print('YES')

def main():
	tc = intinp()
	while tc:
		solve()
		tc -= 1
main()


from sys import stdin, stdout
t = int(stdin.readline())

def gcd(a, b):
	if a > b:
		return gcd(b, a)
	if a == 0:
		return b
	return gcd(a, b % a)
for _ in range(t):
	L = [int(l) for l in stdin.readline().split(' ')]
	(n, k) = (L[0], L[1])
	A = sorted([int(l) for l in stdin.readline().split(' ')])
	if k < 0:
		A = [a - k for a in A]
		k = 0
	diffs = [a - A[0] for a in A[1:]]
	g = diffs[0]
	for d in diffs:
		g = gcd(g, d)
	if k in A or (k - A[0]) % g == 0:
		print('YES')
	else:
		print('NO')


from math import gcd
import os
import sys
from io import BytesIO, IOBase
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def func(n, k):
	global arr
	arr.sort()
	g = 0
	for i in range(1, n):
		g = gcd(g, arr[i] - arr[0])
	if (k - arr[0]) % g == 0:
		return 'YES'
	return 'NO'

def main():
	global arr
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		print(func(n, k))
	return
arr = []
main()


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def def_value():
	return 0

def def_inf():
	return inf
for _ in range(iinp()):
	(n, k) = mp()
	a = lmp()
	a.sort()
	gd = 0
	for i in range(1, n):
		gd = gcd(gd, a[i] - a[i - 1])
	if (k - a[0]) % gd == 0:
		print('YES')
	else:
		print('NO')


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(1, n):
		ans = math.gcd(ans, a[i] - a[i - 1])
	if (k - a[0]) % ans == 0:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [*map(int, input().split())]
	x = a[1] - a[0]
	for i in range(1, n):
		x = math.gcd(a[i] - a[0], x)
	k -= a[0]
	if k % x == 0:
		print('YES')
	else:
		print('NO')


import sys
r = sys.stdin.readline
t = int(r())
for _ in range(t):
	(n, k) = map(int, r().split())
	x = list(map(int, r().split()))
	m = min(x)
	g = 0
	for i in range(n):
		b = x[i] - m
		while b:
			(g, b) = (b, g % b)
	if (k - m) % g:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
getint = lambda : int(input())
getints = lambda : [int(a) for a in input().split()]

def calc_gcd(big, small):
	if small == 0:
		return big
	return calc_gcd(small, big % small)

def solve():
	(n, k) = getints()
	x = getints()
	a = min(x)
	gcd = x[0] - a
	if gcd == 0:
		gcd = x[1] - a
	for xvalue in x:
		if xvalue == a:
			continue
		comparer = (gcd, xvalue - a)
		gcd = calc_gcd(max(comparer), min(comparer))
	k -= a
	if k % gcd == 0:
		print('YES')
	else:
		print('NO')
t = getint()
for i in range(t):
	solve()


import sys

def gcd(a, b):
	while b > 0:
		r = a % b
		a = b
		b = r
	return a
t = int(input())
for test in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	ans = 0
	for el in a:
		ans = gcd(ans, abs(el - a[0]))
	k -= a[0]
	if k % ans == 0:
		print('YES')
	else:
		print('NO')


from math import gcd

def board(a, k):
	a = sorted(a)
	g = 0
	for i in a:
		g = gcd(i - a[0], g)
	if (k - a[0]) % g == 0:
		return 'YES'
	return 'NO'
for i in range(int(input())):
	(n, k) = map(int, input().strip().split())
	lst = list(map(int, input().strip().split()))
	print(board(lst, k))


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l2 = []
	for i in range(1, n):
		l2.append(abs(l[i] - l[i - 1]))
	gcd = l2[0]
	for i in range(1, n - 1):
		gcd = math.gcd(gcd, l2[i])
	t = 0
	if abs(l[i] - k) % gcd == 0:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	g = 0
	for i in range(n - 1):
		diff = arr[i + 1] - arr[i]
		g = gcd(g, diff)
	off = arr[0] % g
	if k % g == off:
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	if y != 0:
		return gcd(y, x % y)
	else:
		return x
for _ in range(int(input())):
	(n, goal) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	base = arr[0]
	g = arr[1] - arr[0]
	for i in range(2, len(arr)):
		g = gcd(g, arr[i] - arr[0])
	if (goal - base) % g == 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.buffer.readline
from math import gcd
ans = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	g = 0
	for i in range(1, n):
		g = gcd(g, x[i] - x[0])
	for i in range(n):
		if (x[i] - k) % g == 0:
			ans.append('YES')
			break
	else:
		ans.append('NO')
print(*ans, sep='\n')


import sys, io, os
from math import gcd
if os.environ['USERNAME'] == 'kissz':
	inp = open('in.txt', 'r').readline

	def debug(*args):
		print(*args, file=sys.stderr)
else:
	inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

	def debug(*args):
		pass
for _ in range(int(inp())):
	(n, k) = map(int, inp().split())
	A = [*map(int, inp().split())]
	A.sort()
	k -= A[0]
	A = [a - A[0] for a in A]
	g = 0
	for a in A[1:]:
		g = gcd(g, a)
	if k % g:
		print('NO')
	else:
		print('YES')


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a.sort()
	x = a[0]
	if k in a:
		print('YES')
		continue
	store = set()
	for i in range(1, n):
		store.add(a[i] - a[i - 1])
	ans = 0
	for i in store:
		ans = math.gcd(ans, i)
	if abs(k - a[0]) % ans == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	a = sorted(R())
	p = sorted([a[i] - a[i - 1] for i in range(1, n)])
	for i in p[1:]:
		p[0] = gcd(p[0], i)
	print('YES' if (k - a[0]) % p[0] == 0 else 'NO')


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	numeros = list(map(int, input().split()))
	g = 0
	for i in range(n - 1):
		g = gcd(g, numeros[i + 1] - numeros[0])
	if (k - numeros[0]) % g == 0:
		print('Yes')
	else:
		print('No')


import sys
readline = sys.stdin.readline

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
T = int(readline())
Ans = ['NO'] * T
for qu in range(T):
	(N, K) = map(int, readline().split())
	A = list(map(int, readline().split()))
	res = 0
	for a in A:
		res = gcd(res, a - A[0])
	if K % res == A[0] % res:
		Ans[qu] = 'YES'
print('\n'.join(Ans))


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = ['NO'] * T
from math import gcd
for t in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	g = 0
	for i in range(n - 1):
		g = gcd(g, A[i + 1] - A[i])
	if A[0] % g == k % g:
		ans[t] = 'YES'
print(*ans, sep='\n')


from math import gcd

def process():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	GCD = 0
	for i in range(1, n):
		GCD = gcd(GCD, a[i] - a[i - 1])
	for i in range(n):
		if (k - a[i]) % GCD == 0:
			print('YES')
			return
	print('NO')

def main():
	t = int(input())
	while t > 0:
		process()
		t -= 1
main()


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = 0
	for j in range(n - 1):
		b = gcd(b, a[j + 1] - a[0])
	if (k - a[0]) % b == 0:
		print('Yes')
	else:
		print('No')


import sys
from math import gcd
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort()
		g = 0
		for i in range(1, n):
			g = gcd(g, a[i] - a[i - 1])
		if (k - a[0]) % g == 0:
			print('YES')
		else:
			print('NO')
main()


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

def find(l):
	num1 = l[0]
	num2 = l[1]
	gcd = find_gcd(num1, num2)
	for i in range(2, len(l)):
		gcd = find_gcd(gcd, l[i])
	return gcd

def solve():
	diff = []
	if k in arr:
		return 'YES'
	for i in range(n - 1):
		diff.append(arr[i + 1] - arr[i])
	if len(diff) == 1:
		x = diff[0]
	else:
		x = find(diff)
	if abs(k - arr[0]) % x == 0:
		return 'YES'
	return 'NO'
t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	s = solve()
	print(s)


from sys import stdin
t = int(stdin.readline())

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)
for case in range(t):
	(n, k) = [int(x) for x in stdin.readline().split()]
	a = sorted([int(x) for x in stdin.readline().split()])
	diffs = [a[x] - a[x - 1] for x in range(1, n)]
	bruhcd = diffs[0]
	for x in diffs[1:]:
		bruhcd = gcd(bruhcd, x)
	if (k - a[0]) % bruhcd == 0:
		print('YES')
	else:
		print('NO')


import os, io, math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	r = min(a)
	k -= r
	for i in range(n):
		a[i] -= r
	p = a[0]
	for i in range(1, n):
		p = math.gcd(p, a[i])
	if k % p == 0:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string

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()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	A = getInts()
	A.sort()
	G = A[1] - A[0]
	for i in range(1, N - 1):
		G = math.gcd(G, A[i + 1] - A[i])
	if G == 1:
		return 'YES'
	for i in range(N):
		if (A[i] - K) % G == 0:
			return 'YES'
	return 'NO'
for _ in range(getInt()):
	print(solve())


def gcd(a1, b):
	while b != 0:
		(a1, b) = (b, a1 % b)
	return a1
t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		ans = gcd(ans, a[i] - a[(i - 1 + n) % n])
	if ans == 0:
		print('NO')
	if k % ans == a[0] % ans:
		print('YES')
	else:
		print('NO')


def __gcd(a, b):
	if a == 0:
		return b
	return __gcd(b % a, a)
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	gcd = 0
	flag = 0
	for i in range(len(a) - 1):
		gcd = __gcd(gcd, a[i + 1] - a[i])
	for i in range(len(a)):
		if ((k - a[i]) % gcd + gcd) % gcd == 0:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a

def poss(n, k, L):
	d = 0
	for x in L:
		d = gcd(x - L[0], d)
	if (k - L[0]) % d == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	L = [int(x) for x in input().split()]
	print(poss(n, k, L))


import sys
input = sys.stdin.readline
from math import gcd
t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	X = list(map(int, input().split()))
	G = 0
	for i in range(1, n):
		G = gcd(G, X[i] - X[i - 1])
	if k % G == X[0] % G:
		print('YES')
	else:
		print('NO')


def hcfnaive(a, b):
	if b == 0:
		return a
	else:
		return hcfnaive(b, a % b)
t = int(input())
for i in range(t):
	inp = input().split()
	n = int(inp[0])
	k = int(inp[1])
	temp_x = input().split()
	x = [int(elm) for elm in temp_x]
	x.sort()
	g = 0
	for j in range(1, n):
		g = hcfnaive(g, x[j] - x[0])
	if (k - x[0]) % g:
		print('NO\n')
	else:
		print('YES\n')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=-10 ** 6, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(50001)]
pp = []

def SieveOfEratosthenes(n=50000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for i in range(50001):
		if prime[i]:
			pp.append(i)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	g = a[1] - a[0]
	for i in range(1, n):
		a[i] -= a[0]
		g = math.gcd(g, a[i])
	if (k - a[0]) % g == 0:
		print('YES')
	else:
		print('NO')


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	g = 0
	for i in range(n):
		g = math.gcd(g, a[i] - a[0])
	print('YES' if k % g == a[0] % g else 'NO')


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	x.sort()
	g = 0
	for i in range(1, n):
		g = gcd(g, x[i] - x[0])
	if not (k - x[0]) % g:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	diff = []
	for i in range(1, len(a)):
		diff += [a[i] - a[i - 1]]
	diff = sorted(diff)
	k = (k - a[0]) % diff[0]
	oof = []
	g = diff[0]
	for i in range(1, len(diff)):
		x = diff[i] % diff[0]
		g = gcd(g, x)
	print('YES' if k % g == 0 else 'NO')


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	(g, chk) = (arr[1] - arr[0], True)
	for i in range(2, n):
		g = math.gcd(g, arr[i] - arr[i - 1])
	for i in range(n):
		if (k - arr[i]) % g == 0:
			print('YES')
			chk = False
			break
	if chk:
		print('NO')


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	g = a[1] - a[0]
	for i in range(2, n):
		g = gcd(a[i] - a[i - 1], g)
	if not abs(k - a[0]) % g:
		print('YES')
	else:
		print('NO')


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

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

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for ii in range(int(input())):
	(n, k) = mapIn()
	a = arrIn()
	g = 0
	a.sort()
	k -= a[0]
	for i in range(1, n):
		a[i] -= a[0]
		g = gcd(g, a[i])
	if k % g == 0:
		print('YES')
	else:
		print('NO')


from functools import reduce
from math import gcd

def solve():
	(n, k) = [int(s) for s in input().split()]
	x = [int(s) for s in input().split()]
	a = [x[i] - x[i - 1] for i in range(1, n)]
	total_gcd = reduce(lambda x1, x2: gcd(x1, x2), a)
	if (k - x[0]) % total_gcd == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for test in range(t):
	solve()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):

	def __init__(self, file):
		self.newlines = 0
		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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

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

def print_list(l):
	print(' '.join(map(str, l)))
from functools import reduce
import math
for _ in range(N()):
	(_, k) = RL()
	a = RLL()
	print('YES' if (k - a[0]) % reduce(math.gcd, [v - a[0] for v in a[1:]]) == 0 else 'NO')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import math
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	x = arr[1] - arr[0]
	for i in range(2, n):
		x = math.gcd(x, arr[i] - arr[0])
	if (k - arr[0]) % x == 0:
		print('YES')
	else:
		print('NO')


import math
from sys import stdin
import sys
ans = []
tt = int(stdin.readline())
for loop in range(tt):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	g = a[1] - a[0]
	for i in range(n - 1):
		g = math.gcd(g, a[i + 1] - a[i])
	if abs(k - a[0]) % g == 0:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


from math import gcd
import sys
input = sys.stdin.buffer.readline

def prog():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort()
		d = 0
		for i in range(n - 1):
			d = gcd(d, a[i + 1] - a[i])
		print('YES' if (k - a[0]) % d == 0 else 'NO')
prog()


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_(lst, k):
	lst.sort()
	k -= lst[0]
	lst = [x - lst[0] for x in lst]
	gcd = math.gcd(lst[0], lst[1])
	for a in lst[1:]:
		gcd = math.gcd(gcd, a)
	if k % gcd == 0:
		return 'YES'
	return 'NO'
for case_num in range(int(input())):
	(_, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	res = solve(lst, k)
	print(res)


import sys, math
r = sys.stdin.readline
for _ in range(int(r())):
	(n, k) = map(int, r().split())
	lst = list(map(int, r().split()))
	st = set(lst)
	if k in st:
		print('YES')
		continue
	lst.sort()
	g = 0
	for i in range(len(lst)):
		g = math.gcd(g, lst[i] - lst[0])
	if (k - lst[0]) % g == 0:
		print('YES')
	else:
		print('NO')