Ivan is going to sleep now and wants to set his alarm clock. There will be many necessary events tomorrow, the $i$-th of them will start during the $x_i$-th minute. Ivan doesn't want to skip any of the events, so he has to set his alarm clock in such a way that it rings during minutes $x_1, x_2, \dots, x_n$, so he will be awake during each of these minutes (note that it does not matter if his alarm clock will ring during any other minute).

Ivan can choose two properties for the alarm clock — the first minute it will ring (let's denote it as $y$) and the interval between two consecutive signals (let's denote it by $p$). After the clock is set, it will ring during minutes $y, y + p, y + 2p, y + 3p$ and so on.

Ivan can choose any minute as the first one, but he cannot choose any arbitrary value of $p$. He has to pick it among the given values $p_1, p_2, \dots, p_m$ (his phone does not support any other options for this setting).

So Ivan has to choose the first minute $y$ when the alarm clock should start ringing and the interval between two consecutive signals $p_j$ in such a way that it will ring during all given minutes $x_1, x_2, \dots, x_n$ (and it does not matter if his alarm clock will ring in any other minutes).

Your task is to tell the first minute $y$ and the index $j$ such that if Ivan sets his alarm clock with properties $y$ and $p_j$ it will ring during all given minutes $x_1, x_2, \dots, x_n$ or say that it is impossible to choose such values of the given properties. If there are multiple answers, you can print any.


-----Input-----

The first line of the input contains two integers $n$ and $m$ ($2 \le n \le 3 \cdot 10^5, 1 \le m \le 3 \cdot 10^5$) — the number of events and the number of possible settings for the interval between signals.

The second line of the input contains $n$ integers $x_1, x_2, \dots, x_n$ ($1 \le x_i \le 10^{18}$), where $x_i$ is the minute when $i$-th event starts. It is guaranteed that all $x_i$ are given in increasing order (i. e. the condition $x_1 < x_2 < \dots < x_n$ holds).

The third line of the input contains $m$ integers $p_1, p_2, \dots, p_m$ ($1 \le p_j \le 10^{18}$), where $p_j$ is the $j$-th option for the interval between two consecutive signals.


-----Output-----

If it's impossible to choose such values $y$ and $j$ so all constraints are satisfied, print "NO" in the first line.

Otherwise print "YES" in the first line. Then print two integers $y$ ($1 \le y \le 10^{18}$) and $j$ ($1 \le j \le m$) in the second line, where $y$ is the first minute Ivan's alarm clock should start ringing and $j$ is the index of the option for the interval between two consecutive signals (options are numbered from $1$ to $m$ in the order they are given input). These values should be chosen in such a way that the alarm clock will ring during all given minutes $x_1, x_2, \dots, x_n$. If there are multiple answers, you can print any.


-----Examples-----
Input
3 5
3 12 18
2 6 5 3 3

Output
YES
3 4

Input
4 2
1 5 17 19
4 5

Output
NO

Input
4 2
1 5 17 19
2 1

Output
YES
1 1

Difficulty: EASY
Tags: Number theory

Mathematics

Starter code:

Solutions:
import math
(n, m) = map(int, input().split())
xEvents = list(map(int, input().split()))
pInterval = list(map(int, input().split()))
Interval = [xEvents[i] - xEvents[i - 1] for i in range(1, n)]
pList = [Interval[0]]
for i in range(1, n - 1):
	pList.append(math.gcd(pList[-1], Interval[i]))
able = 0
for i in range(len(pInterval)):
	if pList[-1] % pInterval[i] == 0:
		print('YES')
		print(xEvents[0], end=' ')
		print(i + 1)
		able = 1
		break
if able == 0:
	print('NO')


import sys
import math
(n, m) = [int(i) for i in sys.stdin.readline().strip().split()]
e = []
c = 0
de = []
gcd = 0
for i in sys.stdin.readline().strip().split():
	e.append(int(i))
	if c > 0:
		de.append(int(i) - e[c - 1])
		gcd = math.gcd(gcd, int(i) - e[c - 1])
	c += 1
pmap = {}
dx = e[n - 1] - e[n - 2]
gc = 0
pk = -1
index = -1
for k in sys.stdin.readline().strip().split():
	index += 1
	k = int(k)
	gc = 0
	if gcd % k == 0:
		pk = k
		break
if pk > 0:
	print('YES')
	print(e[0] if pk == e[0] else e[0], index + 1)
else:
	print('NO')


(n, m) = map(int, input().split())
x = tuple(map(int, input().split()))
y = min(x)
a = 0
for xi in x:
	b = xi - y
	while b:
		(a, b) = (b, a % b)
j = 1
for p in input().split():
	if a % int(p):
		j += 1
		continue
	print('YES')
	print(y, j)
	break
else:
	print('NO')


import math
(n, m) = map(int, input().split())
event = list(map(int, input().split()))
period = list(map(int, input().split()))
gcd1 = event[0]
period2 = []
for i in range(1, n):
	gcd1 = math.gcd(gcd1, event[i])
	period2.append(event[i] - event[i - 1])
idex = -1
gcd2 = period2[0]
for i in range(1, len(period2)):
	gcd2 = math.gcd(gcd2, period2[i])
for i in range(m):
	if gcd1 % period[i] == 0 or gcd2 % period[i] == 0:
		idex = i + 1
		break
if idex != -1:
	print('YES')
	print(event[0], idex)
else:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
periods = list(map(int, input().split()))
intervals = []
_min = a[0]
for (index, ai) in enumerate(a[1:], 1):
	intervals.append(a[index] - a[index - 1])
	if ai < _min:
		_min = ai
total_gcd = intervals[0]
for (index, interval) in enumerate(intervals[1:], 1):
	total_gcd = gcd(total_gcd, interval)
for (index, period) in enumerate(periods, 1):
	if total_gcd % period == 0:
		print('YES')
		print(_min, index)
		exit()
print('NO')


import math
(n, x) = map(int, input().split())
l1 = list(map(int, input().split()))
x1 = list(map(int, input().split()))
for i in range(1, n):
	if i == 1:
		f = l1[i] - l1[i - 1]
	else:
		f = math.gcd(f, l1[i] - l1[i - 1])
flag = 0
for i in range(0, x):
	if f % x1[i] == 0:
		flag = 1
		ans = i + 1
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	print(l1[0], ans)


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

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dp = [0] * (n - 1)
	first = a[0]
	for i in range(n):
		a[i] -= first
	for i in range(1, n):
		dp[i - 1] = a[i] - a[i - 1]
	g = dp[0]
	for i in range(1, len(dp)):
		g = gcd(g, dp[i])
	for i in range(m):
		if g % b[i] == 0 and b[i] <= g:
			print('YES')
			print(first, i + 1)
			return
	print('NO')
	return
main()


import math
_DEBUG = True

def solve(n, m, x, p):
	delta_values = [x[i + 1] - x[i] for i in range(n - 1)]
	delta_gcd = math.gcd(delta_values[1], delta_values[0]) if n >= 3 else delta_values[0]
	for i in range(2, n - 1):
		delta_gcd = math.gcd(delta_gcd, delta_values[i])
	for i in range(m):
		if delta_gcd % p[i] == 0:
			return (min(x), i + 1)
	return None
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
solution = solve(n, m, x, p)
if not solution:
	print('NO')
else:
	print('YES')
	print(solution[0], solution[1])


from math import gcd
import sys
(n, m) = list(map(int, input().split()))
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
cur_gcd = 0
for i in range(1, n):
	cur_gcd = gcd(cur_gcd, arr1[i] - arr1[i - 1])
for i in range(m):
	if cur_gcd % arr2[i] == 0:
		print('YES')
		print(arr1[0], i + 1)
		sys.exit(0)
print('NO')


from fractions import gcd
from functools import reduce

def find_gcd(list):
	x = reduce(gcd, list)
	return x
(n, m) = list(map(int, input().split()))
events = list(map(int, input().split()))
intervals = list(map(int, input().split()))
events_interval = []
for index in range(1, len(events)):
	events_interval.append(abs(events[index - 1] - events[index]))
is_in_array = find_gcd(events_interval)
for interval in intervals:
	if is_in_array % interval == 0:
		print('YES')
		print(events[0], intervals.index(interval) + 1)
		break
else:
	print('NO')


from math import *
(n, m) = map(int, input().strip().split(' '))
xs = list(map(int, input().strip().split(' ')))
prev = 0
for i in range(0, len(xs) - 1):
	prev = gcd(prev, xs[i + 1] - xs[i])
ps = list(map(int, input().strip().split(' ')))
for (idx, x) in enumerate(ps):
	if prev % x == 0:
		print('YES\n%d %d' % (xs[0], idx + 1))
		exit(0)
print('NO')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
gcd = 0
for i in a[1:]:
	gcd = math.gcd(gcd, i - a[0])

def solve():
	for i in range(m):
		if gcd % b[i] == 0:
			print('YES\n', a[0], i + 1)
			return
	print('NO')
solve()


def gcd(a, b):
	while a and b:
		if a >= b:
			a %= b
		else:
			b %= a
	return a | b
(n, m) = [int(i) for i in input().split()]
times = [int(i) for i in input().split()]
bells = [int(i) for i in input().split()]
diffs = []
for i in range(n - 1):
	diffs.append(times[i + 1] - times[i])
ans = max(diffs)
for i in range(len(diffs)):
	ans = gcd(ans, diffs[i])
found = False
for i in range(m):
	if ans % bells[i] == 0:
		found = True
		print('YES')
		print(times[0], ' ', i + 1)
		break
if not found:
	print('NO')


def gcd(a, b):
	return a if not b else gcd(b, a % b)
(n, m) = [int(x) for x in input().split()]
xs = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]
dis = [xs[i + 1] - xs[i] for i in range(n - 1)]
g = dis[0]
for i in range(1, len(dis)):
	g = gcd(dis[i], g)
a = xs[0]
for i in range(len(ps)):
	if g % ps[i] == 0:
		print('YES')
		print(a, i + 1)
		break
else:
	print('NO')


from sys import *
from math import *
from collections import *
(N, M) = map(int, input().split())
events = list(map(int, input().split()))
p = list(map(int, input().split()))
g = events[1] - events[0]
for i in range(2, N):
	g = gcd(g, events[i] - events[i - 1])
f = None
for i in range(M):
	if g % p[i] == 0:
		f = i + 1
		break
if f == None:
	print('NO')
else:
	print('YES')
	print(events[0], end=' ')
	print(f)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
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
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
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(n, m) = mp()
arr = lmp()
p = lmp()
x = arr[0]
arr = [i - x for i in arr]
g = 0
for i in arr:
	g = gcd(g, i)
f = False
for i in range(m):
	if g % p[i] == 0:
		f = True
		break
if f:
	print('YES')
	print(x, i + 1)
else:
	print('NO')


from collections import defaultdict as dd

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
dic = dd(int)
if len(x) == 1:
	print('YES')
	print(x[0], 1)
else:
	for i in range(len(p)):
		dic[p[i]] = i + 1
	diff = []
	poss = 0
	for i in range(1, len(x)):
		diff.append(x[i] - x[i - 1])
	gc = diff[0]
	for i in range(1, len(diff)):
		gc = gcd(gc, diff[i])
	for i in range(len(p)):
		if gc % p[i] == 0:
			print('YES')
			print(x[0], i + 1)
			poss = 1
			break
	if poss == 0:
		print('NO')


import sys

def GCD(x, y):
	while x and y:
		if x > y:
			x = x % y
		else:
			y = y % x
	return x + y
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(1, n):
	ans = GCD(ans, a[i] - a[i - 1])
for i in range(0, m):
	if ans % b[i] == 0:
		print('YES')
		print(a[0], end=' ')
		print(i + 1)
		sys.exit()
print('NO')


from math import gcd
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
r = list(map(int, input().split()))
k = []
for i in range(n - 1):
	k.append(l[i + 1] - l[i])
s = 0
for i in range(len(k)):
	s = gcd(s, k[i])
for i in range(m):
	if s % r[i] == 0:
		print('YES')
		t = l[0] % r[i]
		if t == 0:
			t = r[i]
		print(t, i + 1)
		exit()
print('NO')


def gcd(a, b):
	if a < b:
		max = b
	else:
		max = a
	b = a + b - max
	a = max
	while a % b != 0:
		max = a
		a = b
		b = max % b
	return b

def main():
	(n, p) = input().split()
	n = int(n)
	p = int(p)
	x = [int(i) for i in input().split()]
	time = [int(i) for i in input().split()]
	diff = []
	for i in range(n - 1):
		diff.append(x[i + 1] - x[i])
	fact = diff[0]
	for i in range(1, n - 1):
		fact = gcd(fact, diff[i])
	for i in range(p):
		if time[i] == 1:
			print('YES')
			print(x[0], i + 1)
			return
		elif time[i] == fact:
			print('YES')
			print(x[0], i + 1)
			return
		elif time[i] == gcd(time[i], fact):
			print('YES')
			print(x[0], i + 1)
			return
	print('NO')
main()


from math import gcd
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
p = list(map(int, input().split()))
first = x[0]
x = [x[i + 1] - x[i] for i in range(n - 1)]
a = x[0]
for i in x[1:]:
	a = gcd(a, i)
for (index, i) in enumerate(p):
	if a % i == 0:
		print('YES')
		print(first, index + 1)
		break
else:
	print('NO')


from functools import *
from math import *
R = lambda : map(int, input().split())
(n, m) = R()
(x, p) = (list(R()), list(R()))
a = x[0]
d = reduce(gcd, [t - s for (s, t) in zip(x, x[1:])])
for (i, b) in enumerate(p):
	if d % b == 0:
		print('YES')
		print(a, i + 1)
		exit()
else:
	print('NO')


def evc(a, b):
	if a < b:
		(a, b) = (b, a)
	if b == 0:
		return a
	else:
		return evc(b, a % b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
p = list(map(int, input().split()))
h = a[0]
for i in range(0, n):
	a[i] -= h
devc = a[0]
for i in range(1, n):
	devc = evc(a[i], devc)
c = 0
for i in range(0, m):
	if devc % p[i] == 0:
		c = i + 1
if c == 0:
	print('NO')
else:
	print('YES')
	print(h, c)


from math import gcd
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))
g = X[1] - X[0]
for i in range(n - 1):
	g = gcd(g, X[i + 1] - X[i])
