Harryxun/stf_run huggingface dataset:
class Point():
	def __init__(self, x, y):
		self.x = x
		self.y = y
	

output_list = []


init_point = map(float, raw_input().split())

p0 = Point(init_point[0], init_point[1])
p1 = Point(init_point[2], init_point[3])


q = int(raw_input())
datalist = [map(float, raw_input().split()) for i in range(q)]


#p0--p1 : y=ax+b
#p2--t  : y=cx+d

a = (p0.y - p1.y) / (p0.x - p1.x)

if a != 0:
	c = -1/a
	b = p0.y - a*p0.x
	
	for data in datalist:
		p2 = Point(data[0], data[1])
		
		d = p2.y - c*p2.x
		
		X = (-b+d) / (a-c)
		Y = a*X + b
		
		output_list.append( (X,Y) )
		
else:
	for data in datalist:
		p2 = Point(data[0], data[1])
		output_list.append( (p2.x, p0.y) )
		
for x, y in output_list:
	print "%.10f %.10f" % (x, y)
	

### FIXED CODE ###

class Point():
	def __init__(self, x, y):
		self.x = x
		self.y = y
	

output_list = []


init_point = map(float, raw_input().split())

p0 = Point(init_point[0], init_point[1])
p1 = Point(init_point[2], init_point[3])


q = int(raw_input())
datalist = [map(float, raw_input().split()) for i in range(q)]


#p0--p1 : y=ax+b
#p2--t  : y=cx+d

if (p0.x - p1.x) == 0:
	for data in datalist:
		p2 = Point(data[0], data[1])
		output_list.append( (p0.x, p2.y) )

elif (p0.y - p1.y) == 0:
	for data in datalist:
		p2 = Point(data[0], data[1])
		output_list.append( (p2.x, p0.y) )
		
else:
	a = (p0.y - p1.y) / (p0.x - p1.x)
	c = -1/a
	b = p0.y - a*p0.x
	
	for data in datalist:
		p2 = Point(data[0], data[1])
		
		d = p2.y - c*p2.x
		
		X = (-b+d) / (a-c)
		Y = a*X + b
		
		output_list.append( (X,Y) )
		
for x, y in output_list:
	print "%.10f %.10f" % (x, y)
ary = input().split().sort()

print(ary(0))

### FIXED CODE ###

ary=list(map(int, input().split()))
ary.sort()
print("{} {} {}".format(ary[0], ary[1], ary[2]))
import functools
import math
import copy

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

A.sort()
ans = 1

for i in range(N):
    B = copy.copy(A)
    B.pop(i)
    gcd = functools.reduce(math.gcd, B)
    ans = max(ans, gcd)

print(ans)

### FIXED CODE ###

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


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

L = [0] * (N + 1)
L[0] = 0
R = [0] * (N + 1)
R[0] = 0

for i in range(N):
    L[i + 1] = gcd(L[i], A[i])
    R[i + 1] = gcd(R[i], A[-i - 1])

ans = 0
for i in range(N):
    ans = max(ans, gcd(L[i], R[N - i - 1]))
print(ans)
#coding:utf-8
#DPの練習

n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

#壊れている階段とそうでない階段を判別するリスト
broken = [0] * (n+1)

#段ごとに何通りかを集計するためのリスト
dp = [0] * (n+1)
#0段目は必ず1通りしかない
dp[0] = 1


#壊れている階段をマークする
for i in range(m):
    broken[a[i]] = 1

#1段目から壊れている可能性があるので場合分け
if broken[1] == 1:
    dp[2] = 0
else:
    #1段目が無事な場合は1通り
    dp[2] = 1

#3段目以降
for i in range(2, n+1):
    if broken[i] == 1:
        #壊れていた場合次の段を確認する
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i] % 1000000007

print(dp[n])



### FIXED CODE ###

#coding:utf-8
#DPの練習

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

#壊れている階段とそうでない階段を判別するリスト
broken = [0] * (n+1)

#段ごとに何通りかを集計するためのリスト
dp = [0] * (n+1)
#0段目は必ず1通りしかない
dp[0] = 1


#壊れている階段をマークする
for i in range(m):
    broken[int(input())] = 1

#1段目から壊れている可能性があるので場合分け
if broken[1] == 1:
    dp[1] = 0
else:
    #1段目が無事な場合は1通り
    dp[1] = 1

#2段目以降
for i in range(2, n+1):
    if broken[i] == 1:
        #壊れていた場合次の段を確認する
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i] % 1000000007

