import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes") no = lambda :print("no");No = lambda :print("No") ####################################################################### from collections import deque N,M=map(int,input().split()) G=[[] for _ in range(N)] for i in range(M): a,b=map(int,input().split()) G[a-1].append(b-1) G[b-1].append(a-1) C=list(map(int,input().split())) C = [c-1 for c in C] W=list(map(int,input().split())) Group=[[-1]*N for _ in range(2**10)] cost=[0]*(2**10) for i in range(1,2**10): T=0 w=0 S=set() c=0 for j in range(10): if((i>>j)&1): S.add(j+1) c+=W[j] cost[i]=c # que=deque([0]) # Group[i][0]=w while T>C[p]&1 and i>>C[q]&1 and Group[i][q]==-1: Group[i][q]=Group[i][p] que.append(q) while T