Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n,m=map(int,input().split())
 
#各部屋の通じてる部屋番のリストを作る
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b)
    l[b-1].append(a)

#深さのリストを作る
l1=sum(l, []) #部屋番のリストを一次元化
l_depth=[1]
l_depth_sub=[0]*n
l_depth_sub[0]+=1
for i in range(len(l1)):
    if l_depth_sub[l1[i]-1]==0:
        l_depth_sub[l1[i]-1]+=1
        l_depth.append(l1[i])
    if l_depth_sub.count(0)==0:break

#解の出力
print('Yes')
for i in range(1,n):
    #各部屋の通じてる部屋リストを浅い順にソート
    ll=sorted(l[i], key=lambda data:l_depth.index(data))
    print(ll[0])

### FIXED CODE ###

import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
 
g=nx.Graph() #無向グラフ
g.add_edges_from(s) #リストsを参照して頂点（部屋）の追加
di=nx.predecessor(g,source=1)#1から全点までの最短路におけるその点の前の点を表示
 
print("Yes")
for x in range(2,n+1):
      print(di[x][0])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from collections import defaultdict
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9+7


def solve(N: int, P: int, S: str):
    DP = [defaultdict(int) for _ in range(N)]
    for i in range(N):
        for key in DP[i-1]:
            DP[i][(key*10+int(S[i])) % P] += DP[i-1][key]
        DP[i][(int(S[i])) % P] += 1
    # print(*DP, sep="\n")
    print(sum([DP[i][0] for i in range(N)]))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: int
    solve(N, P, S)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, P: int, S: str):

    if P == 2 or P == 5:
        tot = 0
        for i, c in enumerate(S):
            c = int(c)
            if c % P == 0:
                tot += i+1
        print(tot)
        return

    U = [0]*(N+1)
    a = 0
    beki = 1
    for i in range(N-1, -1, -1):
        a += beki*int(S[i])
        a %= P
        U[i] = a
        beki = (beki * 10) % P
    table = [0]*P
    tot = 0
    for i in range(N-1, -1, -1):
        tot += table[U[i]]
        table[U[i]] += 1
    tot += table[0]
    print(tot)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: int
    solve(N, P, S)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
s = input()
count =0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                if j - i != k - j:
                    count +=1
print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n=int(input())
s=input()

r=s.count('R')
g=s.count('G')
b=s.count('B')

ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n: break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans-=1

print(ans)
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, m = MAP()
A = LIST()
B = LIST()

L = [LIST() for i in range(m)]

D = [[0] * b for i in range(a)]
for x,y,c in L:
    D[x-1][y-1] = max(D[x-1][y-1], c)


ans = INF
C = [[0] * b for i in range(a)]
for i in range(a):
    for j in range(b):
        ans = min(A[i] + B[j] - D[i][j], ans)
        
print(ans)

# exit()

# for x, y, c in L:
#     C[x-1][y-1] = min(C[x-1][y-1], C[x-1][y-1]-c)

# print(min(C))


# #     ans.append(A[x-1] + B[y-1] - c)
# # print(min(ans))



# exit()
# s = input()
# m= "hi"
# # for i in range():
# l = len(s) // 2
# if l * m == s:
#     print("Yes")
# else:
#     print("No")

# # if s // 2



### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, m = MAP()
A = LIST()
B = LIST()
A_s = sorted(A)
B_s = sorted(B)
# print(A)
# print(B)
L = [LIST() for i in range(m)]

ans = A_s[0] + B_s[0]
for x, y, c in L:
    # print(x, y, c)
    v = A[x-1] + B[y-1] - c
    if ans > v:
        ans = v
print(ans)


# exit()


# D = [[0] * b for i in range(a)]
# for x,y,c in L:
#     D[x-1][y-1] = max(D[x-1][y-1], c)
# ans = INF
# C = [[0] * b for i in range(a)]
# for i in range(a):
#     for j in range(b):
#         ans = min(A[i] + B[j] - D[i][j], ans)
        
# print(ans)

# # exit()

# # for x, y, c in L:
# #     C[x-1][y-1] = min(C[x-1][y-1], C[x-1][y-1]-c)

# # print(min(C))


# # #     ans.append(A[x-1] + B[y-1] - c)
# # # print(min(ans))



# # exit()
# # s = input()
# # m= "hi"
# # # for i in range():
# # l = len(s) // 2
# # if l * m == s:
# #     print("Yes")
# # else:
# #     print("No")

# # # if s // 2
### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

#  f = open('C_input_29.txt')
#  lines = f.readlines()
#  f.close()
#  N, M = map(int, lines[0].split())
#  A = []
#  for line in lines[1:]:
#      A.append(int(line))

N, M = LI()
A = []
for i in range(M):
    A.append(_I())