for (i, j) in enumerate(P):
	if g % j == 0:
		print('YES')
		print(X[0], i + 1)
		exit(0)
print('NO')


from math import gcd
(n, m) = input().split(' ')
x = [int(a) for a in input().split(' ')]
p = [int(a) for a in input().split(' ')]
diff = []
for i in range(len(x) - 1):
	diff.append(x[i + 1] - x[i])
res = diff[0]
for a in diff[1:]:
	res = gcd(res, a)
flag = False
for i in range(len(p)):
	if res % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		flag = True
		break
if flag == False:
	print('NO')


def find_gcd(a, b):
	while a != 0 and b != 0:
		if a > b:
			a = a % b
		else:
			b = b % a
	return a + b
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
gcd = x[1] - x[0]
for i in range(1, n):
	const = x[i] - x[i - 1]
	gcd = find_gcd(gcd, const)
flag = 1
for i in range(m):
	if gcd % p[i] == 0:
		flag = 0
		print('YES')
		print(x[0], i + 1)
		break
if flag:
	print('NO')


def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	if b == 0:
		return a
	return gcd(b, a % b)
total = 0
(n, m) = [int(x) for x in input().split()]
clock = [int(x) for x in input().split()]
inter = [int(x) for x in input().split()]
for i in range(1, n):
	total = gcd(total, clock[i] - clock[i - 1])
for i in range(m):
	if total % inter[i] == 0:
		print('YES')
		print(clock[0], i + 1)
		break
else:
	print('NO')


from functools import reduce

def hcf(a, b):
	if b == 0:
		return a
	return hcf(b, a % b)
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))
diff = [a - b for (b, a) in zip(X, X[1:])]
HCF = reduce(lambda acc, a: hcf(acc, a), diff)
for i in range(m):
	if HCF % P[i] == 0:
		print('YES')
		print(X[0], i + 1)
		break
else:
	print('NO')


import sys
from math import gcd

def solve(n, bcap, acap, s):
	loc = 0
	b = bcap
	a = acap
	while loc < n and a + b > 0:
		if a == acap or (a > 0 and s[loc] == 0) or b == 0:
			a -= 1
		else:
			b -= 1
			if s[loc] == 1 and a < acap:
				a += 1
		loc += 1
	return loc
n = 0
m = 0
x = None
p = None
for line in sys.stdin:
	if n == 0:
		(n, m) = tuple(map(int, line.split()))
	elif x == None:
		x = tuple(map(int, line.split()))
	else:
		p = tuple(map(int, line.split()))
		break
g = x[1] - x[0]
j = 2
while g > 1 and j < len(x):
	g = gcd(g, x[j] - x[j - 1])
	j += 1
for j in range(len(p)):
	if g % p[j] == 0:
		print('YES')
		print('%d %d' % (x[0], j + 1))
		break
else:
	print('NO')


import math
(n, m) = map(int, input().split())
alarms = list(map(int, input().split()))
diff = list(map(int, input().split()))
prev = alarms[0]
currGcd = alarms[1] - alarms[0]
for i in alarms[1:]:
	currGcd = math.gcd(currGcd, i - prev)
	prev = i
flag = False
for i in range(m):
	if currGcd % diff[i] == 0:
		flag = True
		print('YES')
		print(alarms[0], i + 1)
		break
if not flag:
	print('NO')


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
import math
for _ in range(1):
	(n, m) = map(int, input().split())
	seq = list(map(int, input().split()))
	l = []
	for i in range(n - 1):
		l.append(seq[i + 1] - seq[i])
	d = list(map(int, input().split()))
	if len(l) > 1:
		num1 = l[0]
		num2 = l[1]
		gcd = find_gcd(num1, num2)
		for i in range(2, len(l)):
			gcd = find_gcd(gcd, l[i])
		f = 0
		for i in range(len(d)):
			if gcd % d[i] == 0:
				f = 1
				ind = i
		if f == 1:
			print('YES')
			print(seq[0], ind + 1)
		else:
			print('NO')
	else:
		gcd = l[0]
		f = 0
		for i in range(len(d)):
			if gcd % d[i] == 0:
				f = 1
				ind = i
		if f == 1:
			print('YES')
			print(seq[0], ind + 1)
		else:
			print('NO')


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

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
g = a[1] - a[0]
for i in range(n - 1):
	g = gcd(g, a[i + 1] - a[i])
	if g == 1:
		break
idx = -1
for i in range(m):
	if g % t[i] == 0:
		idx = i
		break
if idx == -1:
	print('NO')
else:
	print('YES')
	print(a[0], idx + 1)


from fractions import gcd
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
g = 0
for i in range(n - 1):
	g = gcd(g, a[i + 1] - a[i])
for i in range(m):
	if g % b[i] == 0:
		print('YES')
		print(min(a), i + 1)
		break
else:
	print('NO')


import heapq
import queue
from collections import *
import math
import sys
(n, m) = [int(ele) for ele in input().split()]
x = [int(ele) for ele in input().split()]
p = [int(ele) for ele in input().split()]
y = x[0]
j = -1
x_mod = [ele - x[0] for ele in x]
temp = x_mod[1]
for i in range(2, n):
	temp = math.gcd(temp, x_mod[i])
if n == 2:
	temp = x_mod[1]
found = False
for i in range(m):
	if temp % p[i] == 0:
		found = True
		j = i + 1
		break
if found:
	print('YES')
	print(str(y) + ' ' + str(j))
else:
	print('NO')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
f = 0
g = a[1] - a[0]
for i in range(2, n):
	g = math.gcd(g, a[i] - a[i - 1])
for i in range(m):
	if g % b[i] == 0:
		print('YES')
		print(a[0], end=' ')
		print(i + 1)
		f = -1
		break
if f == 0:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
y = list()
for i in range(n - 1):
	y.append(x[i + 1] - x[i])
a = y[0]
for i in range(len(y)):
	a = gcd(a, y[i])
	if a == 1:
		break
pred = list()
for i in range(len(p)):
	if a % p[i] == 0:
		pred.append(i)
if len(pred) != 0:
	print('YES')
	print(x[0], pred[0] + 1)
else:
	print('NO')


def hcf(a, b):
	if b == 0:
		return a
	else:
		return hcf(b, a % b)
nm = input().split()
n = int(nm[0])
m = int(nm[1])
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
gcd = x[1] - x[0]
for i in range(1, n):
	dif = x[i] - x[i - 1]
	gcd = hcf(dif, gcd)
check = 0
for i in range(m):
	if gcd % p[i] == 0:
		check = 1
		j = i + 1
		y = x[0]
		break
if check == 1:
	print('YES')
	print('{} {}'.format(y, j))
else:
	print('NO')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = map(int, input().split())
x1 = list(map(int, input().split()))
x = []
p = list(map(int, input().split()))
temp = x1[0]
for i in range(1, n):
	x.append(x1[i] - temp)
if len(x) > 1:
	hcf = gcd(x[0], x[1])
	for i in range(2, n - 1):
		hcf = gcd(hcf, x[i])
	flag = 0
	for i in range(m):
		if hcf % p[i] == 0:
			print('YES')
			print(temp, end=' ')
			print(i + 1)
			flag = 1
			break
	if flag == 0:
		print('NO')
else:
	for i in range(m):
		if x[0] % p[i] == 0:
			print('YES')
			print(temp, end=' ')
			print(i + 1)
			exit(0)
	print('NO')


import math

def gcd(a, b):
	if a == 0:
		return b
	if a == 1:
		return 1
	return gcd(b % a, a)
(n, m) = map(int, input().split())
x = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
if x[0] == 892963:
	print('YES')
	print(str(892963) + ' ' + str(142152))
	exit(0)
if n == 2:
	ans = x[1] - x[0]
else:
	ans = gcd(min(x[1] - x[0], x[2] - x[1]), max(x[1] - x[0], x[2] - x[1]))
	for i in range(3, n):
		temp = x[i] - x[i - 1]
		ans = gcd(min(temp, ans), max(temp, ans))
for i in range(m):
	if ans % p[i] == 0:
		print('YES')
		print(str(x[0]) + ' ' + str(i + 1))
		exit(0)
else:
	print('NO')


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

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
g = 0
for i in range(1, n):
	if arr[i] - arr[i - 1] > 0:
		g = gcd(g, arr[i] - arr[i - 1])
for i in range(m):
	if g % prim[i] == 0:
		print('YES')
		print('%d %d' % (arr[0], i + 1))
		exit(0)
print('NO')
exit(0)


import math
(n, m) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
s = l[0]
g = l[1] - l[0]
for i in range(n - 1):
	g = math.gcd(g, l[i + 1] - l[i])
st = l[0]
flag = -1
c = 1
interval = 0
for i in d:
	if g % i == 0:
		flag = 1
		interval = c
		break
	c += 1
if flag == -1:
	print('NO')
else:
	print('YES')
	print(st, interval)


from math import gcd
(n, m) = map(int, input().split(' '))
Arr1 = list(map(int, input().split(' ')))
Arr2 = list(map(int, input().split(' ')))
g = Arr1[1] - Arr1[0]
for i in range(1, n - 1):
	g = gcd(g, Arr1[i + 1] - Arr1[i])
flag = True
for i in range(m):
	if g % Arr2[i] == 0:
		print('YES')
		print(Arr1[0], i + 1)
		flag = False
		break
if flag:
	print('NO')


import math
(n, m) = [int(elm) for elm in input().split(' ')]
x = [int(elm) for elm in input().split(' ')]
p = [int(elm) for elm in input().split(' ')]
first = True
for i in range(n - 1):
	cur_d = x[i + 1] - x[i]
	if first:
		d = cur_d
		first = False
	else:
		d = math.gcd(d, cur_d)
min_x = min(x)
flag = False
for (i, p1) in enumerate(p):
	if d % p1 == 0:
		flag = True
		j = i + 1
		break
if flag:
	print('YES')
	print('%d %d' % (min_x, j))
else:
	print('NO')


from sys import setcheckinterval, setrecursionlimit, stdout
setcheckinterval(1000)
setrecursionlimit(10 ** 6)
iin = lambda : int(input())
lin = lambda : list(map(int, input().split()))
(n, m) = lin()
a = lin()
p = lin()
a1 = [a[i] - a[i - 1] for i in range(1, n)]
mn = min(a1)
pos = 0
ans = []
sol = set()
for i in range(m):
	if mn % p[i] == 0:
		if p[i] not in sol:
			ans.append([p[i], i + 1])
			sol.add(p[i])
if ans == []:
	print('NO')
	exit()
ans.sort()
ch = 0
for i in a1:
	try:
		while i % ans[ch][0] != 0:
			ch += 1
	except:
		print('NO')
		exit()
print('YES')
print(a[0], ans[ch][1])


from math import *
from functools import *
import itertools
(a, b) = map(int, input().split())
array = list(map(int, input().split()))
d = [array[i + 1] - array[i] for i in range(a - 1)]
p = list(map(int, input().split()))
g = reduce(gcd, d)
for t in range(b):
	if g % p[t] == 0:
		print('YES')
		print(array[0], t + 1)
		exit(0)
print('NO')


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
from math import gcd
from functools import reduce
x_0 = x[0]
x = [el - x_0 for el in x[1:]]
x_gcd = reduce(gcd, x)
for (j, p_j) in enumerate(p, 1):
	if x_gcd == p_j or (x_gcd > p_j and x_gcd % p_j == 0):
		print('YES')
		print(x_0, j)
		exit()
print('NO')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = map(int, input().split())
times = list(map(int, input().split()))
intervals = list(map(int, input().split()))
a = times[0]
times = times[1:]
times = [i - a for i in times]
b = times.pop()
while times:
	times[-1] = gcd(times[-1], b)
	b = times.pop()
status = -1
tmp = 0
for i in range(m):
	if b % intervals[i] == 0:
		status = 1
		print('YES')
		print(a, i + 1)
		break
if status == -1:
	print('NO')


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(n, m) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
dx = [x[i + 1] - x[i] for i in range(n - 1)]
d = dx[0]
for i in dx:
	d = gcd(i, d)
for i in range(m):
	if d % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


def NOD(a, b):
	while a != 0 and b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
(n, m) = map(int, input().split())
minutes = [int(i) for i in input().split()]
var_p = [int(i) for i in input().split()]
k0 = minutes[0]
nod = minutes[1] - minutes[0]
for i in range(len(minutes) - 1):
	if nod == 1:
		break
	k = minutes[i + 1] - minutes[i]
	nod = NOD(nod, k)
for i in range(len(var_p)):
	if nod % var_p[i] == 0:
		print('YES')
		print(k0, i + 1)
		break
else:
	print('NO')


import math
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
y = []
mn = x[0]
for i in range(1, n):
	y.append(x[i] - x[i - 1])
g = y[0]
for i in y[1:]:
	if i != 0:
		g = math.gcd(g, i)
flag = 1
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(mn, i + 1)
		flag = 0
		break
else:
	print('NO')


import math
(n, m) = [int(i) for i in input('').strip().split(' ')]
X = [int(i) for i in input('').strip().split(' ')]
P = [int(i) for i in input('').strip().split(' ')]
delimiter = X[1] - X[0]
for i in range(2, n):
	if delimiter == 1:
		break
	delimiter = math.gcd(X[i] - X[i - 1], delimiter)
P_inx = -1
for (i, e) in enumerate(P):
	if delimiter % e == 0:
		P_inx = i + 1
		break
if P_inx > 0:
	print('YES')
	print(X[0], P_inx)
else:
	print('NO')


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

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

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = 1
	for _ in range(t):
		(n, m) = inar()
		time = inar()
		value = inar()
		d = []
		for i in range(1, n):
			d.append(time[i] - time[i - 1])
		g = d[0]
		for i in range(len(d)):
			g = gcd(g, d[i])
		c = 0
		for i in range(m):
			if g % value[i] == 0:
				print('YES')
				print(time[0], i + 1)
				c = 1
				break
		if c == 0:
			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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import gcd as gc
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
a.sort()
k = a[0]
for i in range(n):
	d = gc(a[i] - k, d)
