t = int(input())

dictionary = {}

list_c = []
for _ in range(t):
    n = int(input())

    for i in range(n):
        a, b, c = map(int, input().split())
        list_c.append(c)

print(max(list_c))