#  if M != 0:
#      # 連続した壊れた段がある場合は0
#      B = [i for i in A]
#      B.remove(B[0])
#      B.append(10**15+100)
#      diffs = [b - a for a, b in zip(A,B)]
#      #  print(diffs)

#      if any(i == 1 for i in diffs):
#          # 隣同士なので0
#          print(0)
#          exit()
#  print('hoge')
"""
考え方
xにたどり着く通りは、x-1とx-2段目にたどり着く通りの合計
dp
3が障害のとき
1へは1通り
2へは0からと1からの2通り
3へは0通り
4へは2からの2通りと、3からの0通りで2通り
5へは3からの0通りと4からの2通りで2通り
6へは4からの2通りと5からの2通りで4通り
"""
#  dp = {}
dp = [0 for i in range(N+1)]
#  print('fua')
dp[0] = 1
dp[1] = 1 if 1 not in A else 0
#  [dp.update({i: (dp[i-1] + dp[i-2])%mod}) if i not in A else dp.update({i: 0}) for i in range(2, N+1)]
for i in range(2, N+1):
    #  print(i)
    # i段目までの通りを計算する
    if i not in A:
        # i段目が障害のときは0になっているので飛ばす
        dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[N])


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

mod = 10 ** 9 + 7

def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


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


n, m = get_numbers()
a = set(get_nums(m))

dp = [0 for _ in range(n + 1)]
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, n + 1):
    if i not in a:
        dp[i] = dp[i - 1] + dp[i - 2]
        dp[i] %= mod

print(dp[-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        print(-1)
        exit(0)
print(ans)
### BUGGY CODE ###

from itertools import combinations
import sys
n, k = map(int, sys.stdin.readline().split())

lst = {i for i in range(0, n+1)}
re = 0
for i in range(k, n+1):
    temp = set(combinations(lst, i))
    tt = {sum(j) for j in temp}
    re += len(tt)

print(re+1)

### FIXED CODE ###

import sys
n, k = map(int, sys.stdin.readline().split())
ans = 0
mod = 10**9+7
for i in range(k, n+2):
    ans += (n-i+1)*i + 1
ans %= mod
print(ans)
### BUGGY CODE ###

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))

A.sort()

dp = [1] * N
for i in range(N):
    for j in range(i+1, N):
        if dp[j] == 0:
            continue
        if A[j] % A[i] == 0:
            dp[j] = 0
            if A[i] == A[j]:
                dp[i] = 0

ans = len(list(filter(lambda x: x == 1, dp)))
print(ans)

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import collections
N = int(input())
A = list(map(int, input().split()))
cA = collections.Counter(A)

LIM = 10 ** 6 + 1
# LIM = 25

A.sort()
dp = [1] * LIM

for i in set(A):
    s = i * 2
    while s < LIM:
        dp[s] = 0
        s += i

ans = 0
# print(dp)
for a in A:
    # print("{} {}".format(dp[a], cA[a]))
    if dp[a] and cA[a] == 1:
        # print(a)
        ans += 1
print(ans)
### BUGGY CODE ###

import math
X = int(input())

for a in range(1, 2000):
    a4 = a**4
    a3 = a**3
    a2 = a**2
    for b in range(-1, 2000):
        an = (a-b)*(a4 + (a3)*b + (a2)*(b**2) + a*(b**3) + b**4)

        if an == X:
            print(a, b)
            exit()


### FIXED CODE ###

import math
X = int(input())

for a in range(1, 1500):
    a4 = a**4
    a3 = a**3
    a2 = a**2
    for b in range(-1500, 1500):
        an = (a-b)*(a4 + (a3)*b + (a2)*(b**2) + a*(b**3) + b**4)
        if an < 0:
            break

        if an == X:
            print(a, b)
            exit()
### BUGGY CODE ###

F_str = input().split()
F = [int(f) for f in F_str]
N = F[0]
M = F[1]

WA_dict = {}
AC_list = []

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list.append(S[0])
    elif(not(S[0] in AC_list)):
        WA_dict.setdefault(S[0], 0)
        WA_dict[S[0]] += 1

AC_set = list(set(AC_list))

WA_count = 0

for item in AC_set:
    if(item in WA_dict):
        WA_count += WA_dict[item]

print(str(len(AC_set)) + " " + str(WA_count))

### FIXED CODE ###

F_str = input().split()
F = [int(f) for f in F_str]
N = F[0]
M = F[1]

WA_list = [0 for _ in range(N)]
AC_list = [0 for _ in range(N)]

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list[int(S[0])-1] = 1
    elif(AC_list[int(S[0])-1] != 1):
        WA_list[int(S[0])-1] += 1

WA_count = 0
AC_count = 0