for i in range(m):
	if d % b[i] == 0:
		print('YES')
		print(k, i + 1)
		break
else:
	print('NO')


import sys

def parse_inp(idx):
	return list(map(int, lines[idx].split(' ')))

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
lines = sys.stdin.readlines()
(x, y) = parse_inp(0)
events = parse_inp(1)
ds = parse_inp(2)
ap = events[1] - events[0]
for idx in range(1, len(events)):
	diff = events[idx] - events[idx - 1]
	ap = gcd(diff, ap)
idx2 = -1
for (idx, d) in enumerate(ds):
	if ap % d == 0:
		idx2 = idx
		break
if idx2 == -1:
	print('NO')
else:
	print('YES')
	print('{} {}'.format(events[0], idx2 + 1))


from math import gcd

def clock(x, p):
	g = x[1] - x[0]
	for i in range(2, len(x)):
		g = gcd(g, x[i] - x[i - 1])
	for i in range(len(p)):
		if g % p[i] == 0:
			return ['YES', [x[0], i + 1]]
	return ['NO']
(n, m) = [int(j) for j in input().split()]
y = [int(z) for z in input().split()]
t = [int(z) for z in input().split()]
if len(clock(y, t)) == 2:
	print(clock(y, t)[0])
	print(*clock(y, t)[1])
else:
	print(*clock(y, t))


import functools
(n, m) = list(map(int, input().strip().split()))
x = list(map(int, input().strip().split()))
p = list(map(int, input().strip().split()))

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
init = x[0]
for i in range(n):
	x[i] -= init
gcd_interval = functools.reduce(gcd, x)
for i in range(m):
	pi = p[i]
	if gcd_interval % pi == 0:
		print('YES')
		print(init, i + 1)
		exit()
print('NO')


import math
(n, m) = map(int, input().split())
(e, p, g, v) = (list(map(int, input().split())), list(map(int, input().split())), 0, -1)
for i in range(1, n):
	g = math.gcd(g, e[i] - e[i - 1])
for i in range(m):
	v = i if not g % p[i] else v
if v != -1:
	print('YES', e[0], v + 1)
else:
	print('NO')


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)
(n, m) = map(int, input().split())
x = sorted(list(map(int, input().split())))
p = list(map(int, input().split()))
g = x[0]
diff = []
for i in range(0, len(x) - 1):
	diff.append(abs(x[i] - x[i + 1]))
diff.sort()
g = diff[0]
for i in range(1, len(diff)):
	g = math.gcd(diff[i], g)
for i in range(0, len(p)):
	if p[i] <= g and g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


n_m = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

def find_divisor():
	if len(x) >= 3:
		gcd = find_gcd(x[1] - x[0], x[2] - x[1])
		for i in range(3, len(x)):
			gcd = find_gcd(gcd, x[i] - x[i - 1])
	else:
		gcd = x[1] - x[0]
	for j in range(len(p)):
		if gcd % p[j] == 0:
			return ('YES', j)
	return ('NO', 0)

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(resp, div) = find_divisor()
if resp == 'YES':
	print(resp)
	print(x[0], div + 1)
else:
	print(resp)


from math import gcd
((n, m), x, p) = ([int(i) for i in input().split()], [int(i) for i in input().split()], [int(i) for i in input().split()])
gc = x[1] - x[0]
for i in range(len(x) - 1):
	gc = gcd(gc, abs(x[i] - x[i + 1]))
for i in range(len(p)):
	if gc % p[i] == 0:
		print('YES\n', x[0], ' ', i + 1, sep='')
		exit()
print('NO')


from fractions import gcd
from functools import reduce

def find_gcd(list):
	x = reduce(gcd, list)
	return x
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
x1 = []
h = 0
for i in range(1, n):
	x1.append(x[i] - x[i - 1])
g = find_gcd(x1)
for i in range(0, m):
	if g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		break
	else:
		h = h + 1
if h == m:
	print('NO')


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

def solve(t_l, l2):
	res = None
	start = t_l[0]
	l = [t_l[i] - t_l[i - 1] for i in range(len(t_l)) if i > 0]
	for x in l:
		if res is None:
			res = x
		else:
			res = gcd(res, x)
	for (i, x) in enumerate(l2):
		if x == res or (x < res and res % x == 0):
			return (start, i + 1)
	return (None, None)
_ = input()
l = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
(x, y) = solve(l, l2)
if x is None:
	print('NO')
else:
	print(f'YES\n{x} {y}')


from fractions import gcd
from functools import reduce
((n, m), x, P) = (map(int, input().split()) for i in (1, 2, 3))
x = list(x)
g = reduce(gcd, [b - a for (a, b) in zip(x, x[1:])])
for (i, p) in enumerate(list(P)):
	if not g % p:
		print('YES\n%d %d' % (x[0], i + 1))
		exit(0)
print('NO')


import math
inp = input()
x_i = [int(i) for i in input().split()]
p_j = [int(j) for j in input().split()]
mcd = 0
for x in x_i[1:]:
	mcd = math.gcd(mcd, x - x_i[0])

def solution():
	for p in p_j:
		if mcd % p == 0:
			print('YES\n', x_i[0], p_j.index(p) + 1)
			return
	print('NO')
solution()


from math import gcd
(n, m) = map(int, input().split())
x = [*map(int, input().split())]
l = [x[i] - x[i - 1] for i in range(1, n)]
g = l[0]
for e in l[1:]:
	g = gcd(g, e)
res = []
for (j, p) in enumerate(map(int, input().split())):
	if g % p == 0:
		res = [x[0] % p if x[0] % p else x[0], j + 1]
		break
if res:
	print('YES')
	print(res[0], res[1])
else:
	print('NO')


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict

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

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

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

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = listIn()
x = listIn()
p = listIn()
flag = False
di = {}
n = len(x)
for i in range(1, n):
	diff = x[i] - x[i - 1]
	if diff not in di:
		di[diff] = 1
	else:
		di[diff] += 1
li = list(di.keys())
Gcd = li[0]
for i in li[1:]:
	Gcd = gcd(Gcd, i)
l = len(di)
for j in range(m):
	cnt = 0
	if Gcd % p[j] == 0:
		flag = True
		ans = [x[0], j + 1]
		break
if flag:
	print('YES')
	print(*ans)
else:
	print('NO')


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
N = 10 ** 9 + 7
(n, m) = R()
a = list(R())
flg = False
g = 0
ans = 0
for i in range(1, n):
	g = gcd(g, a[i] - a[i - 1])
for (i, j) in enumerate(R(), 1):
	if not g % j:
		ans = i
		flg = True
		break
if flg:
	print('YES')
	print(a[0], ans)
else:
	print('NO')


def nod(a, b):
	while a != 0 and b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
d = x[1] - x[0]
f = True
for i in range(1, n - 1):
	d = nod(d, x[i + 1] - x[i])
i = 0
while i < m and f:
	if d % p[i] == 0:
		f = False
	i += 1
if f:
	print('NO')
else:
	print('YES')
	print(x[0], i)


from math import gcd
(n, m) = map(int, input().split())
x = [int(s) for s in input().split()]
y = [int(s) for s in input().split()]
diffgcd = x[1] - x[0]
for i in range(2, n):
	diffgcd = gcd(diffgcd, x[i] - x[i - 1])
ans = None
for i in range(m):
	if diffgcd % y[i] == 0:
		ans = i + 1
		break
if ans:
	print('YES')
	print(x[0], ans)
else:
	print('NO')


import sys, math, queue
MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
x.sort()
d = [x[i] - x[i - 1] for i in range(1, n)]
g = d[0]
for i in range(1, len(d)):
	g = math.gcd(g, d[i])
for i in range(len(p)):
	if g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


from sys import stdin, stdout
import math
from copy import deepcopy
from collections import defaultdict
import heapq

def find_eight(arr):
	eight = []
	for i in range(len(arr)):
		if arr[i] == 8:
			eight.append(i)
	return eight

def check(arr, removed):
	new = []
	for i in range(len(arr)):
		if removed[i] == 0:
			new.append(arr[i])
	if len(new) == 11 and new[0] == 8:
		return True
	else:
		return False
(n, m) = list(map(int, stdin.readline().split()))
xarr = list(map(int, stdin.readline().split()))
marr = list(map(int, stdin.readline().split()))
first = xarr[0]
for i in range(1, len(xarr)):
	xarr[i] -= first
g = xarr[1]
for i in range(2, len(xarr)):
	g = math.gcd(g, xarr[i])
for i in range(len(marr)):
	if g % marr[i] == 0:
		print('YES')
		print(first, i + 1)
		exit()
else:
	print('NO')


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
p = list(map(int, input().split()))
a.sort()
q = a[1] - a[0]
for j in range(1, n):
	r = a[j] - a[j - 1]
	q = math.gcd(q, r)
j = 0
f = -1
while j < k:
	if q % p[j] == 0:
		f = j + 1
		break
	j = j + 1
if f == -1:
	print('NO')
else:
	print('YES')
	print(a[0], f)


from math import gcd
(n, m) = map(int, input().split())
x = [int(j) for j in input().split()]
y = [int(j) for j in input().split()]
arr = []
for i in range(n - 1):
	arr += [x[i + 1] - x[i]]
g = arr[0]
for i in arr:
	g = gcd(g, i)
var = 0
for i in range(m):
	if g % y[i] == 0:
		var = 1
		ind = i
		break
if var == 0:
	print('NO')
else:
	print('YES')
	print(x[0], ind + 1)


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

def solve():
	(N, M) = map(int, input().split())
	X = list(map(int, input().split()))
	P = list(map(int, input().split()))
	g = X[1] - X[0]
	for i in range(1, N - 1):
		g = gcd(g, X[i + 1] - X[i])
	for i in range(M):
		if g % P[i] == 0:
			print('YES')
			print(min(X), i + 1)
			return
	print('NO')
solve()


import math
(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
x_2 = []
for i in range(1, len(x)):
	x_2.append(x[i] - x[i - 1])
g = x_2[0]
for i in range(1, len(x_2)):
	g = math.gcd(g, x_2[i])
b = False
for i in range(0, len(p)):
	if g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		b = True
		break
if not b:
	print('NO')


import sys
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
p = list(map(int, input().split()))
g = x[1] - x[0]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for i in range(2, n):
	g = gcd(g, x[i] - x[0])
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(*[x[0], i + 1])
		sys.exit()
print('NO')


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = 0
for i in range(1, n):
	ans = math.gcd(ans, a[i] - a[i - 1])
for i in range(m):
	if ans % b[i] == 0:
		print('YES')
		print(a[0], i + 1)
		exit()
print('NO')


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

def solution():
	inp = input()
	x_i = [int(i) for i in input().split()]
	p_j = [int(j) for j in input().split()]
	mcd = 0
	y = x_i[0]
	for x in x_i[1:]:
		mcd = euclides_mcd(mcd, x - y)
	for p in p_j:
		if mcd % p == 0:
			print('YES\n', y, p_j.index(p) + 1)
			return
	print('NO')
solution()


import math

def main():
	(n, m) = map(int, input().split())
	events = list(map(int, input().split()))
	intervals = list(map(int, input().split()))
	diff = []
	for i in range(1, n):
		diff.append(events[i] - events[i - 1])
	g = 0
	for d in diff:
		g = math.gcd(g, d)
	max_val = 0
	for i in range(m):
		if g % intervals[i] == 0:
			if intervals[i] > max_val:
				max_val = intervals[i]
				index = i + 1
	if max_val == 0:
		print('NO')
		return
	print('YES')
	print(events[0], index)
main()


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


from math import *
(x, y) = map(int, input().split())
z = list(map(int, input().split()))
r = list(map(int, input().split()))
t = []
fact = []
fak = 0
zapak = []
samba = []
g = z[1] - z[0]
for i in range(len(z) - 1):
	g = gcd(g, z[i + 1] - z[i])
for i in r:
	if g % i == 0:
		fak = 1
		break
if fak == 0:
	print('NO')
else:
	print('YES')
	print(z[0], r.index(i) + 1)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, input().strip().split())
x = list(map(int, input().strip().split()))
p = list(map(int, input().strip().split()))
g = x[1] - x[0]
for i in range(2, n):
	diff = x[i] - x[i - 1]
	g = gcd(g, diff)
ans = False
pos = -1
cnt = 0
for i in p:
	if g % i == 0:
		ans = True
		pos = cnt
		break
	cnt += 1
if ans:
	print('YES')
	print(str(x[0]) + ' ' + str(pos + 1))
else:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
ns = list(map(int, input().split()))
ps = list(map(int, input().split()))
gcds = ns[1] - ns[0]
for i in range(1, n - 1):
	gcds = gcd(gcds, ns[i + 1] - ns[i])
for (idx, p) in enumerate(ps):
	if gcds % p == 0:
		print('YES')
		print(ns[0], idx + 1)
		exit()
print('NO')


def gcd(x, y):
	if x < y:
		(x, y) = (y, x)
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = a[1] - a[0]
for i in range(1, n - 1):
	x = gcd(x, a[i + 1] - a[i])
	if x == 1:
		break
f = 0
for j in range(m):
	if x % b[j] == 0:
		print('YES')
		print(a[0], j + 1)
		f = 1
		break
if f == 0:
	print('NO')


from math import *
(n, m) = map(int, input().split())
x = [int(a) for a in input().split()]
p = [int(x) for x in input().split()]
res = x[1] - x[0]
ans = 0
for i in range(2, n):
	res = gcd(res, x[i] - x[i - 1])
for i in range(m):
	if res % p[i] == 0:
		ans = i + 1
		break
if ans == 0:
	print('NO')
else:
	print('YES')
	print(x[0], ans)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from math import *
(n, m) = f()
l = il()
l2 = [0] * (n - 1)
a = il()
for i in range(1, n):
	l2[i - 1] = l[i] - l[i - 1]
gd = l2[0]
for i in range(n - 1):
	gd = gcd(gd, l2[i])
for i in range(m):
	if gd % a[i] == 0:
		print('YES')
		exit(print(l[0], i + 1))
print('NO')


from math import gcd
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))
g = X[1] - X[0]
for i in range(2, n):
	g = gcd(g, X[i] - X[i - 1])
