from itertools import permutations n,m,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) d = list(map(int,input().split())) ans = 0 for px in permutations(range(n)): for py in permutations(range(m)): i = j = w = v = 0 while i