for i in range(N):
    if(AC_list[i] == 1):
        AC_count += 1
        WA_count += WA_list[i]

print(AC_count, WA_count)
### BUGGY CODE ###

from collections import deque

N, Q = map(int, input().split(' '))

queue = deque()

for _ in range(1, N):
    queue.append(tuple(map(int, input().split(' '))))

tree = {
    1: set()
}

while len(queue) > 0:
    a, b = queue.popleft()
    if a in tree:
        tree[a].add(b)
        tree[b] = set()
    elif b in tree:
        tree[b].add(a)
        tree[a] = set()
    else:
        queue.append((a, b))

results = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split(' '))
    results[p] += x

stack = deque([1])

while len(stack) > 0:
    node = stack.popleft()
    for child in tree[node]:
        stack.append(child)
        results[child] += results[node]

print(' '.join([str(result) for result in results[1:]]))


### FIXED CODE ###

from collections import deque, defaultdict

N, Q = map(int, input().split(' '))

tree = defaultdict(set)
for _ in range(1, N):
    a, b = map(int, input().split(' '))
    tree[a].add(b)
    tree[b].add(a)

results = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split(' '))
    results[p] += x

stack = deque([1])
searched = set()

while len(stack) > 0:
    node = stack.popleft()
    searched.add(node)
    for child in tree[node]:
        if child not in searched:
            stack.append(child)
            results[child] += results[node]

print(' '.join([str(result) for result in results[1:]]))
### BUGGY CODE ###

S = input()
ans = 0
while any(['01' in S,'10' in S]):
    ans += S.count('01')
    S = S.replace('01','')
    ans += S.count('10')
    S = S.replace('10','')
print(ans*2)

### FIXED CODE ###

S = input()
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)
### BUGGY CODE ###

from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

s = input()[::-1]
rem = [[0 for i in range(13)] for _ in range(len(s)+1)]
rem[0][0] = 1
for i, st in enumerate(s):
    if st == '?':
        for j in range(10):
            next = (j * 10 ** i) % 13
            for k in range(13):
                rem[i+1][(k+next)%13] += rem[i][k]
    else:
        next = (int(st) * 10**i) % 13
        for j in range(13):
            rem[i+1][(j+next)%13] = rem[i][j]
    for _ in rem[i]:
        _ %= mod
print(rem[len(s)][5] % mod)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = sys.stdin.readline()
n = len(s)-1
now = [0] * 13
now[0] = 1
for i in range(n)[::-1]:
    prev = now[::]
    now = [0] * 13
    c = n - i - 1#桁
    m = pow(10,c,13)
    if s[i] == '?':
        for k in range(10):
            l = (m*k) % 13
            for j in range(13):
                now[(j+l)%13] += prev[j]
                now[(j+l)%13] = now[(j+l)%13] % mod
    else:
        k = int(s[i])
        l = (m*k) % 13
        for j in range(13):
            now[(j+l)%13] = prev[j]
    # print(now)