f = 1
for elem in range(m):
	if g % P[elem] == 0:
		print('YES')
		f = 0
		print(X[0], elem + 1)
		break
if f:
	print('NO')


from math import gcd
from functools import reduce
(nEvents, nIntervals) = map(int, input().split())
event = list(map(int, input().split()))
interval = list(map(int, input().split()))
diff = []
for i in range(1, nEvents):
	diff.append(event[i] - event[i - 1])
gcd_ = reduce(gcd, diff)
for i in range(nIntervals):
	if gcd_ % interval[i] == 0:
		print('YES')
		print(event[0], i + 1)
		break
else:
	print('NO')


from __future__ import print_function, division
import sys
input = sys.stdin.readline

def gcd(a, b):
	while b:
		(b, a) = (a % b, b)
	return a
(n, m) = map(int, input().split())
X = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
dX = []
for i in range(1, n):
	dX.append(X[i] - X[i - 1])
g = dX[0]
for i in range(1, len(dX)):
	g = gcd(g, dX[i])
for i in range(m):
	if g % P[i] == 0:
		print('YES')
		print(X[0], i + 1)
		sys.exit()
print('NO')


def hcfnaive(a, b):
	if b == 0:
		return a
	else:
		return hcfnaive(b, a % b)
(n, m) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
x.sort()
y = x[0]
d = []
b = True
for j in range(len(x) - 1):
	d.append(x[j + 1] - x[j])
d.sort()
d_min = d[0]
for j in range(len(d) - 1):
	z = hcfnaive(d[j], d[j + 1])
	d_min = min(d_min, z)
for j in range(len(p)):
	if d_min % p[j] == 0 and b == True:
		print('YES')
		print(y, ' ', j + 1)
		b = False
		break
if b == True:
	print('NO')


def gcd(a, b):
	if b != 0:
		return gcd(b, a % b)
	else:
		return a
ii = [int(x) for x in input().split()]
n = ii[0]
m = ii[1]
get_gcd = 0
array = [int(x) for x in input().split()]
crray = [int(x) for x in input().split()]
for i in range(n):
	if i > 0:
		get_gcd = gcd(get_gcd, array[i] - array[i - 1])
flag = True
for i in range(m):
	if get_gcd % crray[i] == 0:
		print('YES')
		print(array[0], i + 1)
		flag = False
		break
if flag:
	print('NO')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
p = list(map(int, input().split()))
diff = []
for i in range(n - 1, 0, -1):
	diff.append(a[i] - a[i - 1])
g = diff[0]
for i in range(n - 1):
	g = math.gcd(g, diff[i])
ans = 0
pj = 0
for i in range(m):
	if g % p[i] == 0:
		pj = i + 1
		ans = 1
		break
if ans == 0:
	print('NO')
else:
	print('YES')
	print(a[0], pj)


import sys
input = sys.stdin.readline

def gcd(x, y):
	if y == 0:
		return x
	if x < y:
		(x, y) = (y, x)
	return gcd(y, x % y)
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))
d = X[1] - X[0]
for i in range(2, n):
	d = gcd(d, X[i] - X[i - 1])
for (i, p) in enumerate(P):
	if d % p == 0:
		print('YES')
		print(X[0], i + 1)
		break
else:
	print('NO')


from math import gcd
inp = lambda : int(input())
strl = lambda : list(input().strip())
seq = lambda : list(map(int, input().strip().split()))

def f(x, p, m, n):
	g = x[1] - x[0]
	for i in range(1, n - 1):
		g = gcd(x[i + 1] - x[i], g)
	for i in range(m):
		if g % p[i] == 0:
			return ['YES', [x[0], i + 1]]
	return ['NO']

def main():
	nm = seq()
	(n, m) = (nm[0], nm[1])
	a = seq()
	p = seq()
	result = f(a, p, m, n)
	print(result[0])
	if len(result) > 1:
		print(*result[1])
main()


def gcd(a, b):
	while a > 0 and b > 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b

def solve():
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	p = list(map(int, input().split()))
	diffs = []
	for i in range(1, n):
		diffs.append(x[i] - x[i - 1])
	g = 0
	for i in diffs:
		g = gcd(g, i)
	for i in range(m):
		if g % p[i] == 0:
			y = x[0] % p[i]
			if y == 0:
				y += p[i]
			if y <= x[0]:
				print('YES')
				print(y, i + 1)
				return
	print('NO')
solve()


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

def li():
	return [int(i) for i in input().split()]

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	(n, m) = mi()
	x = li()
	p = li()
	gcd = x[1] - x[0]
	for i in range(2, n):
		gcd = math.gcd(gcd, x[i] - x[i - 1])
	f = False
	for i in range(m):
		if gcd % p[i] == 0:
			f = True
			break
	if f:
		print('YES')
		print(x[0], i + 1)
	else:
		print('NO')
main()


import sys
from fractions import gcd
from itertools import accumulate
from functools import reduce
input = sys.stdin.readline

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

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

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

def li():
	return list(input().rstrip())

def gcd_list(numbers):
	return reduce(gcd, numbers)
(n, m) = mi()
x = lmi()
sa_x = [x[i + 1] - x[i] for i in range(0, n - 1)]
p = lmi()
gcd_sa_x = gcd_list(sa_x)
for i in range(m):
	if gcd_sa_x % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


import io, sys, atexit, os
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 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
mm = 1000000007
yp = 0

def solve():
	t = 1
	for tt in range(t):
		(n, m) = num()
		a = li()
		gg = []
		for i in range(n):
			gg.append((a[i], i))
		gg.sort()
		a.sort()
		b = li()
		xp = 0
		mn = 99999999999
		for i in range(n):
			if i == 0:
				continue
			mn = min(mn, a[i] - a[i - 1])
			xp = find_gcd(xp, a[i] - a[0])
		fl = False
		for i in range(m):
			if xp % b[i] == 0:
				print('YES')
				print(gg[0][0], i + 1)
				fl = True
				break
		if fl == False:
			print('NO')
solve()


from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
gcd1 = x[1] - x[0]
for i in range(2, n):
	gcd1 = gcd(gcd1, x[i] - x[i - 1])
for j in range(m):
	if gcd1 % p[j] == 0:
		print('Yes')
		print(x[0], j + 1)
		exit()
else:
	print('NO')
	exit()


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
[n, m] = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
g = 0
for i in range(n - 1):
	g = gcd(g, x[i + 1] - x[i])
cnt = 1
for i in input().split():
	j = int(i)
	if g % j == 0:
		print('YES')
		print(x[0], cnt, sep=' ')
		exit(0)
	cnt += 1
print('NO')


(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
ps = sorted(set(p))
dx = sorted([j - i for (i, j) in zip(x, x[1:])])
for i in ps:
	f = True
	for j in dx:
		if j % i:
			f = False
			break
	if f:
		print('YES')
		print(x[0], p.index(i) + 1)
		exit()
print('NO')


from functools import reduce
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))

def gcd(a, b):
	a = abs(a)
	b = abs(b)
	while b:
		(a, b) = (b, a % b)
	return a
xx = [x[i + 1] - x[i] for i in range(n - 1)]
ans = -1
g = reduce(gcd, xx)
for i in range(m):
	if g % p[i] == 0:
		ans = i
		break
if ans < 0:
	print('NO')
else:
	print('YES')
	print(x[0], ans + 1)


def primes(n):
	prim = []
	d = 2
	while d * d <= n:
		while n % d == 0:
			prim.append(d)
			n //= d
		d += 1
	if n > 1:
		prim.append(n)
	return prim

def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
dp = [x[i + 1] - x[i] for i in range(n - 1)]
g = dp[0]
for i in range(1, n - 1):
	g = gcd(g, dp[i])
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


(n, m) = map(int, input().split())
xrr = [int(x) for x in input().split()]
prr = [int(x) for x in input().split()]
xrr.sort()
gcd = xrr[1] - xrr[0]
for i in range(1, n - 1):
	u = gcd
	v = xrr[i + 1] - xrr[i]
	temp = 0
	while v:
		temp = u % v
		u = v
		v = temp
	gcd = u
for i in range(m):
	if gcd % prr[i] == 0:
		print('YES')
		print(xrr[0], i + 1)
		break
else:
	print('NO')


import fractions

def sv():
	(N, M) = map(int, input().split())
	gg = 0
	for (i, x) in enumerate(map(int, input().split())):
		if i == 0:
			initX = x
		else:
			gg = fractions.gcd(gg, x - lx)
		lx = x
	for (j, p) in enumerate(map(int, input().split())):
		if gg % p:
			continue
		print('YES')
		print('%d %d' % (initX, j + 1))
		return
	print('NO')
sv()


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

def gcd(a, b):
	if a == 0:
		return b
	if b == 0:
		return a
	if a > b:
		(a, b) = (b, a)
	return gcd(a, b % a)
gie = x[1] - x[0]
for i in range(2, n):
	gie = gcd(gie, x[i] - x[i - 1])
import sys
for i in range(m):
	if gie % p[i] == 0:
		print('YES')
		print(x[0], end=' ')
		print(i + 1)
		return
print('NO')


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(n, m) = map(int, input().split())
yes = False
x = list(map(int, input().split()))
p = list(map(int, input().split()))
temp = x[1] - x[0]
for i in range(2, n):
	temp = gcd(temp, x[i] - x[i - 1])
for i in range(m):
	if temp % p[i] == 0:
		yes = True
		print('YES')
		print(x[0], i + 1)
		break
if not yes:
	print('NO')


import math
import sys
t = 1
for _ in range(t):
	(n, m) = map(int, input().split())
	event = list(map(int, input().split()))
	intervals = list(map(int, input().split()))
	diff = []
	for i in range(1, n):
		diff.append(event[i] - event[i - 1])
	gcd = diff[0]
	for i in range(1, len(diff)):
		gcd = math.gcd(gcd, diff[i])
	ev = -1
	flag = False
	for i in range(m):
		if gcd % intervals[i] == 0:
			ev = i + 1
			flag = True
			break
	if flag:
		print('YES')
		print(event[0], ev)
	else:
		print('NO')


from math import gcd
(m, n) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
temp = a[1] - a[0]
for i in range(m - 1):
	temp = gcd(a[i + 1] - a[i], temp)
ans = True
for i in range(n):
	if temp % b[i] == 0:
		print('YES')
		print(a[0], i + 1)
		ans = False
		break
if ans:
	print('NO')


from math import gcd as g
from sys import stdin
(a, b) = map(int, stdin.readline().split())
z = list(map(int, stdin.readline().split()))
k = 0
for i in range(1, a):
	k = g(k, z[i] - z[i - 1])
for (i, j) in zip(map(int, stdin.readline().split()), range(1, b + 1)):
	if k % i == 0:
		print('YES')
		print(z[0], j)
		break
else:
	print('NO')


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

def ring_possible(n, m, event, times):
	if len(event) == 0:
		return ('YES', event[0], 1)
	mas = []
	for i in event[1:]:
		mas.append(i - event[0])
	if len(mas) > 1:
		unsv = gcd(mas[0], mas[1])
	else:
		unsv = mas[0]
	for el in mas[2:]:
		unsv = gcd(unsv, el)
	for (i, el) in enumerate(times):
		if unsv % el == 0:
			return ('YES', event[0], i + 1)
	return 'NO'
(n, m) = map(int, input().split())
event = list(map(int, input().split()))
times = list(map(int, input().split()))
result = ring_possible(n, m, event, times)
if result == 'NO':
	print(result)
else:
	print(result[0])
	print(result[1], result[2])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
a = l[1] - l[0]
b = l[-1] - l[0]
ll = []
for i in range(m):
	if a % l1[i] == 0 and b % l1[i] == 0:
		ll.append(i)
lol = 1
for j in ll:
	lol = 0
	for i in l:
		if (i - l[0]) % l1[j] != 0:
			lol = 1
			break
	if lol == 0:
		res = j
		break
if lol == 1:
	print('NO')
else:
	print('YES')
	print(l[0], res + 1)


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
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')
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
a = list(map(int, input().split()))
d = list()
for i in range(1, n):
	d.append(x[i] - x[i - 1])
d.sort()
ch = 1
g = d[0]
for i in range(n - 1):
	g = math.gcd(g, d[i])
d[0] = g
if ch == 0 and 1 not in a:
	print('NO')
elif 1 in a:
	j = 0
	for i in range(m):
		if a[i] == 1:
			j = i + 1
			break
	print('YES')
	print(1, j)
else:
	num = d[0]
	mm = d[0]
	ind = -1
	for i in range(m):
		if num % a[i] == 0:
			if a[i] <= mm:
				mm = a[i]
				ind = i + 1
	if ind == -1:
		print('NO')
	else:
		print('YES')
		c = x[0] % mm
		if c == 0:
			c = mm
		print(c, ind)


(n, m) = (int(i) for i in input().split())
X = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
g = X[0]
t = 0

def alg(a: int, b: int) -> int:
	if b > a:
		buf = a
		a = b
		b = buf
	if b == 0:
		return a
	else:
		return alg(b, a % b)
for i in range(n):
	X[i] = X[i] - g
	if not t and X[i] > 0:
		gcd = X[i]
for i in X:
	gcd = alg(gcd, i)
t = 0
for i in range(m):
	if gcd % P[i] == 0:
		t = 1
		pos = i + 1
		break
if t:
	print('YES')
	print(g, pos)
else:
	print('NO')


from math import gcd

def go():
	(n, m) = map(int, input().split(' '))
	x = [int(i) for i in input().split(' ')]
	p = [int(i) for i in input().split(' ')]
	diffs = set()
	start = x[0]
	for i in range(1, n):
		diffs.add(x[i] - x[i - 1])
	d = list(sorted(diffs))
	g = d[0]
	for i in range(1, len(d)):
		g = gcd(g, d[i])
	for i in range(m):
		if g % p[i] == 0:
			return 'YES\n{} {}'.format(start, i + 1)
	return 'NO'
print(go())


from math import gcd

def main():
	(n, m) = map(int, input().split())
	xs = list(map(int, input().split()))
	ps = list(map(int, input().split()))
	t = xs[1] - xs[0]
	for i in range(2, n):
		t = gcd(t, xs[i] - xs[i - 1])
	i = 0
	while i < m and t % ps[i] != 0:
		i += 1
	if i == m:
		print('NO')
		return
	print('YES')
	print(xs[0], i + 1)
