During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.

Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.

It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.

During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.


-----Input-----

The first line of the input contains an integer n (1 ≤ n ≤ 10^5) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 10^5; 1 ≤ k ≤ 10^5) — the number of previous unique solutions and the identifier of the participant.


-----Output-----

A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.


-----Examples-----
Input
2
0 1
1 1

Output
YES

Input
4
0 1
1 2
1 1
0 2

Output
NO

Input
4
0 1
1 1
0 1
0 2

Output
YES

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = [-1]*100001
p = 0
for i in range(n):
    x, k = map(int, input().split())
    if a[k] < x-1:
        p = 1
    else:
        a[k] = max(a[k],x)
if p:
    print('NO')
else:
    print('YES')

n = int(input())

m = []
d = dict()

for i in range(n):
    x, k = map(int, input().split())

    if k in d:
        r = d[k]
        if x > r+1:
            print('NO')
            return
        d[k] = max(r, x)
    else:
        if x != 0:
            print('NO')
            return
        d[k] = x

print('YES')

n = int(input())

tasks = {}
fail = False

for i in range(n):
	x, k = list(map(int, input().split()))
	if k not in tasks:
		if x == 0:
			tasks[k] = {x}
		else:
			fail = True
			break
	else:
		if x == 0:
			if x in tasks[k]:
				tasks[k].add(x)
			else:
				fail = True
				break
		elif x > 0:
			if (x-1) in tasks[k]:
				tasks[k].add(x)
			else:
				fail = True
				break
		else:
			fail = True
			break

if fail:
	print("NO")
else:
	print("YES")


def readln(): return tuple(map(int, input().split()))

n, = readln()
max_pref = [-1] * 100001
flag = True
for _ in range(n):
    x, k = readln()
    flag &= max_pref[k] + 1 >= x
    max_pref[k] = max(max_pref[k], x)
print('YES' if flag else 'NO')



n = int(input())

r = ["NO", "YES"]

d = {}

for _ in range(n):
    x, k = list(map(int, input().split(" ")))
    a = d.get(k, -1)
    if a + 1 < x:
        print(r[0])
        return
    elif a + 1 == x:
        d[k] = x
        
print(r[1])
    


p = {}
for i in range(int(input())):
    x, k = map(int, input().split())
    if k in p:
        if x == p[k] + 1: p[k] = x
        elif x > p[k]:
            print('NO')
            return
    elif x:
        print('NO')
        return
    else:
        p[k] = 0
print('YES')

n = int(input())
res = 'YES'
uch = {}
zap= [0,0]
for i in range(0, n):
    zap = list(map(int, input().split()))
    if zap[1] in uch:
        if zap[0] == uch[zap[1]] + 1:
            uch[zap[1]] = zap[0]
        else:
            if zap[0] > uch[zap[1]] + 1:
                res = 'NO'
    else:
        if zap[0] == 0:
            uch[zap[1]] = zap[0]
        else:
            res = 'NO'
print(res)



all = {}
n = int(input())
ans = True
for i in range(n):
    x_k = input().split()
    x = int(x_k[0])
    k = int(x_k[1])
    if k not in all:
        all[k] = -1
    if all[k] >= x:
        pass
    elif all[k]+1 != x:
        ans = False
        break
    else:
        all[k] = x


if ans:
    print("YES")
else:
    print("NO")

import sys
from array import array

f = sys.stdin
n = int(f.readline())
ans = 'YES'
submissions = [0]*n
i = 0
for line in f:
    arr = line.split(" ")
    x = int(arr[0])
    k = int(arr[1]) - 1
    while(k < 0 or k >= len(submissions)):
        submissions.extend([0]*len(submissions))
    if(submissions[k] < x):
        ans = 'NO'
        break
    if(submissions[k] == x):
        submissions[k] = submissions[k] + 1
    i = i + 1
    if(i >= n):
        break
print(ans)


#the basic idea is to use a dict to record every participant's submission

n = int(input())
participants = {}
order = True
while n:
	n -= 1
	x, k = list(map(int,input().split()))
	if k in participants:
		if x in participants[k]:
			continue
		elif x-1 in participants[k]:
			participants[k].add(x)
		else:
			order = False
			break
	else:
		if x != 0:
			order = False
			break
		tmp = set()
		tmp.add(x)
		participants[k] = tmp


if order:
    print("YES")
else:
    print("NO") 


import sys
from collections import defaultdict

n = int(sys.stdin.readline())
d = defaultdict(lambda:-1)
for i in range(0, n):
  x, k = map(int, sys.stdin.readline().split())
  z = d[k]
  if x == z + 1:
    d[k] = x
  elif x > z + 1:
    print('NO')
    return

print('YES')