print(dp[n])
print(int(input)//3)

### FIXED CODE ###

print(int(input())//3)
a, b = list(map(int, input().split(' ')))
print(b*pow(b-1, a-1))



### FIXED CODE ###

import numpy as np
array = list(map(int, input().split(' ')))
print(len(np.unique(array)))
h,w = map(int,input().split())
hwl = []
for _ in range(h):
  l = list(input())
  hwl.append(l)
  
for i in range(h):
  for j in range(w):
    if hwl[i][j] == ".":
      cnt = 0
      if i != 0 and j !=0 and hwl[i-1][j-1] == "#":
        cnt +=1
      
      if i != 0 and hwl[i-1][j] == "#":
        cnt +=1
      
      if i != 0 and hwl[i-1][j+1] == "#":
        cnt +=1
        
      if j !=0 and hwl[i][j-1] == "#":
        cnt +=1
      
      if j < w-1 and hwl[i][j+1] == "#":
        cnt +=1
        
      if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
        cnt +=1
      
      if i <h-1 and hwl[i+1][j] == "#":
        cnt +=1
        
      if i < h-1 and j < w-1 and hwl[i+1][j+1] == "#":
        cnt +=1
        
      hwl[i][j] = str(cnt)

  print("".join(hwl[i]))
      
   

### FIXED CODE ###

h,w = map(int,input().split())
hwl = []
for _ in range(h):
  l = list(input())
  hwl.append(l)
  
for i in range(h):
  for j in range(w):
    if hwl[i][j] == ".":
      cnt = 0
      if i != 0 and j !=0 and hwl[i-1][j-1] == "#":
        cnt +=1
      
      if i != 0 and hwl[i-1][j] == "#":
        cnt +=1
      
      if i != 0 and j < w-1 and  hwl[i-1][j+1] == "#":
        cnt +=1
        
      if j !=0 and hwl[i][j-1] == "#":
        cnt +=1
      
      if j < w-1 and hwl[i][j+1] == "#":
        cnt +=1
        
      if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
        cnt +=1
      
      if i <h-1 and hwl[i+1][j] == "#":
        cnt +=1
        
      if i < h-1 and j < w-1 and hwl[i+1][j+1] == "#":
        cnt +=1
        
      hwl[i][j] = str(cnt)

  print("".join(hwl[i]))
N = int(input())
A = list(map(int, input().split()))
res = 0
 
while all(a%2 == 0 for a in A):
  A = [a/2 for a in A]
  res += 1
 
print(res)

### FIXED CODE ###

print(input().count("1"))
print(" ".join(input().split(","))

### FIXED CODE ###

print(" ".join(input().split(",")))
import collections
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
points=['No' for i in range(n)]
c = collections.Counter(a)

zone=k-q

if zone<1:
    for v in c.values():
        if abs(zone)+1=<v:
            points[v-1]='Yes'
        
    
    
    
        
    

print(points)

### FIXED CODE ###

import collections
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
points=['No' for i in range(n)]
c = collections.Counter(a)

zone=k-q


for v in c:
    
    if zone+c.get(v)>=1:
        points[v-1]='Yes'
if zone>=1:
    for h in points:
        print('Yes')
else:
    for h in points:
        print(h)
no = input()
answer = no**3

print(answer)

### FIXED CODE ###

x = int(input())
print(x**3)
from collections import defaultdict
def preorder(here, conn, chain):
    if here == -1:
        return
    chain.append(here)
    if conn[here]:
        preorder(conn[here][0], conn, chain)
        preorder(conn[here][1], conn, chain)

def inorder(here, conn, chain):
    if here == -1:
        return
    if conn[here]:
        inorder(conn[here][0], conn, chain)
        chain.append(here)
        inorder(conn[here][1], conn, chain)

def postorder(here, conn, chain):
    if here == -1:
        return
    if conn[here]:
        postorder(conn[here][0], conn, chain)
        postorder(conn[here][1], conn, chain)
    chain.append(here)

query = int(input())
connect = defaultdict(list)
in_v = [0 for n in range(query + 1)]
for _ in range(query):
    here, left, right = (int(n) for n in input().split(" "))
    connect[here] = [left, right]
    in_v[left] += 1
    in_v[right] += 1
for i in range(query):
    if not in_v[i]:
        root = i
        break
preo = []
ino = []
posto = []
preorder(root, connect, preo)
inorder(root, connect, ino)
postorder(root, connect, posto)

print("Preorder")
print(" " + *preo)
print("Inorder")
print(" " + *ino)
print("Postorder")
print(" " + *posto)

### FIXED CODE ###

from collections import defaultdict
def preorder(here, conn, chain):
    if here == -1:
        return
    chain.append(here)
    if conn[here]:
        preorder(conn[here][0], conn, chain)
        preorder(conn[here][1], conn, chain)

def inorder(here, conn, chain):
    if here == -1:
        return
    if conn[here]:
        inorder(conn[here][0], conn, chain)
        chain.append(here)
        inorder(conn[here][1], conn, chain)

def postorder(here, conn, chain):
    if here == -1:
        return
    if conn[here]:
        postorder(conn[here][0], conn, chain)
        postorder(conn[here][1], conn, chain)
    chain.append(here)

query = int(input())
connect = defaultdict(list)
in_v = [0 for n in range(query + 1)]
for _ in range(query):
    here, left, right = (int(n) for n in input().split(" "))
    connect[here] = [left, right]
    in_v[left] += 1
    in_v[right] += 1
for i in range(query):
    if not in_v[i]:
        root = i
        break
preo = []
ino = []
posto = []
preorder(root, connect, preo)
inorder(root, connect, ino)
postorder(root, connect, posto)

print("Preorder")
print("", end = " ")
print(*preo)
print("Inorder")
print("", end = " ")
print(*ino)
print("Postorder")
print("", end = " ")
print(*posto)
s=input()
n=len(s)
cnt=0
for i in range(n):
  if s[i]=='W':
    cnt+=1
ans=0
for i in range(n):
  if s[i]=='W':
    cnt--
  else:
    ans+=cnt
print(ans)
 
  

### FIXED CODE ###

s=input()
n=len(s)
cnt=0
for i in range(n):
  if s[i]=='W':
    cnt+=1
ans=0
for i in range(n):
  if s[i]=='W':
    cnt-=1
  else:
    ans+=cnt
print(ans)
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

#define ll long long
            
int main() {
    int L, R;
    cin >> L >> R;
  
    int range = R - L;
    vector<int> mod;
  
    if (range >= 2019) {
        cout << 0 << endl;
    } else {
        for (int i = 0; i < (range + 1); i++) {
            for (int j = 1; j <= (range - i); j++) {
                int ij = (L + i) * (L + i + j);
                mod.push_back(ij % 2019);
            }
        }
        vector<int>::iterator iter = min_element(mod.begin(), mod.end());
        cout << *iter << endl;
    }
  
    return 0;
}





### FIXED CODE ###

import math

L,R = list(map(int,input().split()))

if (R-L) >= 2019:
  print(0)
else:
  l = L % 2019
  r = l + (R - L)
  if r >= 2019:
    print(0)
  else:
    all_e = []
    for i in range(r-l+1):
      for j in range(r-l-i):
        all_e.append((l+i)*(l+i+j+1))
    for i in range(len(all_e)):
      all_e[i] = all_e[i] % 2019
    print(min(all_e))
N=int(input())
e_list = [[] for i in range(N)]
for i in range(N-1):
    a,b=list(map(int,input().split()))
    a,b=a-1,b-1
    e_list[a].append(b)
    e_list[b].append(a)

vi = 0 #時と場合によってここを変える
from collections import deque
Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
prev_list = [-1 for i in range(N)]
min_path_list = [10**27 for i in range(N)] #問題によりここを変える
min_path_list[vi] = 0
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            prev_list[v1]=v
            min_path_list[v1]=min(min_path_list[v1],min_path_list[v]+1) #問題によりここを変える

path = [N-1]
v=N-1
while prev_list[v]!=-1:
    path.append(prev_list[v])
    v=prev_list[v]

a=path[(min_path_list[N-1]-1)//2]
b=path[(min_path_list[N-1]-1)//2+1]
for i in range(len(e_list[a])):
    if e_list[a][i]==b:
        break
del e_list[a][i]

for i in range(len(e_list[b])):
    if e_list[b][i]==a:
        break
del e_list[b][i]

vi = 0 #時と場合によってここを変える

Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
count = 1
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            count+=1

if count>N-count:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###


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

S=[0]
s = 0
for i in range(N):
    s+=a[i]
    S.append(s)
ans=10**28
for i in range(1,N):
    ans=min(abs(S[N]-2*S[i]),ans)
print(ans)
def num2alpha(num):
    if num <= 26:  return chr(64 + num)
    elif num % 26 == 0:  return num2alpha(num // 26 - 1) + chr(90)
    return num2alpha(num // 26) + chr(64  num % 26)

N = int(input())
ans = num2alpha(N).lower()
print(ans)

### FIXED CODE ###

N = int(input())
d = "abcdefghijklmnopqrstuvwxyz"
ans = ""
N -= 1

while(N >= 0):
    ans += d[N % 26]
    N //= 26
    N -= 1
    
print(ans[::-1])
N = int(input())
nums = [int(i) for i in input().split()]
nums = list((set(nums)))
def compute_divs(n):
    divs = []
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs

if len(nums) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums[0])
    divs2 = compute_divs(nums[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in range(len(nums)):
            if nums[j] % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)

### FIXED CODE ###

N = int(input())
nums = [int(i) for i in input().split()]
nums_sorted = sorted(list((set(nums))), reverse=True)
def compute_divs(n):
    divs = []
    if n == 1: return [1]
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs
ans = 1
if len(nums_sorted) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums_sorted[0])
    divs2 = compute_divs(nums_sorted[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in nums:
            if j % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)
N = int(input())
A = [input() for _ in [0]*N]

for i,a in enumerate(A):
    b = a.split(".")
    if len(b)==1:
        A[i] = int(a)*10**9
        continue
    c = b[1]
    n = len(c)
    c += "0"*(9-n)
    A[i] = int(b[0] + c)

cnt = [[0]*20 for _ in [0]*20]
B = [None]*N
for k,a in enumerate(A):
    i = 0
    j = 0
    while a%2==0:
        a//=2
        i+=1
    while a%5==0:
        a//=5
        j+=1
    B[k] = (i,j)
    cnt[i][j] += 1

for i in range(1,20):
    i = 19-i
    for j in range(20):
        j = 19-j
        cnt[i][j] += cnt[i+1][j]

for i in range(20):
    i = 19-i
    for j in range(1,20):
        j = 19-j
        cnt[i][j] += cnt[i][j+1]

ans = 0
for i,j in B:
    me = int(i>=9 and j>=9)
    ans += cnt[18-i][18-j]-me

print(ans//2)

### FIXED CODE ###

N = int(input())
A = [input() for _ in [0]*N]

for i,a in enumerate(A):
    b = a.split(".")
    if len(b)==1:
        A[i] = int(a)*10**9
        continue
    c = b[1]
    n = len(c)
    c += "0"*(9-n)
    A[i] = int(b[0] + c)

cnt = [[0]*40 for _ in [0]*40]
B = [(0,0)]*N
for k,a in enumerate(A):
    i = 0
    j = 0
    while a%2==0:
        a//=2
        i+=1
    while a%5==0:
        a//=5
        j+=1
    B[k] = (i,j)
    cnt[i][j] += 1

for i in range(1,40):
    i = 39-i
    for j in range(40):
        j = 39-j
        cnt[i][j] += cnt[i+1][j]

for i in range(40):
    i = 39-i
    for j in range(1,40):
        j = 39-j
        cnt[i][j] += cnt[i][j+1]

ans = 0
for i,j in B:
    me = int(i>=9 and j>=9)
    ans += cnt[max(0,18-i)][max(0,18-j)]-me

print(ans//2)
N = int(input())
A = list(map(int, input().split()))



def merge(A, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = []
    R = []
    for i in range(n1):
        L.append(A[left + i])
    for i in range(n2):
        R.append(A[mid + i])

    L.append(float("inf"))
    R.append(float("inf"))
    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    count += right - left


def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

mergeSort(A,0,N)
ans = ""
for i in A:
    ans += str(i) + " "

print(ans)
print(count)

### FIXED CODE ###

def merge(a, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = a[left:left + n1] + [SENTINEL]
    R = a[mid:mid + n2] + [SENTINEL]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    count += right - left
 
def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)
 
SENTINEL = 1000000001
n = int(input())
a = list(map(int, input().strip().split()))
count = 0
merge_sort(a, 0, len(a))
print(' '.join(map(str, a)))
print(count)
n,w = map(int, input().split())
wv = []
for _ in range(n):
    data = list(map(int,input().split()))
    wv.append(data)


memo = [[-1] * (n+10)]*(w+10)

def solve(i,j):
    if i>=n:
        return 0

    if memo[i][j] != -1:
        return memo[i][j]

    weight=wv[i][0]
    value =wv[i][1]

    if j<weight: # can't push this item
        val = solve(i+1,j)
    else:# push or not push
        val =  max(solve(i+1,j-weight)+value, solve(i+1,j))

    memo[i][j] = val

    return val

print(solve(0,w))

### FIXED CODE ###

n,w = map(int, input().split())
wv = []
for _ in range(n):
    data = list(map(int,input().split()))
    wv.append(data)

dp = [[0 for i in range(w+1)] for j in range(n+1)]

for item in range(n):
    now_w=wv[item][0]
    now_v=wv[item][1]

    for weight in range(w+1):
        ans1=dp[item][weight]
        ans2=-1
        if weight - now_w >= 0:
            ans2=dp[item][weight-now_w]+now_v
        dp[item+1][weight] = max(ans1,ans2)

print(dp[n][w])
# coding: utf-8

# In[12]:


import numpy as np


# In[65]:


N,M = map(int, input().split())


# In[66]:


def usage(n):
    print('# 素因数')
    fct = factorize(n)
    print(fct, num(fct))
    
    print('# 約数')
    for div in divisorize(fct):
        print(div, num(div))


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


# In[67]:


def func(n):
    fct = factorize(n)
    ret = []
    for div in divisorize(fct):
        ret.append(num(div))
    
    return ret


# In[68]:


div = np.array(func(M))


# In[69]:


print(div[div < M/N].max())



### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[11]:


N,M = map(int, input().split())


# In[12]:


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# In[14]:


for x in make_divisors(M)[::-1]:
    if M//x >= N:
        ans = x
        break
print(ans)


# In[ ]:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if a[i]=a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if a[i]+1==a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)
import math
h,n = map(int,input().split())

dp = []
for i in range(n):
    a, b = map(int,input().split())
    if i == 0:
        for j in range(h):
            dp.append(math.ceil((j + 1) / a) * b)
    for j in range(h):
        if dp[j] > dp[j - a] + b:
            dp[j] = dp[j - a] + b
print(dp[h - 1])

### FIXED CODE ###

import math
h,n = map(int,input().split())


a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = []
for i in range(h + max(a)):
    dp.append(pow(2, 31) - 1)
dp[0] = 0

for i in range(1, len(dp)):
    '''
    tmp = dp[i]
    for j in range(n):
        tmp = min(tmp, dp[max(0, i-a[j])] + b[j])
    dp[i] = tmp
    '''
    dp[i] = min(dp[i - A] + B for A, B in zip(a, b))

print(min(dp[h:]))
n = input()

d = [1000 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]

def BFS(s):
  q = []
  q.append(s)
  d[s] = 0
  while q.length != 0:
    u = q.pop()
    for v in range(n):
      if M[u][v] == 0 and d[v] != 1000:
        d[v] = d[u] + 1
        q.push(v)
  for i in range(n):
    print i+1, d[i]

for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    M[G[0]-1][G[2+j]-1] = 1

BFS()

### FIXED CODE ###

n = input()
  
d = [-1 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
color = [0 for i in range(n)]
  
def BFS(s):
  color[0] = 1
  q = []
  q.append(s)
  d[s] = 0
  while len(q) != 0:
    u = q[0]
    q.pop(0)
    for v in range(n):
      if M[u][v] == 1 and color[v] == 0:
        color[v] = 1
        d[v] = d[u] + 1
        q.append(v)
  color[u] = 2
  for i in range(n):
    print i+1, d[i]
  
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    M[G[0]-1][G[2+j]-1] = 1
  
BFS(0)
import numpy as np

n = int(input())
A = np.array(list(map(int, input().split() )))
q = int(input())
m = list(map(int, input().split()))

def deci_to_bin_list(num, n):
    out = np.zeros(n, dtype='int')
    for i in range(n-1, -1, -1):
        denom = 2**i
        out[i] = num // denom
        num = num % denom
    return out

def sums_to_num(A, num):
    n = len(A)
    for cnt in range(2**n - 1):
        selected = deci_to_bin_list(cnt, n)
        if np.sum(A*selected) == num:
            return 'yes'
    return 'no'

for num in m:
    print(sums_to_num(A, num))    


### FIXED CODE ###

# used DP

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


dp = [[None]*(max(M)+1) for i in range(n)]

# we refer to the list dp only when i = 0, 1, ... , n-1 and m >= 0.
def solve(i, m):    
    if i >= n:
        return m == 0
    
    elif m < 0:
        return False
    
    elif dp[i][m] is not None:
        return dp[i][m]
    
    else:
        if m == 0:
            dp[i][m] = True
        elif solve(i+1, m):
            dp[i][m] = True
        elif solve(i+1, m - A[i]):
            dp[i][m] = True
        else:
            dp[i][m] =  False        
        return dp[i][m]

    
for num in M:
    print('yes' if solve(0, num) else 'no')