CodeEff/ECCO huggingface dataset:
# Original solution
from operator import itemgetter


def main():
    N = int(eval(input()))
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=itemgetter(1), reverse=True)
    # x 昇順
    cd.sort(key=itemgetter(0))
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()


# Optimized solution
from operator import itemgetter


def main():
    N = int(eval(input()))
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=itemgetter(1), reverse=True)
    # x 昇順
    cd.sort()
    # ペアになった赤
    done = [False] * N
    for bx, by in cd:
        for k, ((rx, ry), d) in enumerate(zip(ab, done)):
            if not d and rx < bx and ry < by:
                done[k] = True
                break
    print((sum(done)))
    return


main()
# Original solution
def main():
    N = int(eval(input()))
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=lambda x:x[1], reverse=True)
    # x 昇順
    cd.sort()
    # ペアになった赤
    done = [False] * N
    for bx, by in cd:
        for k, ((rx, ry), d) in enumerate(zip(ab, done)):
            if not d and rx < bx and ry < by:
                done[k] = True
                break
    print((sum(done)))
    return


main()


# Optimized solution
def main():
    N = int(eval(input()))
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=lambda x:x[1], reverse=True)
    # x 昇順
    cd.sort()
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()
# Original solution
from operator import itemgetter


def main():
    N = int(eval(input()))
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=itemgetter(1), reverse=True)
    # x 昇順
    cd.sort()
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()


# Optimized solution
def main():
    N = int(eval(input()))
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # x 降順
    ab.sort(key=lambda x: x[0], reverse=True)
    # y 昇順
    cd.sort(key=lambda x: x[1])
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()
# Original solution
n = int(eval(input()))
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]

a.sort(reverse=True)
b.sort()
idxb = list()
for i in range(n):
    idx = -1
    maxy = -1
    for j in range(n):
        if not j in idxb:
            if a[j][0] < b[i][0] and maxy < a[j][1] < b[i][1] :
                maxy = a[j][1]
                idx = j
    if idx != -1:
        idxb.append(idx)

print((len(idxb)))





# Optimized solution
n = int(eval(input()))
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]

a.sort(reverse=True)
b.sort()
idxb = list()
for i in range(n):
    idx = -1
    miny = 1e+9
    for j in range(n):
        if not j in idxb:
            if a[i][0] < b[j][0] and a[i][1] < b[j][1] < miny:
                miny = b[j][1]
                idx = j
    if idx != -1:
        idxb.append(idx)

print((len(idxb)))
# Original solution
n = int(eval(input()))
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
reds = sorted(reds, key=lambda tup: tup[1], reverse=True)
#print(reds)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
#print(blues)
blues = sorted(blues, key=lambda tup: tup[0])
#print(blues)

count = 0
for b in blues:
    tmp = []
#    print(len(reds))
    for i in range(len(reds)):
        r = reds[i]
        if b[0] > r[0] and b[1] > r[1]:
            tmp.append(i)
            break
            
    if len(tmp) > 0:
        del reds[tmp[0]]
        count += 1

print(count)


# Optimized solution
n = int(eval(input()))
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
reds = sorted(reds, key=lambda tup: tup[1], reverse=True)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
blues = sorted(blues, key=lambda tup: tup[0])

count = 0
for b in blues:
    paired = None
    for i in range(len(reds)):
        r = reds[i]
        if b[0] > r[0] and b[1] > r[1]:
            paired = i
            break
            
    if paired is not None:
        del reds[paired]
        count += 1

print(count)
# Original solution
aa=[]
a=int(eval(input()))
for i in range(0,a):
  aa.append(input().split(" "))

bb=[]
for j in range(0,a):
  bb.append(input().split(" "))
  
pattern=[]
zentai=[]
chouhuku=0

