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