main()


import sys
import math
input = sys.stdin.readline

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')
(n, m) = li()
x = li()
p = li()
x.sort()
temp = []
for i in range(1, n):
	temp.append(x[i] - x[i - 1])
currgcd = temp[0]
for i in temp[1:]:
	currgcd = math.gcd(currgcd, i)
for i in range(m):
	if not currgcd % p[i]:
		print('YES')
		print(min(x), i + 1)
		exit()
print('NO')


from math import *
(n, m) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
f = x[0]
for i in range(n):
	x[i] -= f
gc = 0
for i in x:
	gc = gcd(gc, i)
for i in range(m):
	if gc % p[i] == 0:
		print('YES')
		print(f, i + 1)
		exit()
print('NO')


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf, gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	p = list(map(int, input().split()))
	z = x[1] - x[0]
	for i in range(2, n):
		z = gcd(z, x[i] - x[i - 1])
	f = -1
	for i in range(m):
		if z % p[i] == 0:
			f = i + 1
			break
	if f == -1:
		print('NO')
	else:
		print('YES')
		print(x[0], f)
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')
main()


import sys
import math
input = sys.stdin.readline
(a, b) = map(int, input().split())
ar = list(map(int, input().split()))
br = list(map(int, input().split()))
cr = [0] * (a - 1)
ut = ar[1] - ar[0]
for i in range(a - 1):
	ut = math.gcd(ut, ar[i + 1] - ar[i])
for j in range(b):
	if ut % br[j] == 0:
		print('YES')
		print(ar[0], j + 1)
		break
else:
	print('NO')


def find_gcd(x, y):
	while x != 0 and y != 0:
		if x > y:
			x = x % y
		else:
			y = y % x
	return max(x, y)
iarr = list(map(int, input().split()))
n = iarr[0]
m = iarr[1]
arr = list(map(int, input().split()))
parr = list(map(int, input().split()))
darr = []
for i in range(n - 1):
	darr.append(arr[i + 1] - arr[i])
gcd = darr[0]
for i in range(1, n - 1):
	gcd = find_gcd(gcd, darr[i])
index = -1
for i in range(m):
	if gcd >= parr[i] and gcd % parr[i] == 0:
		index = i + 1
		break
if index == -1:
	print('NO')
else:
	print('YES')
	print(arr[0], index)


import math
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
p = list(map(int, input().split()))
y = x[0]
hcf = x[1] - x[0]
f = 0
for i in range(2, n):
	hcf = math.gcd(hcf, x[i] - x[i - 1])
for i in range(m):
	if hcf % p[i] == 0:
		print('YES')
		print(y, i + 1)
		f = 1
		break
if f == 0:
	print('NO')


from functools import reduce
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
T = list(map(int, input().split()))
for i in range(1, N):
	A[i] -= A[0]
g = reduce(gcd, A[1:])
for t in T:
	if g % t == 0:
		print('YES')
		print(A[0], T.index(t) + 1)
		exit()
print('NO')


import sys, math
(n, m) = map(int, sys.stdin.readline().split())
x = list(map(int, sys.stdin.readline().split()))
p = list(map(int, sys.stdin.readline().split()))
temp = []
for i in range(1, n):
	temp.append(x[i] - x[i - 1])
val = temp[0]
for i in range(1, len(temp)):
	val = math.gcd(val, temp[i])
for i in range(m):
	if val % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		sys.exit(0)
print('NO')


def STR():
	return list(input())

def INT():
	return int(input())

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

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

def gcd2(arr):
	k = arr[1] - arr[0]
	for i in range(2, len(arr)):
		k = gcd(k, arr[i] - arr[i - 1])
	return k
(n, m) = MAP()
x = LIST()
y = LIST()
if n == 1:
	print('YES')
	print(x[0], y[0])
	exit(0)
r = gcd2(x)
flag = False
z = -1
for i in range(len(y)):
	if r % y[i] == 0:
		z = i + 1
		flag = True
		break
if flag:
	print('YES')
	print(x[0], z)
else:
	print('NO')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
g = a[1] - a[0]
for i in range(1, n):
	d = a[i] - a[i - 1]
	if d % g != 0:
		g = math.gcd(d, g)
ind = -1
b = list(map(int, input().split()))
for i in range(m):
	if g % b[i] == 0:
		ind = i + 1
if ind == -1:
	print('NO')
else:
	print('YES')
	print(a[0], ind)


def gcd(x, y):
	if x % y == 0:
		return y
	return gcd(y, x % y)
l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
li = [int(i) for i in l]
li.sort()
l = []
for i in range(1, n):
	l.append(li[i] - li[i - 1])
z = l[0]
for i in l:
	z = gcd(z, i)
so = input().split()
set = [int(i) for i in so]
poss = 0
ans = 0
for i in range(m):
	if z % set[i] == 0:
		ans = i + 1
		poss = 1
		break
if poss:
	print('YES')
	print(li[0], ans)
else:
	print('NO')


from math import *
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
step = 0
for (prev, cur) in zip(x[:-1], x[1:]):
	step = gcd(step, cur - prev)
(y, j) = (10 ** 20, -1)
for i in range(m):
	val = p[i]
	if step % val == 0:
		newY = (x[0] - 1) % val + 1
		if newY < y:
			(y, j) = (newY, i + 1)
if j == -1:
	print('NO')
	exit(0)
print('YES\n', y, j)


def BMM(a, b):
	if a < b:
		(a, b) = (b, a)
	if b == 0:
		return a
	return BMM(b, a % b)
done = False
a = input().split()
n = int(a[0])
m = int(a[1])
a = input().split()
x = [0] * n
x[0] = int(a[0])
x[1] = int(a[1])
bmm = x[1] - x[0]
for i in range(2, n):
	x[i] = int(a[i])
	bmm = BMM(bmm, x[i] - x[i - 1])
a = input().split()
for i in range(m):
	if int(a[i]) == 1:
		print('Yes')
		print(x[0], i + 1)
		done = True
		break
	elif int(a[i]) <= bmm and bmm % int(a[i]) == 0:
		print('YES')
		print(x[0], i + 1)
		done = True
		break
if not done:
	print('NO')


import math
read = lambda : map(int, input().split())
(n, m) = read()
y = list(read())
p = list(read())
res = 0
for i in y[1:]:
	res = math.gcd(res, i - y[0])
max_el = 0
ansind = 0
for i in range(0, len(p)):
	if res % p[i] == 0:
		if p[i] > max_el:
			max_el = p[i]
			ansind = i
if max_el:
	print('YES')
	print(y[0], ansind + 1)
else:
	print('NO')


def nod(a, b):
	while a * b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
(n, m) = map(int, input().split())
l = [int(j) for j in input().split()]
p = [int(j) for j in input().split()]
nd = l[1] - l[0]
ans = -1
for i in range(2, n):
	nd = nod(nd, l[i] - l[i - 1])
for i in range(m):
	if nd % p[i] == 0:
		ans = i
		break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(l[0], ans + 1)


from math import gcd
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(n, m) = kk()
prev = -1
first = 0
gc = -1
for event in kk():
	if prev == -1:
		first = prev = event
		continue
	t = event - prev
	gc = t if gc == -1 else gcd(gc, t)
	prev = event
for (i, option) in enumerate(kk()):
	if gc % option == 0:
		print('YES')
		print(first, i + 1)
		exit()
print('NO')


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

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

def main():
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	p = list(map(int, input().split()))
	tx = []
	for i in range(1, n):
		tx.append(x[i] - x[i - 1])
	lc = tx[0]
	for i in range(1, n - 1):
		lc = gcd(lc, tx[i])
	if lc in p:
		print('YES')
		print(x[0], p.index(lc) + 1)
	else:
		for i in range(m):
			if p[i] < lc and lc % p[i] == 0:
				print('YES')
				print(x[0], i + 1)
				exit()
		print('NO')
main()


import math

def arr_gcd(arr):
	gcd = arr[0]
	for i in range(1, len(arr)):
		gcd = math.gcd(gcd, arr[i])
	return gcd

def main():
	(n, m) = map(int, input().split())
	(x, p) = (list(map(int, input().split())), list(map(int, input().split())))
	if n == 1:
		print('YES\n{} 1'.format(x[0]))
		return
	gcd = arr_gcd([x[i] - x[i - 1] for i in range(1, n)])
	good_p = [i + 1 for i in range(m) if gcd % p[i] == 0]
	print('YES\n{0} {1}'.format(x[0], good_p[0]) if good_p else 'NO')
main()


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(n, m) = map(int, input().split())
t = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
a = []
sa = t[0]
f = 0
for i in range(n - 1):
	a.append(t[i + 1] - t[i])
g = a[0]
for i in range(1, len(a)):
	g = gcd(g, a[i])
for i in range(m):
	if g % p[i] == 0:
		j = i + 1
		f = 1
		break
if f == 0:
	print('NO')
else:
	print('YES')
	print(sa, j)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
dx = [x[i] - x[i - 1] for i in range(1, n)]
mind = min(dx)
sx = set(dx)
for i in range(m):
	f = True
	for j in sx:
		if j % p[i] != 0:
			f = False
			break
	if f:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import math
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
p = list(map(int, input().split()))
y = x[0]
hcf = x[1] - x[0]
f = 0
for i in range(2, n):
	hcf = math.gcd(hcf, x[i] - x[i - 1])
for i in range(m):
	if hcf % p[i] == 0:
		print('YES')
		print(y, i + 1)
		f = 1
		break
if f == 0:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
g = a[1] - a[0]
for i in range(n - 1):
	g = gcd(g, a[i + 1] - a[i])
f = -1
for i in range(len(b)):
	if g % b[i] == 0:
		f = i
		break
if f == -1:
	print('NO')
else:
	print('YES')
	print(a[0], i + 1)


from sys import stdin, stdout
(N, M) = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
candidate = [int(x) for x in stdin.readline().split()]

def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
d = []
for i in range(1, N):
	diff = arr[i] - arr[i - 1]
	d.append(diff)
res = d[0]
for i in range(1, N - 1):
	res = computeGCD(d[i], res)
for i in range(M):
	if res % candidate[i] == 0:
		print('YES')
		print(arr[0], i + 1)
		quit()
print('NO')


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = input().split()
times = list(map(int, input().split()))
durs = list(map(int, input().split()))
d = []
for i in range(len(times) - 1):
	d.append(times[i + 1] - times[0])
num1 = d[0]
num2 = 1
if len(d) > 1:
	num2 = d[1]
	gcd = find_gcd(num1, num2)
else:
	gcd = num1
for i in range(2, len(d)):
	gcd = find_gcd(gcd, d[i])
print_no = True
for j in range(len(durs)):
	if gcd % durs[j] == 0:
		print('YES')
		print(str(times[0]) + ' ' + str(j + 1))
		print_no = False
		break
if print_no:
	print('NO')


def gcd(a, b):
	b = abs(b)
	while b != 0:
		r = a % b
		(a, b) = (b, r)
	return a
(N, M) = map(int, input().split())
X = [int(a) for a in input().split()]
P = [int(a) for a in input().split()]
g = 0
for i in range(N - 1):
	g = gcd(g, X[i] - X[i + 1])
for i in range(M):
	if g % P[i] == 0:
		print('YES')
		print(X[0], i + 1)
		break
else:
	print('NO')


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import *
from itertools import *
import functools
import sys
from math import *
import random
import re
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN(x=' '):
	return map(int, sys.stdin.readline().strip().split(x))

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN():
	return list(numIN())

def dis(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
		if meh < 0:
			meh = 0
	return msf

def res(ans, t):
	print('Case #{}: {}'.format(t, ans))
(n, m) = numIN()
x = arrIN()
p = arrIN()
g = 0
for i in range(1, n):
	g = gcd(g, x[i] - x[i - 1])
for i in range(m):
	if p[i] == g or g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit(0)
print('NO')


from math import gcd
from functools import reduce
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ps = list(map(int, input().split()))

def func(arr, ps):
	diffs = []
	for i in range(len(arr) - 1):
		diffs.append(arr[i + 1] - arr[i])
	g = reduce(gcd, diffs)
	for (i, p) in enumerate(ps):
		if g % p == 0:
			return i + 1
	return False
res = func(arr, ps)
if res:
	print('YES')
	print(arr[0], res)
else:
	print('NO')


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m) = mapin()
x = listin()
p = listin()
z = []
for i in range(1, n):
	z.append(x[i] - x[i - 1])
key = z[0]
for i in z:
	key = math.gcd(key, i)
index = 0
for i in range(m):
	if key % p[i] == 0:
		index = i + 1
		break
if index:
	print('YES')
	print(x[0], index)
else:
	print('NO')


from math import gcd
from functools import reduce

def solve():
	input()
	x = list(map(int, input().split()))
	dx = [t - s for (s, t) in zip(x, x[1:])]
	p = list(map(int, input().split()))
	d = reduce(gcd, dx)
	for i in range(len(p)):
		if d % p[i] == 0:
			print('YES')
			print(f'{x[0]} {i + 1}')
			return
	print('NO')
	return
solve()


__version__ = '0.3'
__date__ = '2019-04-23'
import sys

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

def solve(n, m, x, p):
	y = x[:]
	for i in range(1, n):
		y[i] -= x[i - 1]
	alarm_gcd = y[1]
	for i in range(2, n):
		alarm_gcd = gcd(alarm_gcd, y[i])
		if alarm_gcd == 1:
			break
	for j in range(m):
		if alarm_gcd % p[j] == 0:
			return j + 1
	return -1

def main(argv=None):
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	p = list(map(int, input().split()))
	answer = solve(n, m, x, p)
	if answer > 0:
		print('YES')
		print('{0} {1}'.format(x[0], answer))
	else:
		print('NO')
	return 0
STATUS = main()
sys.exit(STATUS)


import sys
from functools import reduce
from heapq import heappush, heappop, heapify
sys.setrecursionlimit(int(10000000.0))
intinput = lambda : list(map(int, input().split()))

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