for m in range(0,a**a):
  for n in range(0,a):
    pattern.append(m//(a**n)%a)
  
  for w in range(0,a):
    if pattern.count(pattern[w])>=2:
      chouhuku=1
  
  if chouhuku==0:
    zentai.append(pattern)
  pattern=[]
  chouhuku=0


score=0
max=0

for ww in zentai:
  for z in range(0,a):
    if aa[z][0]<bb[int(ww[z])][0] and aa[z][1]<bb[int(ww[z])][1]:
      score=score+1

  if max<=score:
    max=score
  score=0

print(max)


# Optimized solution
#解答確認後
n=int(eval(input()))
aa=[[int(i) for i in input().split()] for i in range(n)]
bb=[[int(i) for i in input().split()] for i in range(n)]

#print(aa)
#print(bb)

import operator
aa.sort(key=operator.itemgetter(1),reverse=True)
bb.sort()
  
#print(aa)
#print(bb)

answer=0
for b in bb:
  xb,yb=b
  for a in aa:
    xa,ya=a
    if xa<xb and ya<yb:
      answer=answer+1
      aa. remove (a)
      #print(aa)
      #print(bb)
      #print(answer)
      break
      
print(answer)
# Original solution
N = int(eval(input()))
Blue = []
Red = []
for i in range(N) :
    a,b = list(map(int,input().split()))
    Red.append([a,b])
for i in range(N) :
    c,d = list(map(int,input().split()))
    Blue.append([c,d])

Blue = sorted(Blue)
Red = list(reversed(sorted(Red,key=lambda x: x[1])))

ans = 0
for i in range(N) :
    for j in range(N) :
        if j >= len(Red) :
            break
        if (Blue[i][0] > Red[j][0]) and (Blue[i][1] > Red[j][1]) :
            ans += 1
            Red.pop(j)
            break
print(ans)


# Optimized solution
N = int(eval(input()))

red = [list(map(int,input().split())) for i in range(N)]
blue = [list(map(int,input().split())) for i in range(N)]

red = sorted(red, key=lambda x: x[1], reverse=True)
blue = sorted(blue, key=lambda x: x[0], reverse=False)

flg = [0 for i in range(N)]

ans = 0

for i in range(N) :
    c,d = blue[i]
    for j in range(N) :
        if flg[j] :
            continue
        
        a,b = red[j]
        
        if (a < c) and (b < d) :
            ans += 1
            flg[j] = 1
            break

print(ans)
# Original solution
N = int(eval(input()))
red = []
blue = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    red.append([in1, in2])
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    blue.append([in1, in2])
    
red = sorted(red, key=lambda x: x[0])[::-1]
ans = 0
INF = 10 ** 9 + 7
for i in range(N):
    min_ = INF
    ind = -1
    for j in range(N):
        if red[i][0] <= blue[j][0] and red[i][1] <= blue[j][1] and blue[j][1] < min_:
            ind = j
            min_ = blue[j][1]
    if ind != -1:
        blue[ind][0] = -1
        ans += 1
print(ans)

# Optimized solution
N = int(eval(input()))
red = sorted([list(map(int,input().split())) for i in range(N)], key=lambda x: x[0])[::-1]
blue = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
    min_ = 10 ** 9 + 7
    ind = -1
    for j in range(N):
        if red[i][0] <= blue[j][0] and red[i][1] <= blue[j][1] and blue[j][1] < min_:
            ind = j
            min_ = blue[j][1]
    if ind != -1:
        blue[ind][0] = -1
        ans += 1
print(ans)
# Original solution
N = int(eval(input()))
red = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x:-x[1])
blue = sorted([list(map(int,input().split())) for _ in range(N)])

ans = 0
for b in blue:
  for r in red:
    if(r[0] < b[0] and r[1] < b[1]):
      ans += 1
      red.remove(r)
      break
print(ans)

# Optimized solution
N = int(eval(input()))
AB = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[1])
CD = sorted([list(map(int,input().split())) for _ in range(N)])

cnt = 0
for c, d in CD:
  for a, b in AB:
    if(a < c and b < d):
      cnt += 1
      AB.remove([a,b])
      break
print(cnt)
# Original solution
def ans():
  N = int(eval(input()))
  AB = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[1])
  CD = sorted([list(map(int,input().split())) for _ in range(N)])
  cnt = 0
  for c, d in CD:
    for a, b in AB:
      if(a < c and b < d):
        cnt += 1
        AB.remove([a,b])
        break
  print(cnt)
ans()

# Optimized solution
N = int(eval(input()))
AB = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[1])
CD = sorted([list(map(int,input().split())) for _ in range(N)])

cnt = 0
for c, d in CD:
  for a, b in AB:
    if(a < c and b < d):
      cnt += 1
      AB.remove([a, b])
      break
print(cnt)
# Original solution
from operator import itemgetter
n=int(eval(input()))
A=[tuple(map(int,input().split())) for i in range(n)]
B=[tuple(map(int,input().split())) for j in range(n)]
A.sort()
B.sort()
count=0
for i in range(n):
    box=[A[j] for j in range(len(A)) if (A[j][0]<B[i][0]) and (A[j][1]<B[i][1])]
    #条件を満たす一番大きいものから消していく
    if any(box):
        box=sorted(box, key=itemgetter(1))
        A.remove(box[-1])
        count +=1
print(count)

