n = int(raw_input());
raw_input();
a = [int(x) for x in raw_input().split()]

for i in range (n - 1):
    raw_input();
    inputs = [int(x) for x in raw_input().split()]
    a = set(a) & set(inputs)
print -sum(a )