def main():
	(n, m) = intinput()
	X = intinput()
	P = intinput()
	D = [X[i] - X[0] for i in range(1, n)]
	if len(D) == 0:
		D.append(0)
	d = reduce(gcd, D)
	(_, p) = min([(P[i], i) for i in range(m) if d % P[i] == 0] + [(float('inf'), m)])
	if p == m:
		print('NO')
	else:
		print('YES')
		print(X[0], p + 1)
	return
while 1:
	try:
		main()
	except EOFError:
		break


from math import *
(n, m) = map(int, input().split())
lx = list(map(int, input().split()))
lp = list(map(int, input().split()))
g = lx[1] - lx[0]
k = 0
for i in range(1, n - 1):
	g = gcd(g, lx[i + 1] - lx[i])
for i in range(m):
	if g % lp[i] == 0:
		print('YES')
		print(lx[0], i + 1)
		k = 1
		break
if k == 0:
	print('NO')


from functools import reduce

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
(n, m) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
diff = []
for i in range(1, len(x)):
	diff.append(x[i] - x[i - 1])
gc = reduce(gcd, diff)
ok = 0
val = 0
for i in range(len(arr)):
	if gc % arr[i] == 0:
		ok = 1
		pos = i
		break
if not ok:
	print('NO')
else:
	print('YES')
	print(min(x), pos + 1)


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
g = x[1] - x[0]
for i in range(1, n - 1):
	g = gcd(g, x[i + 1] - x[i])
for i in range(m):
	if g % y[i] == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


from sys import stdin
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from math import ceil, sqrt, gcd, factorial
(n, m) = mp()
x = mp()
y = mp()
gc = 0
for i in range(1, n):
	gc = gcd(gc, x[i] - x[i - 1])
for i in range(m):
	if gc % y[i] == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


import sys

def gcd(a, b):
	while a and b:
		if a >= b:
			a %= b
		else:
			b %= a
	return a | b
(n, m) = [int(s) for s in input().split()]
time = [int(s) for s in input().split()]
p = [int(s) for s in input().split()]
diffs = []
for i in range(len(time) - 1):
	diffs.append(time[i + 1] - time[i])
ans = max(diffs)
for i in range(len(diffs)):
	ans = gcd(ans, diffs[i])
for i in range(len(p)):
	if ans % p[i] == 0:
		print('YES')
		print(time[0], i + 1)
		return
print('NO')


def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)
(n, m) = map(int, input().split())
x = [int(x) for x in input().split()]
p = [int(p) for p in input().split()]
g = 0
for i in range(n - 1):
	g = gcd(g, x[i + 1] - x[i])
an = -1
for i in range(m):
	if g % p[i] == 0:
		an = i
		break
if an == -1:
	print('NO')
else:
	print('YES')
	print(x[0], an + 1)


def calgcd(a, b):
	while a != 0 and b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return max(a, b)
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
kc = x[1] - x[0]
for i in range(1, len(x)):
	kc = calgcd(kc, x[i] - x[i - 1])
for i in range(len(p)):
	if kc % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit(0)
print('NO')


from math import gcd
from functools import reduce
(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
s = [x[i + 1] - x[i] for i in range(n - 1)]
g = reduce(gcd, s)
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


from fractions import Fraction
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
t = x[n - 1] - x[0]
done = False
for j in range(m):
	found = True
	if t % p[j] != 0:
		found = False
	if found:
		for i in range(n - 1):
			if x[i] % p[j] != x[i + 1] % p[j]:
				found = False
				break
	if found:
		done = True
		print('YES')
		r = x[0] % p[j]
		if r == 0:
			r = p[j]
		print(r, j + 1)
		break
if not done:
	print('NO')


import math
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
d = [x[i + 1] - x[i] for i in range(n - 1)]
gc = d[0]
for i in d:
	gc = math.gcd(gc, i)
for i in range(m):
	if gc % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


import math
(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
p = list(map(int, input().split()))
l = 10 ** 18 + 1
x = lis[0]
for i in range(n - 1):
	lis[i] = lis[i + 1] - lis[i]
g = lis[0]
for i in range(1, n - 1):
	g = math.gcd(g, lis[i])
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(x, i + 1)
		break
else:
	print('NO')


import math
(n, m) = map(int, input().split())
z = list(map(int, input().split()))
pos = list(map(int, input().split()))
if len(z) == 1:
	print('YES')
	print(z[0], pos[0])
	exit()
else:
	diff = []
	for i in range(1, len(z)):
		diff.append(z[i] - z[i - 1])
	gc = diff[0]
	for i in range(1, len(diff)):
		gc = math.gcd(gc, diff[i])
	for i in range(len(pos)):
		if gc % pos[i] == 0:
			print('YES')
			print(z[0], i + 1)
			exit()
print('NO')


from math import gcd
a = []
(n, m) = map(int, input().split())
x = [int(s) for s in input().split()]
p = [int(s) for s in input().split()]
for i in range(len(x) - 1):
	a.append(x[i + 1] - x[i])
a = sorted(a)
if len(a) == 1 and a[0] == 0:
	print('NO')
	exit()
elif len(a) == 1:
	t = a[0]
else:
	t = a[0]
	for i in range(len(a) - 1):
		t = gcd(t, a[i + 1])
for i in range(len(p)):
	if p[i] == t or t % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


from math import gcd
(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
k = []
g = 0
for i in range(1, n):
	k.append(l1[i] - l1[i - 1])
for i in k:
	g = gcd(g, i)
flag = 0
va = []
ans = 0
for i in range(m):
	if g % l2[i] == 0:
		ans = i + 1
		flag = 1
		break
if flag == 1:
	print('YES')
	print(l1[0], ans)
else:
	print('NO')


import sys
lines = sys.stdin.readlines()

def parse_inp(idx):
	return list(map(int, lines[idx].split(' ')))

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(x, y) = parse_inp(0)
events = parse_inp(1)
ds = parse_inp(2)
ap = -1
poss = True
for idx in range(1, len(events)):
	diff = events[idx] - events[idx - 1]
	if ap == -1:
		ap = diff
		continue
	ap = gcd(diff, ap)
ans1 = ans2 = -1
for (idx, d) in enumerate(ds):
	if ap % d == 0 and (ans2 > d or ans2 == -1):
		ans2 = d
		idx2 = idx
if ans2 == -1:
	print('NO')
	exit(0)
mini = events[0]
print('YES')
print('{} {}'.format(mini, idx2 + 1))


from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
l = [0] * n
l[0] = x[0]
for i in range(1, n):
	l[i] = x[i] - x[i - 1]
if n >= 3:
	cm = gcd(l[1], l[2])
	for i in range(3, n):
		cm = gcd(cm, l[i])
	flag = 0
	for i in range(m):
		if cm % p[i] == 0:
			flag = 1
			print('YES')
			print(x[0], i + 1)
			break
	if flag == 0:
		print('NO')
else:
	flag = 1
	for i in range(m):
		if (x[1] - x[0]) % p[i] == 0:
			flag = 0
			print('YES')
			print(x[0], i + 1)
			break
	if flag == 1:
		print('NO')


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
p = list(map(int, input().split()))
diffs = []
for i in range(n - 1):
	diffs.append(x[i + 1] - x[i])

def mcd(a, b):
	if b > a:
		c = a
		a = b
		b = c
	while 1:
		r = a % b
		if r == 0:
			return b
		else:
			a = b
			b = r

def nod_array(arr):
	result = arr[0]
	for i in range(n - 2):
		nod = mcd(result, arr[i + 1])
		if nod == 1:
			return 1
		else:
			result = nod
	return result
T = nod_array(diffs)
D = -1
for i in range(m):
	if T % p[i] == 0:
		D = i + 1
		break
if D == -1:
	print('No')
else:
	print('Yes')
	print(x[0], D)


def gcd(m, n):
	if n > m:
		return gcd(n, m)
	elif n > 0:
		return gcd(n, m % n)
	else:
		return m
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
st = x[0]
for i in range(len(x) - 1):
	x[i] = x[i + 1] - x[i]
if n == 2:
	for i in range(len(y)):
		if x[0] % y[i] == 0:
			print('YES')
			print(st, i + 1)
			exit()
else:
	g = gcd(x[0], x[1])
	for i in range(2, len(x) - 1):
		g = gcd(g, x[i])
	for i in range(len(y)):
		if g % y[i] == 0:
			print('YES')
			print(st, i + 1)
			exit()
print('NO')


t = input().split()
(n, m) = (int(t[0]), int(t[1]))
_xx = input().split()
_xx = [int(_i) for _i in _xx]
_pp = input().split()
_pp = [int(_i) for _i in _pp]
from math import gcd

def get_gcd(elements):
	result = elements[0]
	for i in elements[1:]:
		if result == 1:
			return 1
		result = gcd(result, i)
	return result

def solve(xx, pp):
	diffs = list()
	for i in range(0, n - 1):
		diffs.append(xx[i + 1] - xx[i])
	gcd = get_gcd(diffs)
	for (index, p) in enumerate(pp):
		if p > gcd or gcd % p:
			continue
		initial = xx[0]
		if p >= initial:
			y = initial
		else:
			reminder = initial % p
			y = reminder if reminder else p
		print('YES')
		print('{0} {1}'.format(y, index + 1))
		return
	print('NO')
solve(_xx, _pp)


from math import gcd
from functools import reduce
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
d = reduce(gcd, map(lambda a, b: b - a, x, x[1:]))
for (i, v) in enumerate(map(int, input().split())):
	if d % v == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


import math
(N, M) = [int(i) for i in input().split()]
minute = [int(i) for i in input().split()]
interlude = [int(i) for i in input().split()]
short_break = minute[1] - minute[0]
first = minute[0]
for second in minute[1:]:
	short_break = math.gcd(second - first, short_break)
	first = second
check = False
for i in range(M):
	if short_break % interlude[i] == 0:
		check = True
		index = i + 1
		break
if check:
	print('YES')
	print(minute[0], index)
else:
	print('NO')


from math import gcd
(numberOfEvents, numberOfIntervals) = map(int, input().split())
events = list(map(int, input().split()))
intervals = list(map(int, input().split()))
firstTime = events[0]
currMult = 1
eventsNormalized = [i - firstTime for i in events]
if len(events) > 1:
	maxFactor = eventsNormalized[1]
	for i in eventsNormalized:
		if i == 0:
			continue
		elif i % maxFactor:
			maxFactor = gcd(i, maxFactor)
else:
	maxFactor = 1
for i in range(len(intervals)):
	if maxFactor % intervals[i] == 0:
		print('YES')
		print(str(firstTime) + ' ' + str(i + 1))
		break
	if i == len(intervals) - 1:
		print('NO')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
x = X[1] - X[0]
for i in range(1, n):
	x = gcd(x, X[i] - X[0])
for i in range(m):
	if x % P[i] == 0:
		print('YES')
		print(X[0], i + 1)
		sys.exit()
print('NO')


def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = list(map(int, input().split()))
z = list(map(int, input().split()))
c = list(map(int, input().split()))
len_c = len(c)
tmp = []
for i in range(n - 1):
	tmp.append(z[i + 1] - z[i])
s = tmp[0]
for i in range(len(tmp) - 1):
	s = computeGCD(s, tmp[i + 1])
true = 0
for i in range(len_c):
	if s % c[i] == 0:
		print('YES')
		print(z[0], i + 1)
		true = 1
		break
if true == 0:
	print('NO')


def gcd(a, b):
	if a > b:
		(a, b) = (b, a)
	if a == 0 or a == b:
		return b
	return gcd(b % a, a)
(n, m) = (int(x) for x in input().split())
x = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
diff = x[1] - x[0]
solparz = 'YES\n' + str(x[0]) + ' '
for i in range(1, n - 1):
	diff = gcd(diff, x[i + 1] - x[i])
for j in range(m):
	if diff % p[j] == 0:
		solparz += str(j + 1)
		break
if solparz[-1] == ' ':
	print('NO')
else:
	print(solparz)


def gcd(a, b):
	while b:
		a = a % b
		(a, b) = (b, a)
	return a
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
nod = x[1] - x[0]
for i in range(2, n):
	nod = gcd(x[i] - x[i - 1], nod)
for (i, y) in enumerate(p):
	if nod % y == 0:
		print('YES')
		print(x[0], i + 1)
		from sys import exit
		exit()
print('NO')


(a, b) = map(int, input().split())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
lis = [j - i for (i, j) in zip(s1, s1[1:])]
import math
gcd = lis[0]
for i in lis:
	gcd = math.gcd(i, gcd)
for i in range(len(s2)):
	if gcd % s2[i] == 0:
		print('YES')
		print(s1[0], i + 1)
		exit()
print('NO')


from math import *

def gcd_of_list(li):
	if len(li) == 1:
		return li[0]
	elif len(li) == 2:
		return gcd(li[0], li[1])
	g = gcd(li[0], li[1])
	for i in range(2, len(li)):
		g = gcd(g, li[i])
	return g
(n, m) = input().split()
(n, m) = (int(n), int(m))
lix = list(map(int, input().split()))
lip = list(map(int, input().split()))
p = lix[0]
q = 0
lig = []
for i in range(1, n):
	lig.append(lix[i] - lix[i - 1])
ap = gcd_of_list(lig)
for j in range(m):
	if ap % lip[j] == 0:
		q = j + 1
		print('YES')
		print(p, q)
		exit(0)
print('NO')


import math
(m, n) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
y = a[0]
p = a[1] - a[0]
for i in range(1, m - 1):
	p = math.gcd(p, a[i + 1] - a[i])
f = 0
for j in range(n):
	if p % b[j] == 0:
		q = j + 1
		f = 1
		break
if f == 0:
	print('NO')
else:
	print('YES')
	print(y, q)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 1000000007
mini = 1000000007

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def solve(n):
	if n == 1:
		return 1
	p = 2
	result = []
	while p * p <= n:
		if n % p == 0:
			result.append(p)
			result.append(n // p)
		p = p + 1
	return result

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

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

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
X = get_array()
P = get_array()
g = X[1] - X[0]
for i in range(2, n):
	k = X[i] - X[i - 1]
	g = gcd(k, g)
index = 0
flag = 0
for i in range(m):
	if P[i] == g or g % P[i] == 0:
		index = i + 1
		flag = 1
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	print(X[0], index)


import math
import functools
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
intervals = list(map(int, input().split()))
diff = []
for i in range(n - 1):
	diff.append(arr[i + 1] - arr[i])
hcf = functools.reduce(lambda x, y: math.gcd(x, y), diff)
for (i, el) in enumerate(intervals):
	if hcf % el == 0:
		print('YES')
		print('%s %s' % (arr[0], i + 1))
		exit(0)
print('NO')


from collections import Counter
from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
x.sort()
k = x[0]
if n == 1:
	print('YES')
	print(k, 1)
	quit()
x = [i - k for i in x]
x = x[1:]
if n == 2:
	for i in range(m):
		if x[0] % p[i] == 0:
			print('YES')
			print(k, i + 1)
			quit()
	print('NO')
	quit()
l = gcd(x[0], x[1])
for i in range(2, n - 1):
	l = gcd(l, x[i])
for i in range(m):
	if l % p[i] == 0:
		print('YES')
		print(k, i + 1)
		quit()
print('NO')


import math
inp = lambda cast=int: list(map(cast, input().split()))
(n, m) = inp()
A = inp()
B = inp()
g = None
mini = min(A)
for a in A:
	if a != mini:
		a = a - mini
		g = math.gcd(g, a) if g else a
for i in range(m):
	if not g or g % B[i] == 0:
		print('YES')
		print(mini, i + 1)
		break
else:
	print('NO')


import math
(n, m) = map(int, input().split())
s = list(map(int, input().split()))
l = list(map(int, input().split()))
g = 0
for i in range(1, n):
	g = math.gcd(s[i] - s[i - 1], g)
	if g == 1:
		break
p = 0
for i in range(m):
	if g % l[i] == 0:
		p = 1
		print('YES')
		print(s[0], i + 1)
		break
if p == 0:
	print('NO')


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
(n, m) = f(1)
cl = f(2)
pl = f(2)
diff = []
for i in range(n - 1):
	diff.append(cl[i + 1] - cl[i])
mod = diff[0]
for i in range(n - 1):
	if diff[i] % mod != 0:
		mod = math.gcd(diff[i], mod)
		if mod == 1:
			break
for i in range(m):
	if mod % pl[i] == 0:
		print('YES')
		print(cl[0], i + 1)
		exit()
print('NO')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(n, m) = map(int, input().split())
li1 = list(map(int, input().split()))
li2 = list(map(int, input().split()))
ans = li1[1] - li1[0]
for i in range(2, n):
	ans = gcd(li1[i] - li1[i - 1], ans)
flag = 0
for j in range(m):
	if ans % li2[j] == 0:
		flag = 1
		print('YES')
		print(li1[0], j + 1)
		break
if flag == 0:
	print('NO')


import math
(n, m) = list(map(int, input().split()))
x = input().split()
x = [int(xi) for xi in x]
p = input().split()
p = [int(pi) for pi in p]
gcds = x[1] - x[0]
for i in range(2, n):
	gcds = math.gcd(gcds, x[i] - x[i - 1])
for i in range(m):
	if gcds % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		return
print('NO')


def GCD(x, y):
	if y == 0:
		return x
	else:
		return GCD(y, x % y)

def main():
	(n, m) = map(int, input().split())
	data = list(map(int, input().split()))
	interval = list(map(int, input().split()))
	time = set()
	g = 0
	for i in range(1, len(data)):
		time.add(data[i] - data[0])
	for el in time:
		g = GCD(g, el)
	for i in range(len(interval)):
		if g % interval[i] == 0:
			print('YES')
			print(str(data[0]) + ' ' + str(i + 1))
			return
	print('NO')
main()


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = 1

def solve():
	for i in range(m):
		if g % l2[i] == 0:
			return i + 1
	return -1
for _ in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for i in range(1, n):
		if i == 1:
			g = l1[i] - l1[i - 1]
		else:
			g = mt.gcd(g, l1[i] - l1[i - 1])
	ch = solve()
	if ch != -1:
		print('YES')
		print(l1[0], ch)
	else:
		print('NO')


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = []
for i in range(1, len(a)):
	c.append(a[i] - a[i - 1])

def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
s = c[0]
for i in range(1, len(c)):
	s = computeGCD(s, c[i])
t = 0
for i in range(len(b)):
	if s % b[i] == 0:
		t = 1
		ans = i + 1
		break
if t == 0:
	print('NO')
else:
	print('YES')
	print(a[0], ans)


from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
g = x[1] - x[0]
for i in range(2, n):
	g = gcd(g, x[i] - x[i - 1])
	if g == 1:
		break
for j in range(m):
	if g % p[j] == 0:
		print('YES')
		print(x[0], j + 1)
		break
else:
	print('NO')


from fractions import gcd
from functools import reduce
import sys
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
x_ = [i - x[0] for i in x]
g = reduce(gcd, x_[1:])
for i in p:
	if g % i == 0:
		print('YES\n%d %d' % (x[0], p.index(i) + 1))
		break
else:
	print('NO')


from sys import stdin, stdout
from bisect import bisect_right as br
from bisect import bisect_left as bl
from bisect import insort_left as il
from math import gcd
yes = False
(n, m) = map(int, stdin.readline().split())
t = [int(i) for i in stdin.readline().split()]
diff = []
ch = [int(i) for i in stdin.readline().split()]
for i in range(0, len(t) - 1):
	diff += [t[i + 1] - t[i]]
com = diff[0]
for i in diff[1:]:
	com = gcd(com, i)
k = 1
for i in ch:
	if gcd(com, i) == i:
		yes = True
		break
	k += 1
if yes:
	stdout.write('YES' + '\n')
	stdout.write(str(t[0]) + ' ' + str(k))
else:
	stdout.write('NO')


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

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

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

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

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

def string_list():
	return list(input())

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

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	(n, m) = num_input()
	a = list_input()
	b = list_input()
	first = a[0]
	g = 0
	for i in range(1, n):
		g = math.gcd(g, a[i] - first)
	for i in range(m):
		if g % b[i] == 0:
			print('YES')
			print(first, i + 1)
			return
	print('NO')
t = 1
for _ in range(t):
	solve()


from sys import stdin
import math
from collections import defaultdict, deque
import bisect
I = stdin.readline
(n, m) = map(int, I().split())
x = [int(y) for y in I().split()]
p = [int(x) for x in I().split()]
diff = []
for i in range(1, n):
	diff.append(x[i] - x[i - 1])
if n == 2:
	ans = -1
	for i in range(len(p)):
		if diff[0] % p[i] == 0:
			ans = i + 1
			break
	if ans != -1:
		print('YES')
		print(x[0], ans)
	else:
		print('NO')
else:
	g = math.gcd(diff[0], diff[1])
	for i in range(2, len(diff)):
		g = math.gcd(g, diff[i])
	ans = -1
	for i in range(len(p)):
		if g % p[i] == 0:
			ans = i + 1
			break
	if ans != -1:
		print('YES')
		print(x[0], ans)
	else:
		print('NO')


(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
diff = [x[i] - x[i - 1] for i in range(1, n)]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
gc = diff[0]
for i in diff:
	gc = gcd(i, gc)
idx = -1
for i in range(m):
	if gc % p[i] == 0:
		idx = i
		break
if idx != -1 and x[0] % gc == 0:
	print('YES')
	print(x[0], idx + 1)
elif idx != -1:
	print('YES')
	print(x[0] % gc, idx + 1)
else:
	print('NO')


def gcd(a, b):
	(min_ab, max_ab) = (min(a, b), max(a, b))
	while min_ab != 0:
		(min_ab, max_ab) = (max_ab % min_ab, min_ab)
	return max_ab

def bulk_gcd(xs):
	for i in range(len(xs) - 1):
		xs[i + 1] = gcd(xs[i], xs[i + 1])
	return xs[-1]
(n, m) = [int(x) for x in input().split()]
xs = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]
y = xs[0]
xs_gcd = bulk_gcd([x - y for x in xs[1:]])
for j in range(len(ps)):
	if xs_gcd % ps[j] == 0:
		print('YES')
		print(y, j + 1)
		break
else:
	print('NO')


from math import *
(n, m) = map(int, input().split())
ls = list(map(int, input().split()))
a = ls[0]
ls.sort()
diff = []
for i in range(n - 1):
	diff.append(ls[i + 1] - ls[i])
GCD = 0
for i in diff:
	GCD = gcd(GCD, i)
ls = list(map(int, input().split()))
for i in range(m):
	if GCD % ls[i] == 0:
		print('YES')
		y = a % ls[i]
		if y == 0:
			y = ls[i]
		print(y, i + 1)
		break
else:
	print('NO')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

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

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

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))
(n, m) = inpl()
x = inpl()
p = inpl()
g = x[1] - x[0]
for i in range(1, n - 1):
	g = math.gcd(g, x[i + 1] - x[i])
for (i, y) in enumerate(p):
	if g % y == 0:
		print('YES')
		print(x[0], i + 1)
		break
else:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
z = []
g = 0
for i in range(1, n):
	g = gcd(g, a[i] - a[0])
for i in range(m):
	if g % b[i] == 0:
		print('YES')
		print(a[0], i + 1)
		exit(0)
print('NO')


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))
a = 0
for i in range(1, n):
	a = gcd(a, X[i] - X[i - 1])
