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 x in range(n+1): for px in permutations(range(n),x): for y in range(m+1): for py in permutations(range(m),y): i = j = w = v = 0 while i