d={1:0,2:0}for _ in range(int(input())): a,b,c=map(int,input().split()) if a>b: d[1]+=c else: d[2]+=cm=max(d,key=d.get)print(f"{m} {d[m]}")