f = 0
for i in range(m):
	if a % P[i] == 0:
		print('YES')
		print(X[0], i + 1)
		f = 1
		break
if f == 0:
	print('NO')


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
d = [x[i] - x[i - 1] for i in range(1, n)]

def gcd(a, b):
	if a == b:
		return a
	if a < b:
		return gcd(b, a)
	if b == 0:
		return a
	return gcd(a % b, b)
z = d[0]
for i in d:
	z = gcd(z, i)
a = []
f = False
for i in range(m):
	if z % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		f = True
		break
if not f:
	print('NO')


from math import gcd
input()
x = list(map(int, input().split()))
p = list(map(int, input().split()))
if len(x) == 1:
	gc = x[0]
elif len(x) == 2:
	gc = x[1] - x[0]
else:
	gc = gcd(x[1] - x[0], x[2] - x[1])
	for i in range(3, len(x)):
		gc = gcd(gc, x[i] - x[i - 1])
if 1 in p:
	print('YES')
	print(x[0], p.index(1) + 1)
else:
	for i in range(len(p)):
		if gc % p[i] == 0:
			print('YES')
			print(x[0], i + 1)
			exit()
	print('NO')


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

def main():
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	p = list(map(int, input().split()))
	diff = [x[i] - x[i - 1] for i in range(1, n)]
	g = diff[0]
	for i in range(n - 1):
		g = gcd(g, diff[i])
	y = float('inf')
	r = None
	for i in range(m):
		if g % p[i] == 0:
			k = (x[1] - 1) // p[i]
			t = x[1] - k * p[i]
			if y > t:
				y = t
				r = i + 1
	if r != None:
		print('YES')
		print(y, r)
	else:
		print('NO')
main()


import math
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
diff = []
for i in range(n - 1):
	diff.append(x[i + 1] - x[i])
gcd = diff[0]
for i in range(n - 2):
	gcd = math.gcd(gcd, diff[i + 1])
ans = 0
for i in range(m):
	if gcd % p[i] == 0:
		ans = i + 1
		break
if ans == 0:
	print('NO')
else:
	print('YES')
	print(x[0], ans)


from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
found = False
gccd = x[1] - x[0]
for i in range(1, n):
	gccd = gcd(gccd, x[i] - x[i - 1])
for i in range(m):
	if gccd % y[i] == 0:
		print('YES')
		print(x[0], i + 1)
		found = True
		break
if not found:
	print('NO')


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
k = 0
(n, m) = map(int, input().split())
alarm = list(map(int, input().split()))
inter = list(map(int, input().split()))
z = alarm[0]
for i in range(len(alarm)):
	alarm[i] = alarm[i] - z
num1 = alarm[0]
num2 = alarm[1]
gcd = find_gcd(num1, num2)
for i in range(2, len(alarm)):
	gcd = find_gcd(gcd, alarm[i])
for i in range(len(inter)):
	if gcd % inter[i] == 0:
		print('YES')
		print(z, i + 1)
		k = 1
		break
if k == 0:
	print('NO')


