na, nb, nc, nd, m = input().split()
na, nb, nc, nd, m = int(na), int(nb), int(nc), int(nd), int(m)
# 相同答案标号,0代表没有约束,其它数字相同的说明答案相同
same = [0 for i in range(13)]
# 相同答案题组
ss = {}
# 求组合数
def Com(n, m):
if m < 0&nbs***bsp;n < 0:
return 0
if n < m:
return 0
if n == 0 and m == 0:
return 1
if n == 0&nbs***bsp;m == 0:
return 1
p = 1
q = 1
while m > 0:
p *= n
q *= m
n -= 1
m -= 1
return int(p / q)
for i in range(m):
x, y = input().split()
x, y = int(x), int(y)
# 生成same数组
if same[x] == same[y] == 0:
same[x] = same[y] = max(same) + 1
elif same[x] != 0 and same[y] != 0:
for i in range(13):
if same[i] == same[y]:
same[i] = same[x]
elif same[x] != 0 and same[y] == 0:
same[y] = same[x]
elif same[x] == 0 and same[y] != 0:
same[x] = same[y]
fix_cout = 0
for i in range(13):
if same[i] != 0:
if str(same[i]) not in ss.keys():
# 相同答案的一组题号是一个集合
ss[str(same[i])] = set()
ss[str(same[i])].add(i)
fix_cout += 1
res = 12 - fix_cout # 剩余多少自由项(没有规定答案与其它题相同的)
keys = list(ss.keys())
su = 0
# 对相同答案组深度遍历 (4^组数)
def alloc(k, i, s):
global su
if i >= len(k):
# print(s)
t = Com(res, na - s['A']) * Com(res - (na - s['A']), nb - s['B']) * Com(res - (na - s['A']) - (nb - s['B']), nc - s['C']) * Com(res - (na - s['A']) - (nb - s['B']) - (nc - s['C']), nd - s['D'])
su += t
# print(t)
return
for c in ['A','B','C','D']:
s[c] += len(ss[k[i]])
alloc(k, i + 1, s)
s[c] -= len(ss[k[i]])
alloc(keys, 0, {'A':0,'B':0,'C':0,'D':0})
print(su)