n, m, k = input().split() ,input().split(),input().split(),
result = []
sp = []
g = 0
w = 0
w2 = 0
m3 = []
total = 0
for i in m:
    result.append(i)
for p in n:
    w += int(p)
for z in k:
    w2 += int(z)
if w2 == w:
    print('NO')
else:
    xss = 'YES'
    a = n[0]
    b = n[1]
    c = n[2]
    a2 = 0
    b2 = 0
    c2 = 0
    s = input().split()
    for _ in s:
        sp.append(_)
        if _ in a:
            a2 = _
            g += 1
        elif _ in b:
            b2 = _
            g += 1
        elif _ in c:
            c2 = _
            g += 1
    for x in range(int(b)):
        sc = input().split()
        for o in sc:
            sp.append(o)
        for sx in sp:
            if sx == 1:
                total = 1
    print(xss)
    print(g)
    
    

        
        
        
        
            
            
    