import sys
#f = open('H:\\Portable Python 3.2.5.1\\test2.txt') 
f = sys.stdin
n = int(f.readline().strip())
people = {}
res = 'YES'
for i in range(n):
    x, k = list(map(int, f.readline().strip().split()))
    #print(x,people)
    if k in people:
        if x==people[k]+1:
            people[k] = x
        elif x<=people[k]:
            pass
        else:
            res='NO'
            break
    else:
        if x==0:
            people[k] = x
        else:
            res='NO'
            break    

print(res)


sol=int(input())
list1=[]
for i in range(10**5+1):
    list1.append([])
for i in range(sol):
    a,b=input().split()
    b=int(b)
    list1[b].append(a)
i=0
v=True
while i<10**5+1 and v:
    j=0
    z=-1
    while j<len(list1[i]) and v:
        if (int(list1[i][j])-z)==1:
            z=int(list1[i][j])
        elif int(list1[i][j])-z>1:
            v=False
        j+=1
    i+=1
if v==True:
    print("YES")
else:
    print("NO")


n = int(input())
d = {}
for i in range(n):
	p = list(map(int, input().split()))
	if p[0] == 0:
		d[p[1]] = d.get(p[1], 0)
	else:
		if p[0] - d.get(p[1], -1) > 1:
			print("NO")
			return
		d[p[1]] = max(d[p[1]], p[0])
print("YES")		


import sys
import math

n = int(sys.stdin.readline())

d = dict()
for i in range(n):
    x, k = [int(x) for x in (sys.stdin.readline()).split()]
    if k in d:
        t = d[k]
        if x not in t[1]:
            if(x - 1 == t[0]):
                t[0] = x
                t[1].add(x)
            else:
                print("NO")
                return
    else:
        if(x > 0):
            print("NO")
            return
            
        d[k] = [x, {x}]

print("YES")


c = [0] * 100001
for i in range(int(input())):
    x, k = map(int, input().split())
    if x == c[k]:
        c[k] += 1
    elif x > c[k]:
        print('NO')
        return
print('YES')

n = int(input())
p = 0
a = []
for _ in range(n):
    x, k = list(map(int, input().split()))
    while k > len(a):
        a.append(-1)
    k = k - 1
    if a[k] < x - 1:
        print('NO')
        return
    else:
        a[k] = max(x, a[k])
print('YES')

n = int(input())
ks = []
for i in range(100001):
  ks.append(-1)
v = True
for i in range(n):
  x, k = list(map(int, input().split()))
  if v:
    if x > ks[k] + 1:
      v = False
    elif x > ks[k]:
      ks[k] = x

if v:
  print("YES")
else:
  print("NO")


c = [0] * 100001
for i in range(int(input())):
    x, k = map(int, input().split())
    if x == c[k]:
        c[k] += 1
    elif x > c[k]:
        print('NO')
        return
print('YES')

def adds(s,x,k):
	if k in s.keys():
		xs=s[k]
		if x<=xs:
			return 0
		else:
			if x-1==xs:
				s[k]=x
				return 0
			else:
				return 1
	else:
		if x==0:
			s[k]=0
			return 0
		else:
			return 1

def corr(v):
	s=dict()
	for c in v:
		if adds(s,c[0],c[1]):
			return 0
	return 1

n=int(input())
v=[]
for c in range(n):
	x,k=map(int,input().split(' '))
	v.append((x,k))
if corr(v):
	print('YES')
else:
	print('NO')

c = [0] * 100001

for i in range(int(input())):

    x, k = list(map(int, input().split()))

    if x == c[k]:

        c[k] += 1

    elif x > c[k]:

        print('NO')

        return

print('YES')



# Made By Mostafa_Khaled


import sys
n = int(input())
c = [-1] * (10**5+1)
for i in range(n):
    x,k = list(map(int,input().split()))
    if c[k] < x-1:
        print("NO")
        return
    else:
        c[k] = max(c[k],x)

print("YES")


n = int(input())
user = 100001 * [-1]
for i in range(n):
  x, k = map(int, input().split())
  if user[k] == x - 1:
    user[k] = x
  elif user[k] < x - 1:
    print('NO')
    return
print('YES')

recovery = [-1]*100001
solution = int(input())
for s in range(solution):
    sol,user = map(int,input().split())
    if recovery[user] == sol - 1:
        recovery[user] = sol
    elif recovery[user] >= sol:
        continue
    else:
        print('NO'); return
print ('YES')

recovery = [-1]*100001
solution = int(input())
for s in range(solution):
    sol,user = map(int,input().split())
    # Consecutive numbers should be 1 apart 
    if recovery[user] == sol - 1:
        recovery[user] = sol
    # Skip duplicates
    elif recovery[user] >= sol:
        continue
    else:
    # exit out of the program 
        print('NO'); return
print ('YES')