S=1 for V,T in sorted([tuple(map(int,input().split()))for _ in range(int(input()))],key=sum):S|=(S&(2**T-1))<