# Optimized solution
N=int(eval(input()))
AB=sorted([list(map(int,input().split())) for _ in range(N)])
CD=sorted([list(map(int,input().split())) for _ in range(N)], key=lambda x:x[1])

cnt=0
for a,b in AB[::-1]:
    for i,j in enumerate(CD):
        c,d=j
        if a<c and b<d:
            cnt +=1
            del CD[i]
            break
print(cnt)
# Original solution
import itertools

n = int(eval(input()))
red = [tuple(map(int, input().split())) for _ in range(n)]
blue = [tuple(map(int, input().split())) for _ in range(n)]

agg = [list() for _ in range(n)]
for i in range(n):
    c, d = blue[i]
    for j in range(n):
        a, b = red[j]
        if c > a and d > b:
            agg[i].append(j)

prod = itertools.product(*[x for x in agg if len(x) > 0])
res = 0
for p in prod:
    res = max(res, len(set(p)))

print(res)

# Optimized solution
n = int(eval(input()))
red = sorted([tuple(map(int, input().split())) for _ in range(n)])
blue = sorted([tuple(map(int, input().split())) for _ in range(n)])

res = 0
for bx, by in blue:
    tmp_max = -1
    tmp_cnt = None
    for i, (rx, ry) in enumerate(red):
        if bx <= rx:
            break
        if tmp_max <= ry < by:
            tmp_max = ry
            tmp_cnt = i
    if tmp_cnt is not None:
        res += 1
        red.pop(tmp_cnt)

print(res)
# Original solution
def c_2D_plane_2N_points(N, R, B):
    red = sorted(R)  # 赤い点の座標(x座標で昇順ソート)
    blue = sorted(B)  # 青い点の座標(x座標で昇順ソート)
    ans = 0
    for c, d in blue:
        # 注目している青い点より"左下"にある赤い点の座標のリスト
        r = [z for z in red if z[0] < c and z[1] < d]
        if r:  # 左下に赤い点があれば
            r.sort(key=lambda x: x[1])  # y座標で昇順ソート
            # 後の青い点のことを考えると、"より左下"にある赤い点を残したほうがよい。
            # x座標でソートしていることを考えると、なるべくy座標が小さな赤い点を
            # あとに残すほうがよい。(y座標が大きな赤い点を先にペアにする)
            red.remove(r[-1])  # r[-1]が指す赤い点とペアにする。もう選べないので削除
            ans += 1
    return ans
N = int(eval(input()))
R = [[int(i) for i in input().split()] for j in range(N)]
B = [[int(i) for i in input().split()] for j in range(N)]
print((c_2D_plane_2N_points(N, R, B)))

# Optimized solution
def c_2d_plane_2n_points():
    N = int(eval(input()))
    R = [tuple([int(i) for i in input().split()]) for j in range(N)]
    B = [tuple([int(i) for i in input().split()]) for j in range(N)]

    red = sorted(R, key=lambda x: x[1], reverse=True)  # 赤い点の座標 (y 座標で降順ソート)
    blue = sorted(B)  # 青い点の座標 (x 座標で昇順ソート)
    ans = 0
    for x_b, y_b in blue:
        for x_r, y_r in red:
            # 注目している青い点より xy 平面で左下にある赤い点のうち、
            # 最も右上にある点とマッチさせるのが最適
            if x_b > x_r and y_b > y_r:
                ans += 1
                red.remove((x_r, y_r))  # もう選べないので削除
                break  # この青い点ももう選べないので終了
    return ans

print((c_2d_plane_2n_points()))
# Original solution
n = int(eval(input()))
ab = sorted([[int(i) for i in input().split()] for i in range(n)], reverse = True, key = lambda x: x[1])
cd = sorted([[int(i) for i in input().split()] for i in range(n)])

count = 0
for i in range(n):
    for j in range(len(cd)):
        if ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:
            count += 1
            del cd[j]
            break

print(count)

# Optimized solution
n = int(eval(input()))
AB = sorted([[int(i) for i in input().split()] for i in range(n)], reverse = True)
CD = sorted([[int(i) for i in input().split()] for i in range(n)], key = lambda x: x[1])

cnt = 0
for a, b in AB:
    for cd in CD:
        if a < cd[0] and b < cd[1]:
            cnt += 1
            CD.remove(cd)
            break
            
print((n - len(CD)))
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()

q = int(eval(input()))
m = list(map(int, input().split()))

def f(A, s, res):
  if res[0]:
    return
  if s == 0:
    res[0] = True
    return
  for i, a in enumerate(A):
    if a > s:
      break
    f(A[i+1:], s-a, res)

