mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) xyz = [] for _ in range(N): a, b, c = map(int, input().split()) xyz.append(sorted([a, b, c]) + [0]) if N == 1: print(max(xyz[0])) exit() while True: xyz.sort(key= lambda p: p[1], reverse=True) ok = 1 for i in range(N-1): if xyz[i+1][0] > xyz[i][0]: ok = 0 x, y, z, w = xyz[i+1] if w == 0: xyz[i+1] = [x, z, y, 1] elif w == 1: xyz[i+1] = [z, y, x, 2] else: assert False if ok: ans = 0 for i in range(N): ans += xyz[i][2] break print(ans) if __name__ == '__main__': main()