N=int(input()) c=[] for i in range(N): l,r=map(int,input().split()) c.append([l,r-l]) dp=[[0]*N for _ in range(1<