print(now[5])
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().split()))
for i in range(0, n):
    j = x.pop(i)
    print(sorted(x)[n//2-1])
    x.insert(i, j)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
d = dict(zip(range(0,n), x))
x.sort()
for i in range(0, n):
    if d[i] <= x[n//2-1] :
        print(x[n//2])
    else :
        print(x[n//2-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
S=int(input())
K=len(str(S))
lst= [x for x in list(str(S))]
A=[[0 for v in range(K)] for j in range(2019)]
A[int(lst[0])][0]+=1
for i in range(1,K):
 c=int(lst[i])
 A[c][i]+=1
 for k in range(2019):
  d=(k*10+c)%2019
  A[d][i]+=A[k][i-1]
print(sum(A[0]))


### FIXED CODE ###

S=input()
T=len(S)
a=0
d=1
mod=[0]*2019
mod[0]+=1
for i in range(T):
 a+=(int(S[T-i-1])*(d))%2019
 b=a%2019
 mod[b]+=1
 d*=10
 d%=2019
c=0
for i in range(2019):
 if mod[i]>=2:
  c+= mod[i]*(mod[i]-1)/2
print(int(c))
### BUGGY CODE ###

#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    H=[int(input()) for i in range(N)]
    H.sort()
    ans=1000000000
    for i in range(N-K+1):
        temp=H[i:i+K]
        xam=max(temp)
        nim=min(temp)
        ans=min(xam-nim,ans)
    print(ans)
#%%submit!
resolve()

### FIXED CODE ###

#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    H=[int(input()) for i in range(N)]
    H.sort()
    #print(H)
    ans=1000000000
    for i in range(N-K+1):
        ans=min(H[i+K-1]-H[i],ans)
    print(ans)
#%%submit!
resolve()
### BUGGY CODE ###

from functools import reduce

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

def gcda(arr, left, right):
    return reduce((lambda a,b:gcd(a,b)), arr[left:right+1], gcd(arr[left], arr[right]))

n = int(input())
nums = [ int(s) for s in input().split(" ")]

if n == 2:
    print(max(nums))
    exit()

allgcd = gcda(nums, 0, n-1)

maxgcd = 0
for jogai in range(n):
    if(jogai == 0):
        maxgcd = max(maxgcd, gcda(nums, 1, n-1))
    elif(jogai == n-1):
        maxgcd = max(maxgcd, gcda(nums, 0, n-2))
    else:
        maxgcd = max(maxgcd,  gcd(gcda(nums, 0, jogai-1), gcda(nums, jogai+1, n-1)))

print(maxgcd)

### FIXED CODE ###

from functools import reduce

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

def gcda(arr, left, right):
    return reduce((lambda a,b:gcd(a,b)), arr[left:right+1], gcd(arr[left], arr[right]))

n = int(input())
nums = [ int(s) for s in input().split(" ")]

if n == 2:
    print(max(nums))
    exit()

left_n = [0 for _ in range(n)]
right_n = [0 for _ in range(n)]

left_n[0] = nums[0]
right_n[n-1] = nums[n-1]

for i in range(n-1):
    left_n[i+1] = gcd(left_n[i], nums[i+1])
    right_n[n-2-i] = gcd(right_n[n-1-i], nums[n-2-i])

# print(left_n)
# print(right_n)

maxgcd = 0
for i in range(n):
    if i == 0:
        maxgcd = max(maxgcd, right_n[1])
    if i == n-1:
        maxgcd = max(maxgcd, left_n[n-2])
    else:
        maxgcd = max(maxgcd, gcd(right_n[i+1], left_n[i-1]))

print(maxgcd)
### BUGGY CODE ###

A, B, K = map(int, input().split())
s = [0 for i in range(B - A + 1)]
if K > len(s):
    K = len(s)
    
for i in range(K):
    s[i] = 1
    s[B - A - i] = 1

for i in range(B - A + 1):
    if s[i] == 1:
        print(i + A)


### FIXED CODE ###

A, B, K = map(int, input().split())
if B - A <= 100:
    s = [0 for i in range(B - A + 1)]
    if K > len(s):
        K = len(s)
    
    for i in range(K):
        s[i] = 1
        s[B - A - i] = 1
 
    for i in range(B - A + 1):
        if s[i] == 1:
            print(i + A)

else:
    ss = [0 for i in range(100)]
    sb = [0 for i in range(100)]

    for i in range(K):
        print(i + A)

    for i in range(K):
        print(B - K + i + 1)
### BUGGY CODE ###

S = input()
Q = int(input())
query = []
for _ in range(Q):
    query.append(input().split(" "))

def calc(q, S):
    if q[0] == "1":
        S = S[::-1]
    else:
        if q[1] == "1":
            S = q[2] + S
        else:
            S = S + q[2]
    return S

for q in query:
    S = calc(q, S)
print(S)

### FIXED CODE ###

import collections
S = input()
dq = collections.deque(S)
Q = int(input())
q = []
hanten = False
for _ in range(Q):
    q = input().split(" ")
    if q[0] == '1':
        hanten = not hanten
    else:
        if q[1] == '1' and not hanten:
            dq.appendleft(q[2])
        elif q[1] == '1' and hanten:
            dq.append(q[2])
        elif q[1] == '2' and not hanten:
            dq.append(q[2])
        else:
            dq.appendleft(q[2])
if not hanten:
    print(''.join(dq))
else:
    print(''.join(dq)[::-1])
### BUGGY CODE ###

def make_divisors(n):
    divisors = []
    n=abs(n)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return set(divisors)

def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  s=make_divisors(x[0]-m)
  for i in range(1,n):
    s=s&make_divisors(x[i]-x[i-1])
  print(max(s))
  
main()

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    n=abs(n)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return set(divisors)

def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  s=make_divisors(x[0]-m)
  news=[]
  for i in range(1,n):
    d=x[i]-x[i-1]
    news=[]
    for j in s:
      if d%j==0:
        news.append(j)
    s=set(news)
  print(max(s))
  
main()
### BUGGY CODE ###

# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
from functools import reduce


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    numbers = input_list()
    ans = []
    for i in range(n):
        t = numbers[:]
        t.pop(i)
        ans.append(reduce(lambda a, b: a ^ b, t))
    print(*ans)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


### FIXED CODE ###

# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
from functools import reduce


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    numbers = input_list()
    ans = []
    s = reduce(lambda a, b: a ^ b, numbers)
    for i in range(n):
        ans.append(s ^ numbers[i])
    print(*ans)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()