for mi in m:
  res = [False]
  f(A, mi, res)
  if res[0]:
    print("yes")
  else:
    print("no")

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
sumA = sum(A)

q = int(eval(input()))
m = list(map(int, input().split()))

def f(A, s, res):
  if res[0]:
    return
  if s == 0:
    res[0] = True
    return
  for i, a in enumerate(A):
    if a > s:
      break
    f(A[i+1:], s-a, res)

for mi in m:
  res = [False]

  if mi <= sumA:
    f(A, mi, res)

  if res[0]:
    print("yes")
  else:
    print("no")
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
q = int(eval(input()))
m = list(map(int,input().split()))

def solve(i, m_i):
    if m_i == 0:
        return True
    if i >= n:
        return False
    res = solve(i + 1, m_i) or solve(i + 1, m_i - a[i])
    return res

for m_tmp in m:
    if solve(0, m_tmp):
        print("yes")
    else:
        print("no")

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
q = int(eval(input()))
m = list(map(int,input().split()))

def solve(i, m_i):
    if m_i == 0:
        return True
    if i >= n:
        return False
    res = solve(i + 1, m_i) or solve(i + 1, m_i - a[i])
    return res

for m_tmp in m:
    if sum(a) < m_tmp:
        print("no")
    elif solve(0, m_tmp):
        print("yes")
    else:
        print("no")
# Original solution
# -*- coding: utf_8 -*-

from itertools import repeat
from itertools import combinations

def rec(s, i, total, m):
    if total == m:
        return 1

    if len(s) == i or total > m:
        return 0

    return rec(s, i + 1, total, m) + rec(s, i + 1, total + s[i], m)

def loop(s, m):
    for i in range(len(s)):
        comb = list(combinations(s, i))
        for c in comb:
            if sum(c) == m:
                return 1

    return 0

if __name__ == "__main__":
    n = int(input())
    a = [int (x) for x in input().split()]
    q = int(input())
    m = [int (x) for x in input().split()]
    for i in m:
        #print("yes") if rec(a, 0, 0, i) > 0 else print("no")
        print("yes") if loop(a, i) > 0 else print("no")


# Optimized solution
# -*- coding: utf_8 -*-

from itertools import repeat
from itertools import combinations

def rec(s, i, total, m):
    if total == m:
        return 1

    if len(s) == i or total > m:
        return 0

    return rec(s, i + 1, total, m) + rec(s, i + 1, total + s[i], m)


def makeCache(s):
    cache = {}
    for i in range(len(s)):
        comb = list(combinations(s, i))
        for c in comb:
            cache[sum(c)] = 1

    return cache

def loop(s, m):
    for i in range(len(s)):
        comb = list(combinations(s, i))
        for c in comb:
            if sum(c) == m:
                return 1

    return 0

if __name__ == "__main__":
    n = int(input())
    a = [int (x) for x in input().split()]
    q = int(input())
    m = [int (x) for x in input().split()]
    s = makeCache(a)
    for i in m:
        #print("yes") if rec(a, 0, 0, i) > 0 else print("no")
        #print("yes") if loop(a, i) > 0 else print("no")
        print("yes") if i in s else print("no")
# Original solution
n = eval(input())
A = list(map( int , input().split() ))
q = eval(input())
mi = list(map( int , input().split() ))

def solve(i, m):
  if m == 0:
    return True
  elif i >= n:
    return False
  else:
    res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
    return res

for m in mi:
  if solve( 0 , m ): print("yes")
  else: print("no")
   

# Optimized solution
n = eval(input())
A = list(map( int , input().split() ))
q = eval(input())
mi = list(map( int , input().split() ))

def solve(i, m):
  if m == 0:
    return True
  elif i >= n or m > sum(A):
    return False

  res = solve( i+1 , m ) or solve( i+1 , m-A[i] )
  return res

for m in mi:
  if solve( 0 , m ): print("yes")
  else: print("no")
# Original solution
# coding=utf-8


def solve_recursively(candidate_numbers, target_number):
    """classify if the target number is represented a summation of elements of candidate_numbers

    Args:
        candidate_numbers: candidate_numbers
        target_number: target_number

    Returns:
        if target number is represented a summation of elements of candidate_numbers(book)
    """
    if target_number == 0:
        return True
    elif len(candidate_numbers) == 0:
        return False

    solution = solve_recursively(candidate_numbers[1:], target_number - candidate_numbers[0]) or solve_recursively(
        candidate_numbers[1:], target_number)

    return solution


