n = gets.to_i
h = {}
a = []
n.times do
    k, *a = gets.split.map(&:to_i)
    x = 0
    a.each do |i|
        h[i] ||= h.size
        x |= (1 << h[i])
    end
    a << x
end
max = 0
((1 << h.size) - 1).downto(0) do |x|
    next if x.to_s(2).count(?1) * h.size <= max
    sum = 0
    k = 0
    a.each do |y|
        next if y & x != x
        k += 1
        sum |= y
    end
    next if k < 3
    c = sum.to_s(2).count(?1) * x.to_s(2).count(?1)
    max = c if c > max
end
p max

