def sieve(n): is_prime = [True for _ in range(n+1)] is_prime[0] = False for i in range(2, n+1): if is_prime[i-1]: j = i * i while j <= n: is_prime[j-1] = False j += i table = [ i for i in range(1, n+1) if is_prime[i-1]] return [False]+is_prime, table N = int(input()) AB = [list(input().split()) for _ in range(N)] TABLE,_ = sieve(10**6) for i in range(2 ** N): S = [] T = [] for j in range(N): if ((i >> j) & 1): T.append(AB[j][0]) S.append(AB[j][1]) else: T.append(AB[j][1]) S.append(AB[j][0]) f = True for j in range(N): for k in range(N): if TABLE[int(str(S[j])+str(T[k]))]: f=False if f: print('Yes') exit() print('No')