def main():
    input()  # pass length
    candidate_numbers = [int(x) for x in input().strip().split(' ')]
    input()  # pass length
    target_numbers = [int(x) for x in input().strip().split(' ')]

    for target_number in target_numbers:
        if solve_recursively(candidate_numbers, target_number):
            print("yes")
        else:
            print("no")


if __name__ == "__main__":
    main()

# Optimized solution
# -*- coding: utf-8 -*-


def check_solvable_recursively(number, is_solvable, candidate_numbers):
    """exhaustively search representable as summation of numbers in candidate_numbers

    Args:
        number: representable number
        is_solvable: is solvable list
        candidate_numbers: candidate numbers to be used

    Returns:
        None
    """
    is_solvable[number] = True
    if candidate_numbers:
        check_solvable_recursively(number + candidate_numbers[0], is_solvable, candidate_numbers[1:])
        check_solvable_recursively(number, is_solvable, candidate_numbers[1:])
    else:
        pass


def main():
    input()  # pass length
    candidate_numbers = [int(x) for x in input().strip().split(' ')]
    input()  # pass length
    target_number_list = [int(x) for x in input().strip().split(' ')]

    is_solvable_list = [False] * 2001

    check_solvable_recursively(0, is_solvable_list, candidate_numbers)

    for target_number in target_number_list:
        if is_solvable_list[target_number]:
            print("yes")
        else:
            print("no")

if __name__ == "__main__":
    main()
# Original solution
# -*- coding: utf-8 -*-


def check_solvable_recursively(number, is_solvable, candidate_numbers):
    """exhaustively search representable as summation of numbers in candidate_numbers

    Args:
        number: representable number
        is_solvable: is solvable list
        candidate_numbers: candidate numbers to be used

    Returns:
        None
    """
    is_solvable[number] = True
    if candidate_numbers:
        check_solvable_recursively(number + candidate_numbers[0], is_solvable, candidate_numbers[1:])
        check_solvable_recursively(number, is_solvable, candidate_numbers[1:])
    else:
        pass


def main():
    input()  # pass length
    candidate_numbers = [int(x) for x in input().strip().split(' ')]
    input()  # pass length
    target_number_list = [int(x) for x in input().strip().split(' ')]

    is_solvable_list = [False] * 2001

    check_solvable_recursively(0, is_solvable_list, candidate_numbers)

    for target_number in target_number_list:
        if is_solvable_list[target_number]:
            print("yes")
        else:
            print("no")

if __name__ == "__main__":
    main()

# Optimized solution
# -*- coding: utf-8 -*-


def check_solvable_recursively(number, is_solvable, candidate_numbers):
    """exhaustively search representable as summation of numbers in candidate_numbers

    Args:
        number: representable number
        is_solvable: is solvable list
        candidate_numbers: candidate numbers to be used

    Returns:
        None
    """
    if not is_solvable[number]:
        is_solvable[number] = True
    if candidate_numbers:
        check_solvable_recursively(number + candidate_numbers[0], is_solvable, candidate_numbers[1:])
        check_solvable_recursively(number, is_solvable, candidate_numbers[1:])


def main():
    input()  # pass length
    candidate_numbers = [int(x) for x in input().strip().split(' ')]
    input()  # pass length
    target_number_list = [int(x) for x in input().strip().split(' ')]

    is_solvable_list = [False] * 2001

    check_solvable_recursively(0, is_solvable_list, candidate_numbers)

    for target_number in target_number_list:
        if is_solvable_list[target_number]:
            print("yes")
        else:
            print("no")

if __name__ == "__main__":
    main()
# Original solution
def solve(p, t):
  if p >= len(A): return False
  if t == A[p]: return True
  if t <= 0: return False
  #print("({}, {})".format(p, t))

  if solve(p + 1, t):
    return True
  else:
    return solve(p + 1, t - A[p])

n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
M = list(map(int, input().split()))

for t in M:
  if solve(0, t): print("yes")
  else: print("no")

# Optimized solution
memo = {}
def solve(p, t):
  key = "{}:{}".format(p, t)
  if key in memo: return memo[key]
  if p >= len(A): return False
  if t == A[p]: return True
  if t <= 0: return False
  #print("({}, {})".format(p, t))

  if solve(p + 1, t):
    memo["{}:{}".format(p + 1, t)] = True
    return True
  else:
    memo["{}:{}".format(p + 1, t)] = False
    return solve(p + 1, t - A[p])

n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
M = list(map(int, input().split()))

for t in M:
  if solve(0, t): print("yes")
  else: print("no")