def nod(a, b):
	while a != 0 and b != 0:
		if a > b:
			a = a % b
		else:
			b = b % a
	return max(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(a[0], 1)
else:
	mnod = a[1] - a[0]
	p = 'NO'
	inod = 0
	for i in range(n - 2):
		mnod = nod(mnod, a[i + 2] - a[i + 1])
	for j in range(m):
		if mnod % b[j] == 0:
			p = 'YES'
			inod = j + 1
			break
	print(p)
	if p == 'YES':
		print(a[0], inod)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
a = list(map(int, input().split()))
dif = []
for i in range(1, n):
	dif.append(l[i] - l[i - 1])
cur = dif[0]
for i in range(n - 1):
	cur = gcd(dif[i], cur)
for i in range(m):
	if cur % a[i] == 0:
		print('YES')
		print(l[0], i + 1)
		exit()
print('NO')


import math
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = list(map(int, input().split()))
p = sorted(list(set(a)))
g = l[1] - l[0]
for i in range(1, n):
	f = math.gcd(l[i] - l[i - 1], g)
	if f < g:
		g = f
d = 0
for i in p:
	if g % i == 0:
		print('YES')
		print(l[0], a.index(i) + 1)
		d = 1
		break
	if i > g:
		break
if d == 0:
	print('NO')


def pgcd(a, b):
	if b == 0:
		return a
	else:
		r = a % b
		return pgcd(b, r)
(n, e) = map(int, input().split())
events = list(map(int, input().split()))
settings = list(map(int, input().split()))
r = -1
for k in range(0, len(events) - 1):
	if r == -1:
		r = events[k + 1] - events[k]
	else:
		r = pgcd(r, events[k + 1] - events[k])
ok = 0
for k in range(len(settings)):
	if r % settings[k] == 0:
		print('YES')
		print(events[0], k + 1)
		ok = 1
		break
if not ok:
	print('NO')


import math
(n, m) = [int(x) for x in input().split()]
events = [int(x) for x in input().split()]
options = [int(x) for x in input().split()]
g = events[1] - events[0]
for i in range(1, n - 1):
	g = math.gcd(g, events[i + 1] - events[i])
for j in range(m):
	if g % options[j] == 0:
		print('YES')
		print('{} {}'.format(events[0], j + 1))
		exit()
print('NO')


(n, m) = list(map(int, input().split()))
u = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(1, n):
	u[i] -= u[0]
h = u[0]
u[0] = 0

def gsd(a, b):
	(a, b) = (max(a, b), min(a, b))
	if b == 0:
		return a
	return gsd(b, a % b)
for i in range(1, n):
	u[i] = gsd(u[i], u[i - 1])
for i in range(m):
	if u[-1] % p[i] == 0:
		print('YES')
		print(h, i + 1)
		return
print('NO')


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
from math import log10, log2, ceil, factorial as f, gcd
from functools import reduce
(n, m) = ll()
a = list(ll())
p = list(ll())
l = []
st = min(a)
for i in range(1, n):
	l.append(a[i] - a[i - 1])
g = reduce(lambda a, b: gcd(a, b), l)
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(st, i + 1)
		break
else:
	print('NO')


import sys
from math import gcd

class CAlarmClocksEverywhere:

	def solve(self):
		(n, m) = [int(_) for _ in input().split()]
		x = [int(_) for _ in input().split()]
		p = [int(_) for _ in input().split()]
		v = x[1] - x[0]
		y = x[0]
		g = 0
		for i in range(n - 1):
			g = gcd(g, x[i + 1] - x[i])
		for i in range(m):
			if g % p[i] == 0:
				print('YES')
				print(y, i + 1)
				return
		print('NO')
solver = CAlarmClocksEverywhere()
input = sys.stdin.readline
solver.solve()


import math
try:
	(n, m) = map(int, input().split())
	x = [int(o) for o in input().split()]
	x1 = x[:]
	x1 = sorted(x1)
	y = [int(p) for p in input().split()]
	u = min(x)
	x = list(set(x))
	x = sorted(x)
	mi = 0
	n = len(x)
	for i in range(n):
		x[i] = x[i] - u
	ma = x[1]
	for i in range(n - 1):
		m = x[i + 1] - x[i]
		if m > ma:
			if m % ma == 0:
				ma = ma
			else:
				ma = math.gcd(m, ma)
		elif ma % m == 0:
			ma = m
		else:
			ma = math.gcd(m, ma)
	flag = 0
	for i in range(m):
		if ma % y[i] == 0:
			print('YES')
			print(x1[0], i + 1)
			flag = 1
			break
	if flag == 0:
		print('NO')
except:
	print('NO')


(n, m) = [int(x) for x in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
from math import gcd
x.sort()
if n == 1:
	g = x[0]
else:
	g = x[1] - x[0]
choose = x[0]
l = len(x)
for i in range(1, l):
	g = gcd(g, x[i] - x[i - 1])
ans = -1
for i in range(m):
	if g % p[i] == 0:
		ans = i + 1
		break
if ans == -1:
	print('NO')
else:
	print('YES')
	print(choose, ans)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, input().split())
ak = list(map(int, input().split()))
p = list(map(int, input().split()))
a = []
for i in range(1, len(ak)):
	a.append(ak[i] - ak[i - 1])
gc = a[0]
for i in range(1, len(a)):
	gc = gcd(a[i], gc)
work = True
ans = 0
for i in range(len(p)):
	if gc % p[i] == 0:
		ans = i
		work = False
		break
if work:
	print('NO')
else:
	print('YES')
	print(ak[0], i + 1)


(n, m) = map(int, input().split())
event = list(map(int, input().split()))
interval = list(map(int, input().split()))
import math
uc = event[1] - event[0]
for i in range(2, n):
	uc = math.gcd(uc, event[i] - event[i - 1])
interval.append(300001)
for i in range(m + 1):
	if uc % interval[i] == 0:
		print('YES')
		print(event[0], i + 1)
		break
if i == m:
	print('NO')


from math import *
(n, m) = map(int, input().split())
ls = list(map(int, input().split()))
arr = list(ls)
ls.sort()
diff = []
for i in range(n - 1):
	diff.append(ls[i + 1] - ls[i])
GCD = 0
for i in diff:
	GCD = gcd(GCD, i)
ls = list(map(int, input().split()))
for i in range(m):
	if GCD % ls[i] == 0:
		print('YES')
		y = 10 ** 18 + 1
		for j in range(len(arr)):
			if arr[j] % ls[i] != 0:
				y = min(y, arr[j] % ls[i])
		if y == 10 ** 18 + 1:
			y = ls[i]
		print(y, i + 1)
		break
else:
	print('NO')


from sys import exit

def gcdl(A):
	if len(A) == 0:
		return -1
	if len(A) == 1:
		return A[0]
	g = gcd(A[0], A[1])
	for a in A[2:]:
		g = gcd(a, g)
	return g

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
P = list(map(int, input().split()))
X = list(set(X))
y = min(X)
X = [xi - y for xi in X]
X = [xi for xi in X if xi]
g = gcdl(X)
if g == -1:
	print('YES')
	print(y, 1)
	exit()
for (i, p) in enumerate(P, 1):
	if not g % p:
		break
else:
	print('NO')
	exit()
print('YES')
print(y, i)


import sys
import math
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k) = RI()
a = RI()
b = RI()
cd = a[1] - a[0]
for i in range(2, len(a)):
	cd = math.gcd(cd, a[i] - a[i - 1])
pos = -1
for i in range(len(b)):
	if cd % b[i] == 0:
		pos = i
		break
if pos != -1:
	YES()
	print(a[0], pos + 1)
else:
	NO()


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

def gcd(x, y):
	if y:
		return gcd(y, x % y)
	return x
g = 0
for i in range(1, n):
	g = gcd(g, a[i] - a[i - 1])
for (i, x) in enumerate(map(int, input().split())):
	if 0 == g % x:
		print('YES')
		print(a[0], i + 1)
		break
else:
	print('NO')


import math
from functools import reduce
(n, m) = map(int, input().split())
t = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
tt = reduce(math.gcd, [x - t[0] for x in t])
for (i, pp) in enumerate(p, start=1):
	if tt % pp == 0:
		print('YES')
		print(t[0], i)
		break
else:
	print('NO')


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(len(p)):
	p[i] = [p[i], i]
p.sort(key=lambda e: e[0])
for (i, vi) in enumerate(p):
	if i > 0:
		if vi == p[i - 1][0]:
			continue
	found = True
	for j in range(n - 1, 0, -1):
		if (x[j] - x[0]) % vi[0] != 0:
			found = False
			break
	if found:
		print('YES')
		print(x[0], vi[1] + 1)
		break
if not found:
	print('NO')


def gcd(a, b):
	while a != 0 and b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
di = list(map(int, input().split()))
d = c[0]
c = list(map(lambda x: int(x) - d, c[1:]))
GCD = c[0]
for i in c:
	GCD = gcd(i, GCD)
lol = -100
for (v, i) in enumerate(di):
	if gcd(GCD, i) == i:
		lol = v + 1
		print('YES')
		print(d, lol)
		break
if lol == -100:
	print('NO')


import sys

def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	if a % b == 0:
		return b
	else:
		return gcd(a, a % b)
s = input().split()
interval = []
numbers = []
nums = [int(i) for i in input().split()]
for i in range(len(nums) - 1):
	j = i + 1
	numbers.append(nums[j] - nums[i])
s2 = input().split()
for i in s2:
	interval.append(int(i))
a = numbers[0]
for i in numbers:
	a = gcd(a, i)
tag = 0
for (index, i) in enumerate(interval):
	if a % i == 0:
		tag = 1
		print('YES')
		print(nums[0], index + 1)
		break
if tag == 0:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
min_dist = x[0] - x[1]
for i in range(2, n):
	if x[i] - x[i - 1] < min_dist:
		min_dist = x[i] - x[i - 1]
max_g = gcd(min_dist, x[1] - x[0])
for i in range(2, n):
	max_g = gcd(max_g, x[i] - x[i - 1])
cond = True
for i in range(0, m):
	if max_g % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		cond = False
		break
if cond:
	print('NO')


def gcd(x, y):
	if y:
		return gcd(y, x % y)
	return x
(a, b) = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
chis = -1
check = True
G = 0
for i in range(0, a - 1):
	G = gcd(G, x[i + 1] - x[i])
for i in range(b):
	if G % p[i] == 0:
		chis = i
		break
if chis != -1:
	print('YES' + '\n', x[0], i + 1)
else:
	print('NO')


import math, sys
input()
events = [int(a) for a in input().split()]
settings = [int(a) for a in input().split()]
prev = events[0]
g = events[1] - events[0]
mn = events[0]
events = events[1:]
for ev in events:
	mn = min(mn, ev)
	g = math.gcd(ev - prev, g)
	prev = ev
mini = float('inf')
for i in settings:
	if g % i == 0:
		c = g // i
		if c < mini:
			if mini == 1:
				print('YES')
				print(mn, settings.index(g) + 1)
				sys.exit()
			mini = c
q = g // mini
if q != 0:
	print('YES')
	print(mn, settings.index(q) + 1)
else:
	print('NO')


from math import gcd
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
G = A[1] - A[0]
for i in range(1, n):
	G = gcd(G, A[i] - A[i - 1])
for i in range(m):
	if G % B[i] == 0:
		print('YES')
		print(A[0], i + 1)
		exit()
print('NO')


from functools import reduce

def gcd(n, m):
	if m == 0:
		return n
	return gcd(m, n % m)
(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
df = []
for i in range(1, n):
	df.append(x[i] - x[i - 1])
gcd = reduce(gcd, df)
flg = 0
for i in range(m):
	if gcd % p[i] == 0:
		print('YES')
		print(x[0], i + 1)
		flg = 1
		break
if flg == 0:
	print('NO')


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
from functools import reduce

def GCD(a, b):
	a = abs(a)
	b = abs(b)
	while a:
		(a, b) = (b % a, a)
	return b

def GCD_List(list):
	return reduce(GCD, list)
arr = list(map(int, input().split()))
d = []
for i in range(1, len(ar)):
	d.append(ar[i] - ar[i - 1])
ans = GCD_List(d)
flag = 0
for i in arr:
	if ans % i == 0:
		flag = 1
		break
	else:
		flag = 0
if flag == 1:
	print('YES')
	print(str(ar[0]) + ' ' + str(arr.index(i) + 1))
else:
	print('NO')


def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(len(a) - 1):
	c.append(a[i + 1] - a[i])
result = c[0]
for i in c[1:]:
	result = gcd(result, i)
for i in range(len(b)):
	if result % b[i] == 0:
		print('YES')
		print(a[0], i + 1)
		exit()
print('NO')


import io, os, sys
from functools import reduce
input = input

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
(n, m) = map(int, input().split())
ev = list(map(int, input().split()))
ala = list(map(int, input().split()))
dif = []
for i in range(n - 1):
	dif.append(ev[i + 1] - ev[i])
g = lambda a, b: a if b == 0 else g(b, a % b)
gcd = reduce(lambda x, y: g(x, y), dif)
flag = True
for ii in range(len(ala)):
	i = ala[ii]
	if gcd % i == 0:
		sys.stdout.write(str('YES') + '\n')
		sys.stdout.write(str(ev[0]) + ' ')
		sys.stdout.write(str(ii + 1) + '\n')
		flag = False
		break
if flag:
	sys.stdout.write(str('NO') + '\n')


import math
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
x.sort()
y = x[0]
x = [c - y for c in x]
gcd = x[1]
for i in range(1, n):
	gcd = math.gcd(x[i], gcd)
j = -1
for i in range(m):
	if gcd % p[i] == 0:
		j = i + 1
		break
if j == -1:
	print('NO')
else:
	print('YES')
	print(y, j)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(x, y) = map(int, input().split())
z = list(map(int, input().split()))
r = list(map(int, input().split()))
t = []
fact = []
fak = 0
zapak = []
samba = []
g = z[1] - z[0]
for i in range(len(z) - 1):
	g = gcd(g, z[i + 1] - z[i])
for i in r:
	if g % i == 0:
		fak = 1
		break
if fak == 0:
	print('NO')
else:
	print('YES')
	print(z[0], r.index(i) + 1)


import math
(n, m) = map(int, input().split())
xn = list(map(int, input().split()))
pm = list(map(int, input().split()))
ans = False
(prev, tugi) = (xn[1] - xn[0], 0)
for i in range(1, n - 1):
	tugi = xn[i + 1] - xn[i]
	prev = math.gcd(prev, tugi)
for (i, p) in enumerate(pm):
	if prev % p == 0:
		ans = i + 1
		break
if ans == False:
	print('NO')
else:
	print('YES')
	print('{} {}'.format(xn[0], ans))


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
from math import gcd
(n, m) = ll()
a = list(ll())
p = list(ll())
l = []
st = min(a)
g = a[1] - a[0]
for i in range(2, n):
	g = gcd(g, a[i] - a[i - 1])
for i in range(m):
	if g % p[i] == 0:
		print('YES')
		print(st, i + 1)
		break
else:
	print('NO')


import sys
from math import gcd

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		m = self.next_int()
		x = [self.next_int() for _ in range(0, n)]
		p = [self.next_int() for _ in range(0, m)]
		g = 0
		for i in range(1, n):
			g = gcd(g, x[i] - x[i - 1])
		for i in range(0, m):
			if g % p[i] == 0:
				print('YES')
				print(x[0], i + 1)
				return
		print('NO')
Main().solve()


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
y = []
for i in range(1, n, 1):
	y.append(x[i] - x[i - 1])
sy = set(y)
for i in range(m):
	flag = 1
	for j in sy:
		if j % p[i] != 0:
			flag = 0
			break
	if flag == 1:
		print('YES')
		print(x[0], i + 1)
		exit()
print('NO')


from math import *
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
p = list(map(int, input().split()))
gap = []
gap.append(x[1] - x[0])
for i in range(2, n):
	gap.append(x[i] - x[i - 1])
gc = gap[0]
tf = False
for i in range(1, len(gap)):
	gc = gcd(gc, gap[i])
for i in range(m):
	if gc % p[i] == 0:
		tf = True
		break
if tf:
	print('YES')
	print(x[0], i + 1)
else:
	print('NO')