Vasya has an array a_1, a_2, ..., a_n.

You don't know this array, but he told you m facts about this array. The i-th fact is a triple of numbers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n) and it means:

  * if t_i=1 then subbarray a_{l_i}, a_{l_i + 1}, ..., a_{r_i} is sorted in non-decreasing order; 
  * if t_i=0 then subbarray a_{l_i}, a_{l_i + 1}, ..., a_{r_i} is not sorted in non-decreasing order. A subarray is not sorted if there is at least one pair of consecutive elements in this subarray such that the former is greater than the latter. 



For example if a = [2, 1, 1, 3, 2] then he could give you three facts: t_1=1, l_1=2, r_1=4 (the subarray [a_2, a_3, a_4] = [1, 1, 3] is sorted), t_2=0, l_2=4, r_2=5 (the subarray [a_4, a_5] = [3, 2] is not sorted), and t_3=0, l_3=3, r_3=5 (the subarray [a_3, a_5] = [1, 3, 2] is not sorted).

You don't know the array a. Find any array which satisfies all the given facts.

Input

The first line contains two integers n and m (2 ≤ n ≤ 1000, 1 ≤ m ≤ 1000).

Each of the next m lines contains three integers t_i, l_i and r_i (0 ≤ t_i ≤ 1, 1 ≤ l_i < r_i ≤ n).

If t_i = 1 then subbarray a_{l_i}, a_{l_i + 1}, ... , a_{r_i} is sorted. Otherwise (if t_i = 0) subbarray a_{l_i}, a_{l_i + 1}, ... , a_{r_i} is not sorted.

Output

If there is no array that satisfies these facts in only line print NO (in any letter case).

If there is a solution, print YES (in any letter case). In second line print n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the array a, satisfying all the given facts. If there are multiple satisfying arrays you can print any of them.

Examples

Input


7 4
1 1 3
1 2 5
0 5 6
1 6 7


Output


YES
1 2 2 3 5 4 4


Input


4 2
1 1 4
0 2 3


Output


NO

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Greedy algorithms

Implementation

Constructive algorithms


Solutions:
def main():
	(n, m) = map(int, input().split())
	l = []
	s = []
	r = []
	d = [0] * n
	for _ in range(m):
		(a, b, c) = map(int, input().split())
		s.append(a)
		b -= 1
		l.append(b)
		c -= 1
		r.append(c)
		if a == 1:
			d[b] += 1
			d[c] -= 1
	dx = [-1] * (n - 1)
	add = 0
	for i in range(n):
		add += d[i]
		if add > 0:
			dx[i] = 0
	res = [0] * n
	res[0] = n
	for i in range(1, n):
		res[i] = res[i - 1] + dx[i - 1]
	nxt = [0] * n
	nxt[n - 1] = n - 1
	for i in range(n - 2, -1, -1):
		if res[i] <= res[i + 1]:
			nxt[i] = nxt[i + 1]
		else:
			nxt[i] = i
	for i in range(m):
		if s[i] != (nxt[l[i]] >= r[i]):
			print('NO')
			return
	print('YES')
	for x in res:
		print(x, end=' ')
	print()
main()


(n, m) = map(int, input().split())
a = [0] * n
unorder = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if not t:
		unorder.append((l, r))
		continue
	for i in range(l, r):
		a[i] = 1
for (l, r) in unorder:
	if set(a[l:r]) == {1}:
		print('NO')
		exit(0)
print('YES')
v = 10 ** 5
for e in a:
	if e:
		v += 1
	else:
		v -= 1
	print(v, end=' ')


(n, m) = map(int, input().split(' '))
a = [[0, 0, 0] for i in range(m + 1)]
mark = [False] * (n + 1)
for i in range(1, m + 1):
	(a[i][0], a[i][1], a[i][2]) = map(int, input().split(' '))
	if a[i][0]:
		for j in range(a[i][1], a[i][2]):
			mark[j] = True
finally_failed = False
for i in range(1, m + 1):
	flag = False
	if not a[i][0]:
		for j in range(a[i][1], a[i][2]):
			if not mark[j]:
				flag = True
				break
		if not flag:
			print('NO')
			finally_failed = True
			break
if not finally_failed:
	cur_value = n + 1
	output_list = list()
	for i in range(1, n + 1):
		if not mark[i - 1]:
			cur_value -= 1
		output_list.append(str(cur_value))
	print('YES')
	print(' '.join(output_list))


import collections

def solution(n, m, facts):
	pos = []
	neg = []
	for (t, l, r) in facts:
		lst = pos if t == 1 else neg
		lst.append((l, r))
	pos.sort()
	neg.sort()
	state = [-1] * n
	for (l, r) in pos:
		state[l:r] = [0] * (r - l)
	for (l, r) in neg:
		if not any(state[l:r]):
			print('NO')
			return
	res = [1001] * n
	for i in range(1, n):
		if state[i] == 0:
			res[i] = res[i - 1] + 1
		else:
			res[i] = res[i - 1] - 1
	print('YES')
	print(' '.join(map(str, res)))
(n, m) = map(int, input().split())
facts = []
for i in range(m):
	facts.append([int(val) for val in input().split()])
solution(n, m, facts)


import sys
(n, m) = list(map(int, sys.stdin.readline().strip().split()))
C = []
D = []
for i in range(0, m):
	(t, l, r) = list(map(int, sys.stdin.readline().strip().split()))
	l = l - 1
	r = r - 1
	if t == 1:
		C.append([l, r])
	else:
		D.append([l, r])
C.sort()
x = len(C)
E = []
i = 0
while i < x:
	a = C[i][0]
	b = C[i][1]
	i = i + 1
	if i != x:
		while C[i][0] <= b:
			b = max([b, C[i][1]])
			i = i + 1
			if i == x:
				break
	E.append([a, b])
v = True
for d in D:
	for e in E:
		if d[0] >= e[0] and d[1] <= e[1]:
			v = False
if v == False:
	print('NO')
else:
	L = [10000 - i for i in range(0, n)]
	for e in E:
		for i in range(e[0] + 1, e[1] + 1):
			L[i] = L[i - 1]
	L = list(map(str, L))
	print('YES')
	print(' '.join(L))


import sys

def input():
	return sys.stdin.readline().rstrip()
(n, m) = map(int, input().split())
NotSorted = []
seq = [0] * (n + 2)
ans = [0] * (n + 2)
ans[1] = 1
ans[-1] = 10 ** 20
query = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	if t == 0:
		query.append((l, r))
	if t == 1:
		for j in range(l + 1, r + 1):
			ans[j] = 1
	else:
		NotSorted.append((l, r))
for (l, r) in NotSorted:
	for j in range(l, r + 2):
		if ans[j] == 0:
			ans[j] = -1
for i in range(2, n + 1):
	ans[i] += ans[i - 1]
for i in range(1, n + 1):
	ans[i] += 100000
flag = True
for (l, r) in query:
	if all((ans[i] <= ans[i + 1] for i in range(l, r))):
		flag = False
		break
if flag == False:
	print('NO')
	exit()
else:
	print('YES')
	print(*ans[1:n + 1])
	exit()


(n, m) = map(int, input().split())
p = [(i, i) for i in range(n)]
a = []
nn = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 1:
		l0 = p[l][0]
		r0 = p[r][1]
		for j in range(l0, r0 + 1):
			p[j] = (l0, r0)
	if t == 0:
		nn.append((l, r))
flag = True
for (l, r) in nn:
	if p[l] == p[r]:
		flag = False
		break
if flag:
	k = 1001
	i = 0
	print('YES')
	a.append(str(k))
	for i in range(1, n):
		if p[i] == p[i - 1]:
			k += 1
		else:
			i += 1
			k = 1001 - i
		a.append(str(k))
	print(' '.join(a))
else:
	print('NO')


import sys

def generate_a_at_sorted_positions(n, sorted_segment):
	sorted_segment.sort()
	union_sorted_segment = []
	a = [n - i for i in range(n)]
	if len(sorted_segment) == 0:
		return a
	(current_low, max_high) = sorted_segment[0]
	for segment in sorted_segment:
		if segment[0] < max_high:
			max_high = max(max_high, segment[1])
		else:
			union_sorted_segment.append((current_low, max_high))
			current_low = segment[0]
			max_high = segment[1]
	union_sorted_segment.append((current_low, max_high))
	for segment in union_sorted_segment:
		for j in range(segment[0] + 1, segment[1]):
			a[j] = a[j - 1]
	return a

def check_non_sorted_position(a, non_sorted_segment):
	for segment in non_sorted_segment:
		found_decreasing_position = False
		for j in range(segment[0] + 1, segment[1]):
			if a[j] < a[j - 1]:
				found_decreasing_position = True
		if not found_decreasing_position:
			return False
	return True
(n, m) = map(int, sys.stdin.readline().split())
(sorted_segment, other_segment) = ([], [])
for line in sys.stdin:
	(t, low, high) = map(int, line.split())
	if t == 1:
		sorted_segment.append((low - 1, high))
	else:
		other_segment.append((low - 1, high))
a = generate_a_at_sorted_positions(n, sorted_segment)
if check_non_sorted_position(a, other_segment):
	print('YES')
	for x in a:
		print(x, end=' ')
else:
	print('NO')
sys.stdin.close()


from sys import exit
(n, m) = map(int, input().split())
tmp = []
s = [0] * (n - 1)
for i in range(m):
	(t, i, j) = map(int, input().split())
	if t == 1:
		s[i - 1:j - 1] = [1] * (j - i)
	else:
		tmp += [(i, j)]
ans = [-1]
cnt = 0
for i in range(1, n):
	if s[i - 1] == 1:
		ans.append(cnt)
		cnt += 1
	else:
		cnt = 0
		ans.append(-i - 1)
for (i, j) in tmp:
	if ans[i - 1:j] == sorted(ans[i - 1:j]):
		print('NO')
		exit()
print('YES')
print(*[i + 10 ** 7 for i in ans])


import math
(n, m) = map(int, input().split())
ans = [-(i + 1) for i in range(n)]
query = []
chec = []
cnt = 1
for i in range(m):
	(x, y, z) = map(int, input().split())
	if x == 1:
		query.append([y, z])
	else:
		chec.append([y, z])
		continue
query.sort()
for i in range(len(query)):
	t = query[i]
	maxa = -math.inf
	for j in range(t[0] - 1, t[1]):
		maxa = max(maxa, ans[j])
	for j in range(t[0] - 1, t[1]):
		ans[j] = maxa
flag = 0
glag = 0
for i in range(len(chec)):
	x = chec[i]
	flag = 1
	for j in range(x[0], x[1]):
		if ans[j] < ans[j - 1]:
			flag = 0
			break
	if flag == 1:
		glag = 1
		break
if glag == 0:
	print('YES')
	r = min(ans)
	for i in range(len(ans)):
		ans[i] += abs(r) + 1
	print(*ans)
else:
	print('NO')


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def pref(a, n, f):
	pre = [0] * n
	if f == 0:
		pre[0] = a[0]
		for i in range(1, n):
			pre[i] = a[i] + pre[i - 1]
	else:
		pre[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			pre[i] = pre[i + 1] + a[i]
	return pre
for _ in range(1):
	(n, m) = cin()
	q1 = []
	q0 = []
	cr = [-1] * n
	f = 0
	for i in range(m):
		(a, b, c) = cin()
		if a == 1:
			for j in range(b, c):
				cr[j] = 0
		else:
			q0 += [[b - 1, c - 1]]
	cr[0] = 50001
	for i in range(1, n):
		cr[i] += cr[i - 1]
	for (i, j) in q0:
		x = sorted(cr[i:j + 1])
		if x == cr[i:j + 1]:
			f = 1
			break
	if f:
		print('NO')
	else:
		print('YES')
		print(*cr)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
(n, m) = mapin()
d = [-1] * n
io = [[], []]
for i in range(m):
	(t, l, r) = mapin()
	l -= 1
	r -= 1
	io[t].append([l, r])
	if t == 1:
		for j in range(l, r):
			d[j] = 0
fl = 1
a = [0] * n
a[0] = n
for i in range(1, n):
	a[i] = a[i - 1] + d[i - 1]
for i in io[1]:
	ff = 1
	for j in range(i[0], i[1]):
		if a[j] <= a[j + 1]:
			continue
		ff = 0
		break
	if ff == 0:
		fl = 0
		break
for i in io[0]:
	ff = 0
	for j in range(i[0], i[1]):
		if a[j] > a[j + 1]:
			ff = 1
			break
	if ff == 0:
		fl = 0
		break
if fl:
	print('YES')
	print(*a)
else:
	print('NO')


import sys
input = sys.stdin.readline
from collections import *
(n, m) = map(int, input().split())
up = [False] * (n - 1)
tlr = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 1:
		for i in range(l, r):
			up[i] = True
	else:
		tlr.append((t, l, r))
ans = []
now = 1 + up.count(False)
for i in range(n):
	ans.append(now)
	if i < n - 1 and (not up[i]):
		now -= 1
flag = True
for (_, l, r) in tlr:
	f = False
	for i in range(l, r):
		if ans[i] > ans[i + 1]:
			f = True
	flag &= f
if flag:
	print('YES')
	print(*ans)
else:
	print('NO')


from collections import defaultdict, Counter
(n, x) = [int(i) for i in input().split()]
temp = []
arr = [-1] * n
for i in range(x):
	(sw, l, r) = [int(i) for i in input().split()]
	temp.append([sw, l, r])
	if sw == 1:
		for i in range(l - 1, r - 1):
			arr[i] = 0
if all([min(arr[l - 1:r - 1]) == -1 for (sw, l, r) in temp if sw == 0]):
	ans = [n]
	for i in range(n - 1):
		ans.append(ans[-1] + arr[i])
	print('YES')
	print(*ans)
else:
	print('NO')


(n, m) = map(int, input().split())
qr = []
cnt = [0] * (n + 1)
a = [0] * (n + 1)
for i in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		cnt[l] += 1
		cnt[r] -= 1
	else:
		qr.append({l, r})
l = -1
s = 0
for i in range(1, n + 1):
	s += cnt[i]
	if s != 0 and l == -1:
		l = i
	if s == 0 and l != -1:
		for j in range(l, i + 1):
			a[j] = n - l + 1
		l = -1
for i in range(1, n + 1):
	if a[i] == 0:
		a[i] = n - i + 1
for (l, r) in qr:
	if a[l] == a[r]:
		print('NO')
		exit(0)
print('YES')
for i in range(1, n + 1):
	print(a[i], end=' ')


(n, m) = map(int, input().split())
c = [False] * (n + 1)
q = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	if t:
		for j in range(l, r):
			c[j] = True
	else:
		q.append((l, r))
for i in range(len(q)):
	for el in range(q[i][0], q[i][1]):
		if not c[el]:
			break
	else:
		print('No')
		exit()
inf = int(10000000.0)
print('Yes')
for i in range(n):
	if not c[i]:
		inf -= 1
	print(inf, end=' ')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
tlr = [list(map(int, input().split())) for i in range(m)]
tlr.sort(key=lambda x: x[1])
srt = []
for (t, l, r) in tlr:
	if t == 0:
		continue
	if not srt:
		srt.append([l, r])
		continue
	if srt[-1][1] >= r:
		continue
	if srt[-1][1] >= l:
		srt[-1][1] = r
	else:
		srt.append([l, r])
ans = [10 ** 8 - i for i in range(n)]
for (x, y) in srt:
	for i in range(x, y):
		ans[i] = ans[i - 1] + 1
for (t, l, r) in tlr:
	if t == 0:
		if sorted(ans[l - 1:r]) == ans[l - 1:r]:
			print('NO')
			exit()
print('YES')
print(*ans)


import sys
from itertools import accumulate
(N, M) = map(int, input().split())
TLR = [tuple(map(int, input().split())) for _ in range(M)]
TLR.sort(reverse=True)
table = [False] * (N + 1)
for i in range(M):
	(t, l, r) = TLR[i]
	l -= 1
	r -= 1
	if not t:
		break
	table[l] += 1
	table[r] -= 1
	if i == M - 1:
		i += 1
stp = i
table = list(accumulate(table))
table = [1 if t > 0 else 0 for t in table[:-1]]
table += [0]
col = [-1] * N
ctr = 10000
for i in range(N):
	if table[i - 1] == 0:
		ctr -= 1
	if table[i - 1] == 1 or table[i] == 1:
		col[i] = ctr
for i in range(stp, M):
	(_, l, r) = TLR[i]
	l -= 1
	r -= 1
	if col[l] == col[r] > 0:
		break
else:
	print('YES')
	Ans = [10000] * N
	for i in range(N):
		if col[i] < 0 or col[i - 1] != col[i]:
			Ans[i] = Ans[i - 1] - 1
		else:
			Ans[i] = Ans[i - 1]
	print(*Ans)
	sys.exit()
print('NO')


(n, m) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(m)]
b = [-1] * n
for (t, l, r) in a:
	if t == 1:
		b[l:r] = [0] * (r - l)
ok = all((min(b[l:r]) == -1 for (t, l, r) in a if t == 0))
if ok:
	b[0] = n
	for i in range(1, len(b)):
		b[i] += b[i - 1]
	print('YES')
	print(*b)
else:
	print('NO')


def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))

class UnionFind:

	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)

	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if self.rank[x] < self.rank[y]:
			self.par[x] = y
		else:
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def same_check(self, x, y):
		return self.find(x) == self.find(y)

def union(uf, l, r):
	origin = uf.par[r]
	for idx in range(l, r + 1):
		if uf.par[idx] == origin:
			return
		uf.union(idx, r)
	return
(n, m) = getList()
uf = UnionFind(n)
zeros = []
for i in range(m):
	(t, l, r) = getList()
	if t == 0:
		zeros.append((l, r))
	else:
		union(uf, l, r)
for z in zeros:
	(a, b) = z
	if uf.find(a) == uf.find(b):
		print('NO')
		import sys
		sys.exit()
print('YES')
tmp = 10000
cur = 0
ans = []
for i in range(n):
	pr = uf.find(i + 1)
	if pr == cur:
		tmp += 1
	else:
		tmp -= 1
	ans.append(str(tmp))
	cur = pr
print(' '.join(ans))


(n, m) = [int(x) for x in input().split()]
ARR = [0 for i in range(n - 1)]
BAADME = []
for _ in range(m):
	(a, l, r) = [int(x) for x in input().split()]
	if a == 1:
		for e in range(l - 1, r - 1):
			ARR[e] = 1
	else:
		BAADME.append([l, r])
flag = 0
for [l, r] in BAADME:
	cflag = 0
	for e in range(l - 1, r - 1):
		if ARR[e] == 0:
			cflag = 1
			break
	if cflag == 0:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	BARR = [1]
	start = 1
	for i in range(n - 2, -1, -1):
		if ARR[i] == 0:
			start += 1
		BARR.append(start)
	for i in range(n - 1, -1, -1):
		print(BARR[i], end=' ')


def solve():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	sorted_bounds = []
	unsorted_bounds = []
	for i in range(m):
		(t, l, r) = input().split()
		if int(t) == 1:
			sorted_bounds.append([int(l), int(r)])
		else:
			unsorted_bounds.append([int(l), int(r)])
	for i in range(len(unsorted_bounds)):
		for j in range(len(sorted_bounds)):
			if is_inside(sorted_bounds[j], unsorted_bounds[i]):
				print('NO')
				quit()
	r = [0] * (n - 1)
	for b in sorted_bounds:
		r[b[0] - 1:b[1] - 1] = [1] * (b[1] - b[0])
	a = [0] * n
	current = n
	a[0] = current
	for i in range(n - 1):
		if r[i] == 0:
			current -= 1
		a[i + 1] = current
	for b in unsorted_bounds:
		if a[b[0] - 1] == a[b[1] - 1]:
			print('NO')
			quit()
	print('YES')
	print(' '.join(map(str, a)))

def is_inside(f, s):
	return f[0] <= s[0] and s[1] <= f[1]
solve()


def naiveSolve():
	return

def main():
	(n, m) = readIntArr()
	a = list(range(n, 0, -1))
	tlr = []
	for _ in range(m):
		(t, l, r) = readIntArr()
		l -= 1
		r -= 1
		tlr.append([t, l, r])
	isInc = [False] * n
	for (t, l, r) in tlr:
		if t == 1:
			for i in range(l, r):
				isInc[i] = True
	for i in range(n):
		if isInc[i]:
			a[i + 1] = a[i]

	def rangeCheck(l, r):
		for i in range(l + 1, r + 1):
			if a[i] < a[i - 1]:
				return False
		return True
	checkOk = True
	for (t, l, r) in tlr:
		if t == 1 and (not rangeCheck(l, r)):
			checkOk = False
		if t == 0 and rangeCheck(l, r):
			checkOk = False
	if checkOk:
		print('YES')
		oneLineArrayPrint(a)
	else:
		print('NO')
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


import sys
zz = 1
sys.setrecursionlimit(10 ** 5)
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def ii():
	return input().rstrip()

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print('Case #' + str(tc) + ':', ans)

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
uu = t

def find(i):
	if i == a[i]:
		return i
	a[i] = find(a[i])
	return a[i]

def union(x, y):
	(xs, ys) = (find(x), find(y))
	if xs != ys:
		if rank[ys] > rank[xs]:
			(xs, ys) = (ys, xs)
		a[ys] = xs
		rank[xs] += 1
while t > 0:
	t -= 1
	(n, m) = mi()
	a = []
	b = []
	for i in range(m):
		(typ, l, r) = mi()
		if typ == 1:
			a.append([l, r])
		else:
			b.append([l, r])
	a.sort()
	d = []
	l = r = -1
	for i in range(len(a)):
		if i == 0:
			l = a[i][0]
			r = a[i][1]
		elif a[i][0] > r:
			d.append([l, r])
			l = a[i][0]
			r = a[i][1]
		else:
			r = max(r, a[i][1])
	if l != -1 and r != -1:
		d.append([l, r])
	ans = [0] * (n + 1)
	rank = [0] * (n + 1)
	c = n * n + 1
	a = [i for i in range(n + 1)]
	for (i, j) in d:
		for l in range(i, j + 1):
			ans[l] = c
			if l > i:
				union(l, l - 1)
		c -= n + 1
	for i in range(1, n + 1):
		a[i] = find(i)
	for (i, j) in b:
		if find(i) == find(j):
			print('NO')
			exit(0)
	print('YES')
	if ans.count(0) == len(ans):
		for i in range(1, n + 1):
			ans[i] = c
			c -= n - 1
	else:
		p = ans.index(n * n + 1)
		for j in range(p - 1, -1, -1):
			if ans[j] == 0:
				ans[j] = ans[j + 1] + 1
		for j in range(p + 1, n + 1):
			if ans[j] == 0:
				ans[j] = ans[j - 1] - 1
	print(*ans[1:])


N = int(1000.0 + 3)
is_less = [0] * N
not_sorted = []
(n, m) = map(int, input().split())
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		for i in range(l, r):
			is_less[i] = 1
	else:
		not_sorted.append((l, r))
for i in not_sorted:
	if min(is_less[i[0]:i[1]]) == 1:
		print('NO')
		exit()
print('YES')
(it, res) = (int(100000.0), [])
for i in range(n):
	res.append(it)
	it -= is_less[i + 1] == 0
print(*res)


R = lambda : map(int, input().split())
(n, m) = R()
lst = [0] * n
lst_hash = []
for i in range(m):
	(t, l, r) = R()
	if t == 1:
		for j in range(l, r):
			lst[j] = 1
	else:
		lst_hash.append((l, r))
for (i, j) in lst_hash:
	if set(lst[i:j]) == {1}:
		print('no')
		exit()
print('yes')
val = 50001
for i in lst:
	if i == 1:
		val += 1
	else:
		val -= 1
	print(val)


import sys
(n, m) = map(int, input().split())
a = [1] * n
for i in range(n):
	a[i] = -(n - i)
Ok = True
srt = []
for ti in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 1:
		v = abs(a[l])
		for j in range(l, r):
			a[j] = v
		if a[r] > 0:
			over = a[r]
			l = r + 1
			while l < n and a[l] == over:
				a[l] = v
				l += 1
		a[r] = v
	else:
		srt.append((l, r))
for i in range(n):
	if a[i] < 0:
		a[i] = -a[i]
for i in range(len(srt)):
	(l, r) = srt[i]
	cnt = 0
	for j in range(l, r):
		if a[j] > a[j + 1]:
			cnt += 1
			break
	if cnt == 0:
		Ok = False
if Ok:
	print('YES')
	print(' '.join(map(str, a)))
else:
	print('NO')


ints = [int(x) for x in input().split()]
n = ints[0]
m = ints[1]
increasingSequence = [-1 for i in range(n)]
increasingSequence[0] = 0
decreasingSequences = []
for i in range(m):
	inArr = [int(x) for x in input().split()]
	if inArr[0] == 1:
		for j in range(inArr[1], inArr[2]):
			increasingSequence[j] = 0
	else:
		decreasingSequences.append([inArr[1], inArr[2]])
pos = True
for item in decreasingSequences:
	isThere = False
	for j in range(item[0], item[1]):
		if increasingSequence[j] == -1:
			isThere = True
			break
	if isThere == False:
		pos = False
		break
if pos == False:
	print('NO')
else:
	print('YES')
	p = 1000
	for i in range(n):
		if increasingSequence[i] == -1:
			p -= 1
		print(p, end=' ')


(n, m) = list(map(int, input().split()))
s = [[], []]
for i in range(m):
	(t, l, r) = list(map(int, input().split()))
	s[t] += [[l, r]]
yes = True
lm = [-1] * (n - 1)
for r in s[1]:
	for p in range(r[0] - 1, r[1] - 1):
		lm[p] = 0
for r in s[0]:
	if sum(lm[r[0] - 1:r[1] - 1]) == 0:
		yes = False
		break
if not yes:
	print('NO')
else:
	print('YES')
	a = [500000000]
	for i in range(n - 1):
		a += [a[-1] + lm[i]]
	print(*a)


(n, m) = map(int, input().split())
inp = [[0, 0] for _ in range(n + 1)]
for _ in range(m):
	(t, li, r) = map(int, input().split())
	if t:
		inp[li][1] += 1
		inp[r][1] -= 1
	else:
		inp[r][0] = max(inp[r][0], li)
ans = []
cur = 1002
cur0 = 0
cur1 = 0
for (i, (inp0, inp1)) in enumerate(inp):
	if cur0 < inp0:
		print('NO')
		break
	cur1 += inp1
	if not cur1:
		cur -= 1
		cur0 = i
	ans.append(cur)
else:
	print('YES')
	ans.pop()
	print(*ans)


def fillSorted(a, sector):
	for i in range(sector[0] - 1, sector[1] - 1, 1):
		a[i] = 1
	return a

def isUnsortable(a, sector):
	for i in range(sector[0] - 1, sector[1] - 1, 1):
		if a[i] == 'n':
			return True
	return False
(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append('n')
sorted = []
unsorted = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	if t:
		sorted.append([l, r])
	else:
		unsorted.append([l, r])
for sector in sorted:
	a = fillSorted(a, sector)
for sector in unsorted:
	if not isUnsortable(a, sector):
		print('NO')
		exit(0)
Ans = [1000]
for i in range(len(a) - 1):
	if a[i] == 1:
		Ans.append(Ans[i] + 1)
	else:
		Ans.append(Ans[i] - 1)
print('YES')
print(*Ans)


(n, m) = map(int, input().split(' '))
d = []
for _ in [0] * n:
	d.append(1)
checkList = []
for _ in [0] * m:
	(t, l, r) = map(int, input().split())
	if t == 1:
		for i in range(l, r):
			d[i] = 2000
	else:
		checkList.append((l, r))
for item in checkList:
	bCheck = False
	for i in range(item[0], item[1]):
		if d[i] != 2000:
			bCheck = True
	if not bCheck:
		print('NO')
		exit(0)
print('YES')
ans = 2000
for item in d:
	res = item
	if item != 2000:
		ans -= 1
		res = ans
	print(ans, end=' ')


def go():
	(n, m) = [int(i) for i in input().split(' ')]
	a = [10000] * (n + 1)
	x = [0] * (n + 1)
	queries = []
	for _ in range(m):
		(t, l, r) = [int(i) for i in input().split(' ')]
		if t == 1:
			for i in range(l + 1, r + 1):
				x[i] = 1
		else:
			queries.append((l + 1, r + 1))
	for q in queries:
		found = False
		for i in range(q[0], q[1]):
			if x[i] == 0:
				found = True
				break
		if not found:
			return 'NO'
	for i in range(1, n + 1):
		if x[i] == 0:
			a[i] = a[i - 1] - 1
		else:
			a[i] = a[i - 1] + 1
	return 'YES\n{}'.format(' '.join([str(a[i]) for i in range(1, n + 1)]))
print(go())


(n, m) = map(int, input().split())
p = []
ne = []
ra = [0] * n
for i in range(m):
	a = [int(o) for o in input().split()]
	if a[0] == 1:
		p.append([a[1], a[2]])
	else:
		ne.append([a[1], a[2]])
		for i in range(a[1], a[2]):
			ra[i] = -1
for i in p:
	for j in range(i[0], i[1]):
		ra[j] = 1
flag = 0
for i in ne:
	if ra[i[0]:i[1]].count(-1) == 0:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	ra[0] = 9999
	for i in range(1, n):
		ra[i] = ra[i - 1] + ra[i]
	print(*ra)


def rev(a, l, r):
	j = 0
	for i in range(l, r + 1, 2):
		(a[l + j], a[r - j]) = (a[r - j], a[l + j])
		j += 1
(n, m) = map(int, input().split())
pairs = []
pairs2 = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 1:
		pairs.append([l, -r])
	else:
		pairs2.append([l, r])
pairs.sort()
actual_pairs = []
for i in range(len(pairs)):
	if len(actual_pairs) > 0 and actual_pairs[-1][1] >= pairs[i][0]:
		actual_pairs[-1][1] = max(actual_pairs[-1][1], -pairs[i][1])
		continue
	actual_pairs.append([pairs[i][0], -pairs[i][1]])
arr = [n - i for i in range(n)]
for i in range(len(actual_pairs)):
	rev(arr, actual_pairs[i][0], actual_pairs[i][1])
for i in pairs2:
	flag = False
	max1 = 0
	for j in range(i[0], i[1]):
		max1 = max(arr[j], max1)
		if max1 > arr[j + 1]:
			flag = True
			break
	if not flag:
		print('NO')
		exit()
print('YES')
print(*arr)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(q1, q0) = ([], [])
for i in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 1:
		q1.append([l, r])
	else:
		q0.append([l, r])
b = [-1] * (n - 1)
for (l, r) in q1:
	for j in range(l, r):
		b[j] = 0
a = [0] * n
a[0] = n
for i in range(1, n):
	a[i] = a[i - 1] + b[i - 1]
flag = 1
for (l, r) in q0:
	if all((a[i] == a[i + 1] for i in range(l, r))):
		flag = 0
if flag:
	print('YES')
	print(*a)
else:
	print('NO')


(n, m) = map(int, input().split())
sorted_ = []
unsorted_ = []
for i in range(m):
	(a, b, c) = map(int, input().split())
	if a == 1:
		sorted_.append((b, c))
	else:
		unsorted_.append((b, c))
arr = [0] * (n - 1)
for a in sorted_:
	arr[a[0] - 1:a[1] - 1] = [1] * (a[1] - a[0])
ans = [0] * n
t = n
ans[0] = n
for i in range(n - 1):
	if arr[i] == 0:
		t -= 1
	ans[i + 1] = t
for a in unsorted_:
	if ans[a[0] - 1] == ans[a[1] - 1]:
		print('NO')
		exit(0)
print('YES')
print(*ans)


(n, m) = map(int, input().split())
container = [0 for i in range(n + 1)]
stick = [0 for i in range(n + 1)]
maxid = [-1 for i in range(n + 1)]
stored = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		maxid[l] = max(maxid[l], r)
	else:
		stored.append([l, r])
maxi = 0
for i in range(1, n + 1):
	maxi = max(maxi, maxid[i])
	if maxi >= i:
		container[i] = 1
	if maxi == i:
		stick[i] = 1
count = 1
ans = [0 for i in range(n + 1)]
for i in range(n, 0, -1):
	ans[i] = count
	if container[i - 1] == 1 == container[i] and stick[i - 1] == 0:
		pass
	else:
		count += 1
flag = 2
for i in stored:
	flag = 0
	for k in range(i[0], i[1]):
		if ans[k] > ans[k + 1]:
			flag = 1
			break
	if flag == 0:
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	print(*ans[1:])


from sys import stdin
read = stdin.readline
(n, m) = map(int, read().split())
ans = [0] * n
nd = []
for i in range(m):
	(t, l, r) = map(int, read().split())
	if t:
		for j in range(l, r):
			ans[j] = 1
	else:
		nd.append((l, r))
can = True
for (l, r) in nd:
	if all(ans[l:r]):
		can = False
		break
if can:
	res = [n] * n
	for i in range(1, n):
		res[i] = res[i - 1] + ans[i] - 1
	print('YES')
	print(' '.join(map(str, res)))
else:
	print('NO')


import sys, os, io
import math
from collections import defaultdict
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = li()
s = []
ns = []
for i in range(m):
	(t, l, r) = li()
	l -= 1
	r -= 1
	if t == 0:
		ns.append([l, r])
	else:
		s.append([l, r])
arr = [0] * n
for i in range(n - 1):
	ss = 0
	nss = 0
	for (l, r) in s:
		if l <= i <= i + 1 <= r:
			ss += 1
	for (l, r) in ns:
		if l <= i <= i + 1 <= r:
			nss += 1
	if nss > 0 and ss == 0:
		arr[i + 1] = -1
c = 0
for i in range(n):
	if arr[i] == -1:
		c -= 2
		arr[i] = c
	else:
		arr[i] = c
	c += 1
for (l, r) in s:
	for i in range(l, r):
		if arr[i] > arr[i + 1]:
			print('NO')
			exit()
for (l, r) in ns:
	f = 0
	for i in range(l, r):
		if arr[i] > arr[i + 1]:
			f = 1
	if f == 0:
		print('NO')
		exit()
m = min(arr)
if m <= 0:
	y = -m + 1
	for i in range(n):
		arr[i] += y
print('YES')
print(*arr)


(n, m) = map(int, input().split())
a = (n - 1) * [-1]
zeros = []
flag = 0
for i in range(m):
	x = list(map(int, input().split()))
	if x[1] == 1:
		if x[0] == 1:
			flag = 1
	if x[0] == 0:
		zeros.append(x)
	else:
		for j in range(x[1], x[2]):
			a[j - 1] = 1
for l in range(len(zeros)):
	for p in range(zeros[l][1], zeros[l][2]):
		if a[p - 1] == -1 or a[p - 1] == 0:
			a[p - 1] = 0
			break
		elif p == zeros[l][2] - 1:
			print('NO')
			exit()
print('YES')
for k in range(n - 1):
	if k == 0 and a[k] == 0:
		a[k] = 5000
	elif a[k] == -1:
		a[k] = 2000
	elif a[k] == 0:
		a[k] = a[k - 1] - 1
	elif a[k] == 1:
		a[k] = a[k - 1] + 10
if flag == 0:
	print(a[0] + 1, *a)
else:
	print(a[0] - 1, *a)


(n, m) = map(int, input().split())
a = [0] * n
a0 = []
while m > 0:
	m -= 1
	(t, l, r) = [int(i) for i in input().split()]
	if t == 0:
		a0.append((l, r))
		continue
	for i in range(l, r):
		a[i] = 1
for (l, r) in a0:
	if set(a[l:r]) == {1}:
		print('NO')
		exit(0)
print('YES')
val = 5 * 10 ** 4
for i in a:
	if i:
		val += 1
	else:
		val -= 1
	print(val)


class rel:
	ans = True

	def __init__(self, i, val=0):
		self.i = i
		self.val = val
		self.numb = [0, 0]

	def valor1(self, l, r):
		i = l
		while i < r:
			t[i].val = 1
			i += 1

	def valor0(self, l, r):
		i = l
		cnt = 0
		while i < r:
			if t[i].val == 0:
				cnt += 1
			i += 1
		if cnt == 0:
			rel.ans = 0
t = {}
(n, m) = map(int, input().split())
for i in range(1, n):
	t[i] = rel(i)
a = []
for i in range(m):
	(b, l, r) = map(int, input().split())
	if b == 1:
		t[1].valor1(l, r)
	else:
		a.append([l, r])
for (l, r) in a:
	t[1].valor0(l, r)
if rel.ans == 1:
	t[1].numb[0] = 3000
	for i in range(1, n):
		if t[i].val == 1:
			t[i].numb[1] = t[i].numb[0] + 1
			if i < n - 1:
				t[i + 1].numb[0] = t[i].numb[1]
		else:
			t[i].numb[1] = t[i].numb[0] - 1
			if i < n - 1:
				t[i + 1].numb[0] = t[i].numb[1]
	answer = []
	for i in range(1, n):
		answer.append(t[i].numb[0])
	answer.append(t[n - 1].numb[1])
	print('YES')
	print(*answer)
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
vals = [-1 for s in range(n)]
zer = []
one = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 0:
		zer.append((l, r))
	else:
		one.append((l, r))
if len(one) == 0:
	print('YES')
	print(*[s for s in range(n, 0, -1)])
else:
	one.sort(key=lambda x: x[0])
	segs = [[one[0][0], one[0][1]]]
	for i in range(1, len(one)):
		if segs[-1][1] >= one[i][0]:
			segs[-1][1] = max(segs[-1][1], one[i][1])
		else:
			segs.append([one[i][0], one[i][1]])
	temp = 10 ** 7
	for i in range(len(segs)):
		inter = segs[i]
		vals[inter[0]] = temp
		temp -= 1001
		for s in range(inter[0] + 1, inter[1] + 1):
			vals[s] = vals[s - 1] + 1
	broke = False
	for s in range(n):
		if vals[s] == -1:
			if s == 0:
				vals[s] = 10 ** 9
			else:
				vals[s] = vals[s - 1] - 1
	for i in range(len(zer)):
		inter = zer[i]
		inc = True
		for s in range(inter[0] + 1, inter[1] + 1):
			if vals[s] >= vals[s - 1]:
				continue
			else:
				inc = False
		if inc == True:
			broke = True
			break
	if broke == True:
		print('NO')
	else:
		print('YES')
		print(*vals)


(n, m) = [int(x) for x in input().split()]
a = []
b = []
for i in range(m):
	(t, l, r) = [int(x) for x in input().split()]
	if t == 1:
		a.append((l - 1, r - 1))
	else:
		b.append((l - 1, r - 1))
a.sort()
b.sort()
c = [0] * n
for i in range(len(a)):
	l = a[i][0]
	r = a[i][1]
	for j in range(l, r + 1):
		if j == l and c[j] == 0:
			c[j] = 1000
		elif j == l:
			c[j] = c[j]
		else:
			c[j] = c[j - 1] + 1000
for i in range(n):
	if c[i] == 0:
		if i == 0:
			c[i] = 1000000
		else:
			c[i] = c[i - 1] - 1
for i in range(len(b)):
	l = b[i][0]
	r = b[i][1]
	for j in range(l + 1, r + 1):
		if c[j] < c[j - 1]:
			break
	else:
		print('NO')
		break
else:
	print('YES')
	print(*c)


(n, m) = map(int, input().split())
srt = []
nsrt = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		srt.append((l - 1, r - 1))
	else:
		nsrt.append((l - 1, r - 1))
ans = []
for i in range(n, 0, -1):
	ans.append(i)
if not srt:
	print('YES')
	print(' '.join(list(map(str, ans))))
	exit(0)
srt.sort()
inters = []
(beg, end) = srt[0]
for (l, r) in srt:
	if l <= end:
		end = max(end, r)
	else:
		inters.append((beg, 0, end))
		(beg, end) = (l, r)
inters.append((beg, 0, end))
for (l, r) in nsrt:
	inters.append((l, 1, r))
inters.sort()
(b1, e1) = (-1, -1)
for (l, o, r) in inters:
	if o == 0:
		(b1, e1) = (l, r)
		tmp = ans[l:r + 1]
		tmp.sort()
		ans[l:r + 1] = tmp
	elif b1 != -1 and e1 != -1 and (b1 <= l) and (r <= e1):
		print('NO')
		exit(0)
print('YES')
print(' '.join(list(map(str, ans))))


(n, m) = list(map(int, input().strip().split()))
are = [False] * n
unos = []
zeros = []
for i in range(m):
	(t, l, r) = list(map(int, input().strip().split()))
	if t == 1:
		unos.append((l - 1, r))
	else:
		zeros.append((l - 1, r))
unos.sort()
c = 10000000
for i in range(len(unos)):
	(l, r) = unos[i]
	if are[l] == False:
		for k in range(l, r):
			are[k] = c
		c -= 10000
	else:
		storer = are[l]
		for k in range(l, r):
			are[k] = storer
if are[0] == False:
	are[0] = 20000000
for i in range(1, n):
	if are[i] == False:
		are[i] = are[i - 1] - 1
flagg = True
for i in range(len(zeros)):
	(l, r) = zeros[i]
	b = are[l:r]
	b.sort()
	if b == are[l:r]:
		flagg = False
if flagg:
	print('YES')
	print(' '.join(map(str, are)))
else:
	print('NO')


(n, m) = map(int, input().split())
a = [0] * n
b = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t == 0:
		b.append((l, r))
	else:
		for i in range(l, r):
			a[i] = 1
for (l, r) in b:
	if set(a[l:r]) == {1}:
		print('NO')
		exit(0)
print('YES')
temp = 50000
for i in a:
	if i:
		temp += 1
	else:
		temp -= 1
	print(temp, end=' ')


(n, m) = map(int, input().split())
query1 = [0] * (n + 1)
query0 = [0] * (n + 1)
querylist0 = []
querylist1 = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		for i in range(l, r):
			query1[i] = 1
	else:
		querylist0.append([l, r - 1])
		for i in range(l, r):
			query0[i] = 1
query1[0] = 2
query0[0] = 2
import itertools
now = 1
for (key, group) in itertools.groupby(query1):
	number = len(list(group))
	if key == 1:
		querylist1.append([now, now + number - 1])
		now += number
	elif key == 0:
		now += number
flag = 1
for i in range(len(querylist1)):
	for j in range(len(querylist0)):
		if querylist1[i][0] <= querylist0[j][0] and querylist1[i][1] >= querylist0[j][1]:
			flag = 0
if flag == 0:
	print('NO')
else:
	print('YES')
	ans = []
	now = 10000
	ans.append(now)
	for i in range(1, n):
		if query1[i] == 1:
			now += 1
			ans.append(now)
		elif query0[i] == 1:
			now -= 1
			ans.append(now)
		else:
			now -= 1
			ans.append(now)
	print(' '.join(map(str, ans)))


from collections import defaultdict
(n, m) = map(int, input().split())
l1 = []
l2 = []
ans = [1] * n
for i in range(m):
	(a, b, c) = map(int, input().split())
	if a == 0:
		l2.append([b, c])
	else:
		l1.append([b, c])
hash = defaultdict(bool)
l1.sort()
l2.sort()
for i in range(len(l1)):
	(a, b) = l1[i]
	for i in range(a, b):
		hash[i, i + 1] = True
l2.reverse()
flag = 1
for i in range(len(l2)):
	(a, b) = l2[i]
	flag = 0
	for i in range(a, b):
		if hash[i, i + 1] == False:
			flag = 1
			ans[i - 1] = ans[i] + 1
			break
	if flag == 0:
		break
if flag == 1:
	print('YES')
	print(*ans)
else:
	print('NO')


def mp():
	return map(int, input().split())

def check(l, r):
	return int(a[l:r + 1] == sorted(a[l:r + 1]))
(n, m) = mp()
q = [0] * m
for qq in range(m):
	(t, l, r) = mp()
	(l, r) = (l - 1, r - 1)
	q[qq] = [l, r, t]
q.sort()
a = [0 for i in range(n)]
u = [0 for i in range(n)]
fail = False
for qq in range(m):
	(l, r, t) = q[qq]
	if t == 0:
		if u[l] == 0:
			if l != 0 and u[l - 1] != 0:
				a[l] = a[l - 1]
				u[l] = 1
			else:
				a[l] = r - l + 1
				u[l] = 1
		for i in range(l + 1, r + 1):
			a[i] = a[i - 1] - 1
			u[i] = 1
for qq in range(m):
	(l, r, t) = q[qq]
	if t == 1:
		i = l
		while i < n and u[i] == 0:
			i += 1
		if i == n:
			x = 1
		else:
			x = a[i]
		a[l] = x
		u[l] = x
		for i in range(l + 1, r + 1):
			if a[i - 1] > a[i]:
				a[i] = a[i - 1]
				u[i] = 1
mn = min(a)
if mn < 1:
	mn = abs(mn) + 1
	for i in range(n):
		a[i] += mn
fail = False
for qq in range(m):
	(l, r, t) = q[qq]
	if t != check(l, r):
		fail = True
		break
if fail:
	print('NO')
else:
	print('YES')
	for i in a:
		print(i, end=' ')


(n, m) = [int(i) for i in input().split()]
diff = [-1] * n
negs = []
for _ in range(m):
	(t, l, r) = [int(i) for i in input().split()]
	if t == 1:
		for i in range(l, r):
			diff[i] = 0
	else:
		negs.append((l, r))
for (li, ri) in negs:
	neg = False
	for i in range(li, ri):
		if diff[i] == -1:
			neg = True
			break
	if not neg:
		print('NO')
		import sys
		sys.exit()
arr = [0]
for i in range(1, n):
	arr.append(arr[-1] + diff[i])
print('YES')
mn = 1 - min(arr)
[print(a + mn, end=' ') for a in arr[:-1]]
print(mn + arr[-1])


(N, M) = map(int, input().split())
P = [i for i in range(N)]

def par(a):
	if P[a] == a:
		return a
	t = par(P[a])
	P[a] = t
	return t

def cb(a, b):
	P[par(b)] = par(a)
X = []
for _ in range(M):
	(t, l, r) = map(int, input().split())
	(l, r) = (l - 1, r - 1)
	if t == 1:
		for i in range(l, r):
			cb(i, i + 1)
	else:
		X.append((l, r))
G = [-1] * N
for i in range(N):
	G[i] = N - par(i)
for (l, r) in X:
	for i in range(l, r):
		if G[i] > G[i + 1]:
			break
	else:
		print('NO')
		break
else:
	print('YES')
	print(*G)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(m)]
check = [0] * (n + 1)
Q1 = []
Q0 = []
for q in Q:
	if q[0] == 0:
		Q0.append(q)
	else:
		Q1.append(q)
for (i, x, y) in Q1:
	check[x] += 1
	check[y] -= 1
S = [0]
for c in check:
	S.append(S[-1] + c)
S = S[1:]
ANS = [10 ** 5]
for s in S[1:-1]:
	if s != 0:
		ANS.append(ANS[-1])
	else:
		ANS.append(ANS[-1] - 1)
for (i, x, y) in Q0:
	if ANS[x - 1] == ANS[y - 1]:
		print('NO')
		sys.exit()
print('YES')
print(*ANS)


(n, m) = map(int, input().split())
a = [0] * n
ordered = []
unordered = []
for i in range(m):
	list1 = list(map(int, input().split()))
	if list1[0] == 0:
		unordered.append(list1)
	else:
		ordered.append(list1)
for (t, l, r) in ordered:
	for i in range(l, r):
		a[i] = t
for (t, l, r) in unordered:
	unset = any((e == 0 for e in a[l:r]))
	if not unset:
		print('NO')
		exit()
print('YES')
v = 100000
for e in a:
	if e == 1:
		v += 1
	else:
		v -= 1
	print(v, end=' ')


def check(o, z, ans):
	for i in o:
		for j in range(i[0] + 1, i[1] + 1):
			if ans[j] < ans[j - 1]:
				return 0
	for i in z:
		f = -1
		for j in range(i[0] + 1, i[1] + 1):
			f = 0
			if ans[j] < ans[j - 1]:
				f = 1
				break
		if f == 0:
			return 0
	return 1
(n, m) = map(int, input().split())
a = []
z = []
o = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	if t:
		o.append([l, r])
	else:
		z.append([l, r])
o.sort()
z.sort()
ans = [-1 for i in range(n + 1)]
for i in o:
	for j in range(i[0] + 1, i[1] + 1):
		ans[j] = 0
ans[0] = 100000
for i in range(1, n + 1):
	ans[i] += ans[i - 1]
if check(o, z, ans):
	print('YES')
	for i in range(1, n + 1):
		print(ans[i], end=' ')
	print('')
else:
	print('NO')


(n, m) = map(int, input().split())
lsttttt = [1] * (n + 10)
L0 = []
L1 = []
pp = [0] * (n - 1)
for ooo in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		L1.append((l - 1, r - 1))
	else:
		L0.append((l - 1, r - 1))
L1 = sorted(L1)
L0 = sorted(L0)
for i in range(0, len(L1)):
	l = L1[i][0]
	r = L1[i][1]
	for j in range(l, r):
		pp[j] = 1
flag1 = 1
for i in range(0, len(L0)):
	l = L0[i][0]
	r = L0[i][1]
	flag = 0
	for j in range(l, r):
		if pp[j] == -1:
			flag = 1
			continue
		elif pp[j] == 0:
			pp[j] = -1
			flag = 1
	if flag == 0:
		flag1 = 0
if flag1 == 0:
	print('NO')
else:
	k = 100000
	lsttttt[0] = 100000
	for i in range(0, len(pp)):
		if pp[i] == 1:
			lsttttt[i + 1] = lsttttt[i] + 1
		elif pp[i] == -1:
			lsttttt[i + 1] = lsttttt[i] - 1
		else:
			lsttttt[i + 1] = lsttttt[i]
	print('YES')
	for i in range(n):
		print(lsttttt[i], end=' ')
	print(' ')


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
ans = [0] * n
arr = []
for j in range(m):
	(t, l, r) = map(int, input().split())
	if t:
		for i in range(l, r):
			ans[i] = -1
	else:
		arr.append((l, r))
for i in range(n):
	ans[i] += 1
for (l, r) in arr:
	if set(ans[l:r]) == {0}:
		print('NO')
		exit(0)
a = [0] * n
a[0] = n
for i in range(1, n):
	a[i] = a[i - 1] - ans[i]
print('YES')
print(*a)


(n, m) = [int(x) for x in input().split(' ')]
unordered = []
count = 0
ordered_status = [0] * n
for i in range(m):
	(t, l, r) = [int(x) for x in input().split(' ')]
	if t == 1:
		for j in range(l, r):
			ordered_status[j] = 1
	else:
		unordered.append([l, r])
		count += 1
for el in unordered:
	l = el[0]
	r = el[1]
	if sum(ordered_status[l:r]) == r - l:
		print('NO')
		exit()
print('YES')
solution = [10000] * (n + 1)
for i in range(1, n + 1):
	if ordered_status[i - 1] == 1:
		solution[i] = solution[i - 1] + 1
	else:
		solution[i] = solution[i - 1] - 1
print(' '.join([str(solution[x]) for x in range(1, n + 1)]))


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	(n, m) = get_tuple()
	sorted = []
	other = []
	for _ in range(m):
		(t, l, r) = get_tuple()
		k = [l - 1, r - 1]
		if t == 0:
			other.append(k)
		else:
			sorted.append(k)
	res = [0 for _ in range(n)]
	for (l, r) in sorted:
		for i in range(l + 1, r + 1):
			res[i] = 1
	for (l, r) in other:
		made = False
		for i in range(l + 1, r + 1):
			if res[i] != 1:
				res[i] = -1
			if res[i] == -1:
				made = True
				break
		if not made:
			print('NO')
			return
	for i in range(1, n):
		res[i] = res[i] + res[i - 1]
	mini = 1 - min(res)
	for i in range(n):
		res[i] += mini
	print('YES')
	display_list(res)
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


(n, m) = map(int, input().split())
ans = True
f = [-1 for i in range(n)]
temp = []
for i in range(m):
	(x, a, b) = map(int, input().split())
	if x == 0:
		temp.append((a, b))
	else:
		f[a:b] = [1 for z in range(b - a)]
for (a, b) in temp:
	if set(f[a:b]) == {1}:
		ans = False
		break
	else:
		for k in range(a, b):
			if f[k] == -1:
				f[k] = 0
f.pop(0)
if ans:
	print('YES')
	l = []
	if ans == True:
		current = 1001
		l.append(current)
		for x in f:
			if x == 0:
				current -= 1
				l.append(current)
			else:
				l.append(current)
	print(*l)
else:
	print('NO')


import sys

def main():
	input = sys.stdin.readline
	(n, m) = map(int, input().split())
	A = [0 for k in range(n)]
	B = []
	C = [10000 for k in range(n)]
	for k in range(m):
		(t, l, r) = map(int, input().split())
		if t == 1:
			for k in range(l - 1, r - 1):
				A[k] = 1
		else:
			B.append([l, r])
		for k in range(1, n):
			if A[k - 1] == 1:
				C[k] = C[k - 1] + 1
			else:
				C[k] = C[k - 1] - 1
		for e in B:
			f = 1
			for t in range(e[0], e[1]):
				if C[t - 1] > C[t]:
					f = 0
					break
			if f == 1:
				print('NO')
				exit(0)
	print('YES')
	print(*C)
main()


(n, m) = map(int, input().split())
DP = [0] * (n + 5)
Result = [0] * (n + 5)
for i in range(0, n + 5):
	Result[i] = n + 5 - i
zeros = []
ones = []
for mm in range(m):
	(t, l, r) = map(int, input().split())
	if t == 0:
		zeros.append((l, r))
	elif t == 1:
		ones.append((l, r))
sortedOnes = sorted(ones, key=lambda ones: ones[0])
for i in range(len(sortedOnes)):
	l = sortedOnes[i][0]
	r = sortedOnes[i][1]
	for j in range(l + 1, r + 1):
		Result[j] = Result[j - 1] + 1
mainChecker = True
for i in range(len(zeros)):
	l = zeros[i][0]
	r = zeros[i][1]
	checker = False
	for j in range(l, r):
		if Result[j] > Result[j + 1]:
			checker = True
			break
	if checker == False:
		mainChecker = False
		break
if mainChecker == True:
	print('YES')
	for i in range(1, n + 1):
		print(Result[i], end=' ')
else:
	print('NO')


import sys
from collections import defaultdict
import typing

class DSU:

	def __init__(self, n: int=0) -> None:
		self._n = n
		self.parent_or_size = [-1] * n

	def merge(self, a: int, b: int) -> int:
		assert 0 <= a < self._n
		assert 0 <= b < self._n
		x = self.leader(a)
		y = self.leader(b)
		if x == y:
			return x
		if -self.parent_or_size[x] < -self.parent_or_size[y]:
			(x, y) = (y, x)
		self.parent_or_size[x] += self.parent_or_size[y]
		self.parent_or_size[y] = x
		return x

	def same(self, a: int, b: int) -> bool:
		assert 0 <= a < self._n
		assert 0 <= b < self._n
		return self.leader(a) == self.leader(b)

	def leader(self, a: int) -> int:
		assert 0 <= a < self._n
		parent = self.parent_or_size[a]
		while parent >= 0:
			if self.parent_or_size[parent] < 0:
				return parent
			(self.parent_or_size[a], a, parent) = (self.parent_or_size[parent], self.parent_or_size[parent], self.parent_or_size[self.parent_or_size[parent]])
		return a

	def size(self, a: int) -> int:
		assert 0 <= a < self._n
		return -self.parent_or_size[self.leader(a)]

	def groups(self) -> typing.List[typing.List[int]]:
		leader_buf = [self.leader(i) for i in range(self._n)]
		result: typing.List[typing.List[int]] = [[] for _ in range(self._n)]
		for i in range(self._n):
			result[leader_buf[i]].append(i)
		return list(filter(lambda r: r, result))

def input():
	return sys.stdin.readline().rstrip()

def slv():
	(n, m) = map(int, input().split())
	dsu = DSU(n)
	info = [-1] * n
	not_sorted = []
	for i in range(m):
		(t, l, r) = map(int, input().split())
		l -= 1
		r -= 1
		if t == 1:
			for j in range(l, r + 1):
				dsu.merge(l, j)
		else:
			not_sorted.append((l, r))
	group = [-1] * n
	dsu_data = defaultdict(list)
	for i in range(n):
		dsu_data[dsu.leader(i)].append(i)
	color = 0
	for (key, value) in dsu_data.items():
		for v in value:
			group[v] = color
		color += 1
	for (l, r) in not_sorted:
		if all((group[j] == group[l] for j in range(l, r + 1))):
			print('NO')
			return
	INF = int(100000000.0)
	D = int(10000.0)
	inc = 0
	print('YES')
	ans = [0] * n
	group_index = group[0]
	for i in range(n):
		if group[i] == group_index:
			ans[i] = INF + inc
			inc += 1
		else:
			group_index = group[i]
			INF -= D
			inc = 0
			ans[i] = INF + inc
			inc += 1
	print(*ans)
	return

def main():
	t = 1
	for i in range(t):
		slv()
	return
main()


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
(n, m) = map(int, input().split())
ans = [0] * n
l = []
for i in range(m):
	(c, a, b) = map(int, input().split())
	l.append((a, b, c))
l.sort()
t = 0
res = []
for i in range(m):
	if l[i][2] == 0:
		for j in range(l[i][0] - 1, l[i][1]):
			if ans[j] == 0:
				ans[j] = 10 ** 9 - t * 10
				t += 1
		res.append(l[i])
	else:
		if ans[l[i][0] - 1] == 0:
			ans[l[i][0] - 1] = 10 ** 9 - t * 10
			t += 1
		for j in range(l[i][0], l[i][1]):
			ans[j] = ans[j - 1]
t *= 10
for i in range(n):
	if ans[i] == 0:
		ans[i] = 10 ** 9 - t * 10
		t += 1
for i in res:
	f = 0
	for j in range(i[0], i[1]):
		if ans[j] < ans[j - 1]:
			f = 1
			break
	if f == 0:
		print('NO')
		sys.exit(0)
print('YES')
print(*ans)


(n, m) = map(int, input().split())
facts = [0] * m
for pos in range(m):
	(ti, li, ri) = map(int, input().split())
	facts[pos] = (ti, li - 1, ri - 1)
facts = sorted(facts)
same = [0] * (n + 1)
for (ti, li, ri) in facts:
	if ti == 1:
		same[li] += 1
		same[ri] -= 1
dec = True
val = n + 2
count = 0
sol = [0] * n
for arr_pos in range(n):
	if dec:
		val -= 1
	count += same[arr_pos]
	dec = count == 0
	sol[arr_pos] = val
bad = False
for (ti, li, ri) in facts:
	if ti == 0 and sol[li] == sol[ri]:
		print('NO')
		bad = True
		break
if not bad:
	print('YES')
	print(' '.join(map(str, sol)))


(n, m) = map(int, input().strip().split())
lis = [0 for _ in range(n)]
q = []
for y in range(m):
	l = list(map(int, input().strip().split()))
	if l[0] == 0:
		q.append(l)
	else:
		j = l[1]
		while j < l[2]:
			lis[j] = 1
			j += 1
z = True
while q:
	l = q.pop()
	j = l[1]
	if set(lis[l[1]:l[2]]) == {1}:
		z = False
if not z:
	print('NO')
if z:
	print('YES')
	e = 100000
	for x in lis:
		if x:
			e += 1
		else:
			e -= 1
		print(e, end=' ')


(n, m) = map(int, input().split())
arr = [k for k in range(n, 0, -1)]
sors = []
nosors = []
for _ in range(m):
	(tp, x1, x2) = map(int, input().split())
	x1 -= 1
	x2 -= 1
	if tp == 1:
		remains = []
		incl = False
		for i in range(len(sors)):
			newfl = True
			if sors[i][0] <= x1 and x2 <= sors[i][1]:
				incl = True
				break
			if x1 <= sors[i][0] <= x2:
				x2 = max(x2, sors[i][1])
				newfl = False
			if x1 <= sors[i][1] <= x2:
				x1 = min(x1, sors[i][0])
				newfl = False
			if newfl:
				remains.append(sors[i])
		if incl:
			remains.extend(sors[i:])
		else:
			remains.append([x1, x2])
		sors = remains
	else:
		nosors.append([x1, x2])
sors.sort(key=lambda pair: pair[0])
for sor in sors:
	for i in range(sor[0], sor[1] + 1):
		arr[i] = n - sor[0]
answer = 'YES'
for nosor in nosors:
	for sor in sors:
		if nosor[0] >= sor[0] and nosor[1] <= sor[1]:
			answer = 'NO'
			break
print(answer)
if answer == 'YES':
	print(' '.join(map(str, arr)))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
inc = list()
dec = list()
s = set()
for i in range(m):
	(ch, l, r) = map(int, input().split())
	if ch == 1:
		inc.append((l - 1, r - 1))
	else:
		dec.append((l - 1, r - 1))
a = [n] * n
inc.sort()
for i in range(len(inc)):
	(l, r) = (inc[i][0], inc[i][1])
	for j in range(l + 1, r + 1):
		s.add(j)
ch = 1
dec.sort()
for i in range(len(dec)):
	(l, r) = (dec[i][0], dec[i][1])
	c = 0
	for j in range(l + 1, r + 1):
		if j in s:
			c += 1
		else:
			if a[j] < a[j - 1]:
				break
			a[j] = a[j - 1] - 1
			break
	if c == r - l:
		ch = 0
		break
if ch == 1:
	print('YES')
	print(*a)
else:
	print('NO')


from sys import stdin, stdout, exit
(n, m) = map(int, stdin.readline().split())
a = [1] * (n - 1)
to_check = []
for i in range(m):
	(t, l, r) = map(int, stdin.readline().split())
	if t == 1:
		for j in range(l, r):
			a[j - 1] = 0
	else:
		to_check.append((l, r))
for (l, r) in to_check:
	if all([a[i - 1] == 0 for i in range(l, r)]):
		print('NO')
		exit()
print('YES')
ans = [0]
cur = 0
for i in range(n - 1):
	if a[i] == 1:
		cur -= 1
	ans.append(cur)
mm = min(ans)
ans = [a - mm + 1 for a in ans]
for i in range(n):
	stdout.write(str(ans[i]) + ' ')
stdout.write('\n')


from collections import Counter, defaultdict, OrderedDict, deque
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from typing import List
import itertools
import math
import heapq
import string
import random
(MIN, MAX, MOD) = (-1061109567, 1061109567, 1000000007)
(n, m) = map(int, input().split())
(a, b) = ([0] * n, [])
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t:
		for i in range(l, r):
			a[i] = 1
	else:
		b.append([l, r])
for (l, r) in b:
	if set(a[l:r]) == {1}:
		print('NO')
		exit(0)
print('YES')
tmp = 50000
for i in a:
	if i:
		tmp += 1
	else:
		tmp -= 1
	print(tmp, end=' ')


def main():
	(n, m) = map(int, input().split())
	l0 = []
	r0 = []
	l1 = []
	r1 = []
	for _ in range(m):
		(ti, li, ri) = map(int, input().split())
		if ti:
			l1.append(li)
			r1.append(ri)
		else:
			l0.append(li)
			r0.append(ri)
	segments = []
	for i in range(len(l1)):
		new_segments = []
		to_add = [l1[i], r1[i]]
		for segment in segments:
			if to_add[0] > segment[1] or to_add[1] < segment[0]:
				new_segments.append(segment)
			else:
				to_add[0] = min(to_add[0], segment[0])
				to_add[1] = max(to_add[1], segment[1])
		new_segments.append(to_add)
		segments = new_segments
	segments.sort(key=lambda x: x[0])
	for i in range(len(l0)):
		for segment in segments:
			if l0[i] >= segment[0] and r0[i] <= segment[1]:
				print('NO')
				return
	print('YES')
	sz = 0
	z = 1001
	p = []
	for i in range(1, n + 1):
		if sz == len(segments) or i <= segments[sz][0]:
			z -= 1
			p.append(z)
		elif i < segments[sz][1]:
			p.append(z)
		else:
			sz += 1
			p.append(z)
	print(*p)
main()


from sys import stdin, exit
data = list(stdin)
(n, m) = map(int, data[0].split())
facts = []
ranges = []
rangesx = []
for i in range(m):
	f = tuple(map(int, data[i + 1].split()))
	if f[0] == 1:
		ranges.append(f)
	else:
		rangesx.append(f)
rangesi = iter(sorted(ranges) + [(1, n + 1, n + 1)])
rs = next(rangesi)
out = []
v = 1000
for i in range(1, n + 1):
	while i >= rs[2]:
		rs = next(rangesi)
	out.append(v)
	if i < rs[1] or i >= rs[2]:
		v -= 1
for rns in rangesx:
	if out[rns[1] - 1] == out[rns[2] - 1]:
		print('NO')
		exit(0)
print('YES')
print(*out)


import sys
(array_length, num_facts) = map(int, sys.stdin.readline().split())
array = [False] * 1010
array[0] = True
array[1] = True
unsorteds = []
for _ in range(num_facts):
	(query_type, left, right) = map(int, sys.stdin.readline().split())
	if query_type == 0:
		unsorteds.append((left, right))
	else:
		for pos in range(left + 1, right + 1):
			array[pos] = True
solution = True
for unsorted in unsorteds:
	valid_unsorted = False
	for pos in range(unsorted[0] + 1, unsorted[1] + 1):
		if not array[pos]:
			valid_unsorted = True
			break
	if not valid_unsorted:
		solution = False
		break
if not solution:
	print('NO')
else:
	print('YES')
	value = 2000
	solution = []
	for is_sorted in array[1:array_length + 1]:
		if is_sorted:
			value += 1
			solution.append(str(value))
		else:
			value -= 1
			solution.append(str(value))
	print(' '.join(solution))


(n, m) = map(int, input().split())
dec = []
a = [0] * n
for i in range(m):
	(t, l, r) = map(int, input().split())
	if not t:
		dec.append((l, r))
		continue
	for j in range(l, r):
		a[j] = 1
for (l, r) in dec:
	if set(a[l:r]) == {1}:
		print('NO')
		exit(0)
print('YES')
v = 10000
for i in a:
	if i > 0:
		v += 1
	else:
		v -= 1
	print(v, end=' ')


import heapq

def main():
	(n, m) = map(int, input().split())
	res = [0 for _ in range(n)]
	is1 = res[:]
	r0 = list()
	r1 = list()
	for i in range(m):
		(t, l, r) = map(int, input().split())
		l -= 1
		r -= 1
		if t == 0:
			heapq.heappush(r0, (-l, r))
		else:
			r1.append((l, r))
			is1[l + 1:r + 1] = [1 for _ in range(r - l)]
	for _ in range(len(r0)):
		(l, r) = heapq.heappop(r0)
		l = -l
		try:
			p = is1[l + 1:r + 1].index(0) + l
		except ValueError:
			p = l
		res[p] = res[p + 1] + 1
	i = n - 1
	cv = 0
	while i >= 0:
		if res[i]:
			cv += 1
		res[i] = cv
		i -= 1
	for (l, r) in r1:
		for i in range(l, r):
			if res[i] > res[i + 1]:
				print('NO')
				return
	print('YES')
	for (pos, i) in enumerate(res):
		print(i + 1, end=' ')
main()


(n, m) = map(int, input().split())
query = [[], []]
for _ in range(0, m):
	(t, l, r) = map(int, input().split())
	query[t].append((l, r))
aa = [-1] * n
for i in range(0, len(query[1])):
	(ll, rr) = (query[1][i][0], query[1][i][1])
	aa[ll:rr] = [0] * (rr - ll)
can = True
for i in range(0, len(query[0])):
	(ll, rr) = (query[0][i][0], query[0][i][1])
	if min(aa[ll:rr]) == 0:
		can = False
		break
if can:
	print('YES')
	ans = [0] * n
	ans[0] = n
	for i in range(1, n):
		ans[i] += aa[i] + ans[i - 1]
	print(*ans)
else:
	print('NO')


(n, m) = map(int, input().split())
unsorted = []
events = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	l -= 1
	r -= 1
	if t == 1:
		events.append((l, +1))
		events.append((r + 1, -1))
	else:
		unsorted.append((l, r))
s = 0
a = []
events.sort()
prev = 0
next = 10 ** 9
for (x, d) in events:
	if s == 0:
		for i in range(prev, x):
			a.append(next)
			next -= 1
	else:
		for i in range(prev, x):
			a.append(next)
	s += d
	if s == 0:
		next -= 1
	prev = x
while len(a) < n:
	a.append(next)
	next -= 1
if any((a[l] == a[r] for (l, r) in unsorted)):
	print('NO')
else:
	print('YES')
	print(*a)


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	(n, m) = mi()
	v = []
	cnt = [0] * (n + 1)
	for i in range(m):
		(t, l, r) = mi()
		if t == 0:
			v.append([l, r])
		else:
			for k in range(l, r):
				cnt[k] = 1
	for j in v:
		a = j[0]
		b = j[1]
		c = 0
		for k in range(a, b):
			c += cnt[k]
		if c == b - a:
			print('NO')
			return
	print('YES')
	mx = int(1000000.0)
	ans = [0] * (n + 1)
	for i in range(1, n + 1):
		if cnt[i - 1]:
			ans[i] = ans[i - 1] + 2
		else:
			ans[i] = mx
			mx -= 1
	ans = ans[1:]
	print(*ans)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


(n, m) = [int(i) for i in input().split()]
q1 = []
q0 = []
arr = [-1] * n
for _ in range(m):
	q = [int(i) for i in input().split()]
	if q[0] == 0:
		q0.append(q)
	else:
		q1.append(q)
for i in range(len(q1)):
	l = q1[i][1]
	r = q1[i][2]
	if arr[l - 1] == -1:
		if arr[r - 1] == -1:
			for j in range(l - 1, r):
				arr[j] = i
		else:
			for j in range(l - 1, r):
				arr[j] = arr[r - 1]
	elif arr[r - 1] == -1:
		for j in range(l - 1, r):
			arr[j] = arr[l - 1]
	elif arr[r - 1] != arr[l - 1]:
		for j in range(l, r - 1):
			arr[j] = arr[l - 1]
		u = r
		while arr[u] == arr[r - 1]:
			arr[u] = arr[l - 1]
			u += 1
			if u == n:
				break
		arr[r - 1] = arr[l - 1]
flag = True
for i in q0:
	l = i[1] - 1
	r = i[2] - 1
	if arr[l] == arr[r] and arr[l] != -1:
		flag = False
		break
if flag:
	p = -2
	j = 1
	for i in range(1, n + 1):
		if arr[-i] == -1:
			j += 1
			arr[-i] = j
		elif arr[-i] == p:
			arr[-i] = j
		else:
			p = arr[-i]
			j += 1
			arr[-i] = j
	print('YES')
	print(*arr)
else:
	print('NO')


(n, q) = map(int, input().split())
a = [0 for i in range(n + 1)]
d = []
for i in range(q):
	(t, l, r) = map(int, input().split())
	if t == 1:
		a[l] += 1
		a[r] -= 1
	else:
		d.append([l, r])
for i in range(1, n + 1):
	a[i] = a[i - 1] + a[i]
for i in d:
	flag = 0
	for j in range(i[0], i[1]):
		if a[j] == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
		break
else:
	print('YES')
	ct = n
	print(ct, end=' ')
	for i in range(1, n):
		if a[i] == 0:
			ct -= 1
		print(ct, end=' ')
	print()


(n, k) = map(int, input().split())
step = [0] * n
a = [1001 for i in range(n)]
sorted_val = []
unsorted = []
for _ in range(k):
	xmd = list(map(int, input().split()))
	if xmd[0] == 0:
		unsorted.append(xmd)
	else:
		sorted_val.append(xmd)
for xmd in sorted_val:
	for i in range(xmd[1], xmd[2]):
		step[i] = 1
for (t, l, r) in unsorted:
	ret = any((i == 0 for i in step[l:r]))
	if not ret:
		print('NO')
		exit(0)
print('YES')
temp = n + 1
ans = []
for i in range(n):
	if step[i]:
		ans.append(n)
	else:
		temp -= 1
		ans.append(temp)
print(*ans)


import sys
(n, m) = map(int, input().split())
arr = [0] * n
tmp = [0] * n
adj = [tmp[:] for i in range(n)]
orders1 = []
orders0 = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t == 1:
		orders1.append((l, r))
	else:
		orders0.append((l, r))
for i in orders1:
	for j in range(i[0] - 1, i[1] - 1):
		adj[j][j + 1] = 1
		adj[j + 1][j] = 1
for i in orders0:
	status = -1
	for j in range(i[0] - 1, i[1] - 1):
		if adj[j][j + 1] != 1:
			status = 1
	if status == -1:
		print('NO')
		sys.exit()
print('YES')
arr[-1] = 1
for i in range(n - 2, -1, -1):
	if adj[i][i + 1] == 1:
		arr[i] = arr[i + 1]
	else:
		arr[i] = arr[i + 1] + 1
for i in arr:
	print(i, end=' ')


def get_compressed(facts):
	compressed_facts = dict()
	for fact in facts:
		if fact[0] == 0:
			continue
		(start, end) = (fact[1], fact[2])
		to_remove = []
		skip = False
		for compressed in compressed_facts:
			(start_compressed, end_compressed) = compressed_facts[compressed]
			if start <= end_compressed and end > end_compressed:
				to_remove.append(compressed)
				start = min(start, start_compressed)
			elif end >= start_compressed and start < start_compressed:
				to_remove.append(compressed)
				end = max(end, end_compressed)
			elif start >= start_compressed and end <= end_compressed:
				skip = True
				break
		if skip:
			continue
		compressed_facts[str(start) + ',' + str(end)] = [start, end]
		for x in to_remove:
			del compressed_facts[x]
	return compressed_facts

def solve(n, facts):
	compressed_facts = get_compressed(facts)
	for fact in facts:
		if fact[0] == 1:
			continue
		for compressed in compressed_facts.values():
			if fact[1] >= compressed[0] and fact[2] <= compressed[1]:
				return None
	a = n * [None]
	for fact in compressed_facts.values():
		start = 10 ** 8
		size = fact[1] - fact[0] + 1
		for i in range(size):
			a[fact[0] - 1 + i] = start - 10000 * fact[0] + i
	for i in range(n):
		if a[i] is None:
			if i == 0:
				a[i] = 10 ** 9 - 1
			else:
				a[i] = a[i - 1] - 1
	return a
(n, num_facts) = map(int, input().split(' '))
facts = []
for _ in range(num_facts):
	facts.append(list(map(int, input().split(' '))))
sol = solve(n, facts)
if sol is None:
	print('NO')
else:
	print('YES')
	print(' '.join(map(str, sol)))


(n, m) = map(int, input().split())
a = []
c = []
d = [10000] * n
for i in range(m):
	b = list(map(int, input().split()))
	a.append(b)
k = 0
for i in a:
	if i[0] == 1:
		for j in range(i[1] - 1, i[2] - 1):
			if j not in c:
				c.append(j)
for i in a:
	if i[0] == 0:
		if i[1] - 1 in c and i[2] - 2 in c:
			t = 0
			for p in range(i[1] - 1, i[2] - 1):
				if p not in c:
					t = 1
					break
			if t == 0:
				k = 1
if k == 1:
	print('NO')
else:
	for j in range(n - 1):
		if j in c:
			d[j + 1] = d[j] + 1
		else:
			d[j + 1] = d[j] - 1
	print('YES')
	print(*d)


import sys
a = []
(n, m) = map(int, input().split())
b = [True] * n
d = []
for i in range(m):
	x = list(map(int, input().split()))
	x[1] -= 1
	x[2] -= 1
	if x[0] == 1:
		for j in range(x[1] + 1, x[2] + 1):
			b[j] = False
	else:
		d.append(x)
el = 1000
a.append(el)
for i in b[1:]:
	if i:
		el -= 1
	a.append(el)
for i in d:
	if a[i[1]] == a[i[2]]:
		print('NO')
		sys.exit(0)
print('YES')
print(*a)


class UnionFind:

	def __init__(self, n):
		self.n = n
		self.root = [-1] * (n + 1)
		self.rnk = [0] * (n + 1)

	def Find_Root(self, x):
		if self.root[x] < 0:
			return x
		else:
			self.root[x] = self.Find_Root(self.root[x])
			return self.root[x]

	def Unite(self, x, y):
		x = self.Find_Root(x)
		y = self.Find_Root(y)
		if x == y:
			return
		elif self.rnk[x] > self.rnk[y]:
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if self.rnk[x] == self.rnk[y]:
				self.rnk[y] += 1

	def isSameGroup(self, x, y):
		return self.Find_Root(x) == self.Find_Root(y)

	def Count(self, x):
		return -self.root[self.Find_Root(x)]
import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
TLR = [list(map(int, input().split())) for _ in range(M)]
uni = UnionFind(N)
for (T, L, R) in TLR:
	if T == 1:
		for n in range(L, R + 1):
			uni.Unite(L, n)
ok = True
for (T, L, R) in TLR:
	if T == 0:
		if uni.isSameGroup(L, R):
			ok = False
if not ok:
	print('NO')
else:
	print('YES')
	ans = [10 ** 6]
	for i in range(1, N):
		if uni.isSameGroup(i, i + 1):
			ans.append(ans[-1] + 1)
		else:
			ans.append(ans[-1] - 1)
	for a in ans:
		print(a, end=' ')
	print()


def gns():
	return list(map(int, input().split()))
(n, m) = gns()
inc = []
dec = []
for i in range(m):
	(t, a, b) = gns()
	a -= 1
	b -= 1
	if t == 0:
		dec.append((a, b))
	else:
		inc.append((a, b))
inc.sort()
ans = [-1] * n
if len(inc) == 0:
	print('YES')
	print(' '.join(map(str, list(reversed(range(1, n + 1))))))
	quit()
(s, t) = inc[0]
cur = 1
to = [[inc[0][0]]]
for i in range(len(inc)):
	(ss, tt) = inc[i]
	if ss <= t:
		t = max(t, tt)
	else:
		to[-1].append(t)
		to.append([ss])
		t = tt
to[-1].append(t)
for (ss, tt) in to:
	for i in range(ss, tt + 1):
		ans[i] = cur
	cur += 1
cur = n + 1
i = 0
while i < n:
	if ans[i] == -1:
		ans[i] = cur
		cur -= 1
		i += 1
		continue
	st = ans[i]
	for j in range(i, n):
		if ans[j] != st:
			break
		ans[j] = cur
	else:
		break
	cur -= 1
	i = j

def check(a, b):
	for i in range(a, b):
		if not ans[i] <= ans[i + 1]:
			return True
	return False
for (a, b) in dec:
	if not check(a, b):
		print('NO')
		quit()
print('YES')
print(' '.join(map(str, ans)))


def solve():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	sorted_bounds = []
	unsorted_bounds = []
	for i in range(m):
		(t, l, r) = input().split()
		if int(t) == 1:
			sorted_bounds.append([int(l), int(r)])
		else:
			unsorted_bounds.append([int(l), int(r)])
	r = [0] * (n - 1)
	for b in sorted_bounds:
		r[b[0] - 1:b[1] - 1] = [1] * (b[1] - b[0])
	a = [0] * n
	current = n
	a[0] = current
	for i in range(n - 1):
		if r[i] == 0:
			current -= 1
		a[i + 1] = current
	for b in unsorted_bounds:
		if a[b[0] - 1] == a[b[1] - 1]:
			print('NO')
			quit()
	print('YES')
	print(' '.join(map(str, a)))
solve()


(n, m) = map(int, input().split())
a = []
b = []
j = 1
l = [0] * n
for _ in range(m):
	(q, w, e) = map(int, input().split())
	if q == 1:
		a += [[q, w, e]]
	else:
		b += [[q, w, e]]
for x in a:
	if l[x[1] - 1] != 0 and l[x[2] - 1] != 0 and (l[x[1] - 1] != l[x[2] - 1]):
		for i in range(x[1] - 1, x[2]):
			l[i] = l[x[1] - 1]
		h = x[2]
		if x[2] != n - 1:
			mu = l[x[2]]
			while h < n and l[h] == mu:
				l[h] = l[x[1] - 1]
				h += 1
	elif l[x[1] - 1] != 0:
		for i in range(x[1] - 1, x[2]):
			l[i] = l[x[1] - 1]
	elif l[x[2] - 1] != 0:
		for i in range(x[1] - 1, x[2]):
			l[i] = l[x[2] - 1]
	else:
		for i in range(x[1] - 1, x[2]):
			l[i] = j
		j += 1
fl = 0
for x in b:
	if l[x[1] - 1] == l[x[2] - 1] and l[x[1] - 1] != 0:
		fl = 1
		break
if fl == 0:
	print('YES')
	val = 10 ** 5
	for i in range(n):
		if i == 0 or (l[i] == l[i - 1] and l[i] != 0):
			print(val, end=' ')
			val += 1
		else:
			val -= 2
			print(val, end=' ')
			val += 1
else:
	print('NO')


(n, m) = map(int, input().split())
sorted = []
unsorted = []
output = [-1] * (n + 1)
for _ in range(m):
	(ti, li, ri) = map(int, input().split())
	if ti == 1:
		sorted.append((li, ri))
	else:
		unsorted.append((li, ri))
sorted.sort()
unsorted.sort(key=lambda y: y[1] - y[0])
for i in sorted:
	for ii in range(i[0] + 1, i[1] + 1):
		output[ii] = 0
output[0] = 1001
for i in range(1, n + 1):
	output[i] += output[i - 1]
for i in unsorted:
	zi = output[i[0]:i[1] + 1]
	zi.sort()
	if zi == output[i[0]:i[1] + 1]:
		print('NO')
		exit()
print('YES')
print(*output[1:])


import sys
import math as mt
import bisect
t = 1

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = [-1] * (n + 1)
	l1 = []
	for i in range(m):
		(x, y, z) = map(int, input().split())
		if x == 1:
			for i in range(y + 1, z + 1):
				ans[i] = 0
		else:
			l1.append([y, z])
	flag = True
	ans[0] = 1010
	for i in range(1, n + 1):
		ans[i] += ans[i - 1]
	for i in range(len(l1)):
		if ans[l1[i][0]:l1[i][1] + 1] == sorted(ans[l1[i][0]:l1[i][1] + 1]):
			flag = False
			break
	if flag:
		print('YES')
		print(*ans[1:])
	else:
		print('NO')


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List

def merge(s):
	q = []
	for (l, r) in s:
		if not q:
			q.append((l, r))
		elif l <= q[-1][1]:
			(pl, pr) = q.pop()
			q.append((pl, max(r, pr)))
		else:
			q.append((l, r))
	return q

def solve(N, M, Q):
	A = [(l, r) for (t, l, r) in Q if t == 1]
	B = [(l, r) for (t, l, r) in Q if t == 0]
	A.sort()
	A = merge(A)
	for (la, ra) in A:
		for (lb, rb) in B:
			if la <= lb <= rb <= ra:
				print('NO')
				return
	d = [-1 for _ in range(N)]
	for (l, r) in A:
		for i in range(l + 1, r + 1):
			d[i] = 0
	v = N + 100
	ans = [0 for _ in range(N)]
	for i in range(N):
		v += d[i]
		ans[i] = v
	for (l, r) in B:
		if any([ans[i] > ans[i + 1] for i in range(l, r)]):
			continue
		else:
			print('NO')
			return
	print('YES')
	print(' '.join(map(str, ans)))
(N, M) = map(int, input().split())
Q = []
for i in range(M):
	(t, l, r) = map(int, input().split())
	Q.append((t, l - 1, r - 1))
solve(N, M, Q)


import math
import collections
import heapq
import bisect

def do():
	(N, n) = map(int, input().split(' '))
	d = []
	flag = [1] * N
	for _ in range(n):
		(f, s, e) = map(int, input().split(' '))
		d.append([f, s, e])
		if f:
			for i in range(s, e):
				flag[i] = 0
	for (f, s, e) in d:
		if not f:
			valid = any((flag[i] for i in range(s, e)))
			if not valid:
				print('NO')
				return 0
	cur = 1001
	res = []
	for i in range(1, N + 1):
		cur -= flag[i - 1]
		res.append(cur)
	print('YES')
	print(' '.join((str(c) for c in res)))
	return 0
do()


(n, m) = map(int, input().split())
A = [0] * n
R = []
for t in range(m):
	(t, L, r) = map(int, input().split())
	if t == 1:
		for i in range(L, r):
			A[i] = 1
	else:
		R.append([L, r])
valid = True
for exp in R:
	if not 0 in A[exp[0]:exp[1]]:
		if not -1 in A[exp[0]:exp[1]]:
			valid = False
			break
	else:
		A[A[exp[0]:exp[1]].index(0) + exp[0]] = -1
else:
	print('YES')
	ans = []
	Ld = 3000
	for i in A:
		if i == 0:
			ans.append(str(Ld))
		elif i == 1:
			ans.append(str(Ld + 1))
			Ld += 1
		else:
			ans.append(str(Ld - 1))
			Ld -= 1
	print(' '.join(ans))
if not valid:
	print('NO')


arr = input()
(N, M) = [int(x) for x in arr.split(' ')]
clue = [[0] * 3 for _ in range(M)]
for i in range(M):
	arr = input()
	(T, L, R) = [int(x) for x in arr.split(' ')]
	clue[i][0] = L
	clue[i][1] = R
	clue[i][2] = T
clue.sort()
ans = [-1] * N
number = 10000000
possible = 0
for i in range(M):
	if clue[i][2] == 1:
		left = clue[i][0] - 1
		right = clue[i][1] - 1
		flag = -1
		for j in range(left, right + 1):
			if ans[j] != -1:
				flag = ans[j]
				break
		if flag == -1:
			number -= 2000
			for j in range(left, right + 1):
				ans[j] = number
		else:
			for j in range(left, right + 1):
				ans[j] = flag
for i in range(M):
	if clue[i][2] == 0:
		left = clue[i][0] - 1
		right = clue[i][1] - 1
		last = ans[left]
		unorder = 0
		idx = left + 1
		while idx <= right:
			if ans[idx] < last or ans[idx] == -1 or last == -1:
				unorder = 1
				break
			last = ans[idx]
			idx += 1
		if unorder == 0:
			possible = 1
			break
if possible == 1:
	print('NO')
else:
	for i in range(N - 1):
		if ans[i] != -1 and ans[i + 1] == -1:
			ans[i + 1] = ans[i] - 1
	k = 100010000
	for i in range(N):
		if ans[i] == -1:
			ans[i] = k
			k -= 1
		else:
			break
	print('YES')
	for x in ans:
		print(x, end=' ')


(n, m) = map(int, input().split())
B = [-1] * (n - 1)
TLR = []
for i in range(m):
	(t, l, r) = map(int, input().split())
	(l, r) = (l - 1, r - 1)
	TLR.append((t, l, r))
	if t == 1:
		for j in range(l, r):
			B[j] = 0
A = [0] * n
A[0] = n
for i in range(n - 1):
	A[i + 1] = A[i] + B[i]
flag = True
for (t, l, r) in TLR:
	if t == 1:
		for i in range(l + 1, r + 1):
			if A[i] < A[i - 1]:
				flag = False
	else:
		flag2 = False
		for i in range(l + 1, r + 1):
			if A[i] < A[i - 1]:
				flag2 = True
		if not flag2:
			flag = False
if flag:
	print('YES')
	print(*A)
else:
	print('NO')


from functools import cmp_to_key

def comp(x, y):
	if x[0] != y[0]:
		return x[0] - y[0]
	return y[1] - x[1]
(n, m) = map(int, input().split())
ans = [-1 for i in range(n)]
tps = []
tans = [n]
for i in range(m):
	(t, l, r) = map(int, input().split())
	tps.append((l, r, t))
tps.sort(key=cmp_to_key(comp))
for i in range(m - 1):
	if tps[i][1] >= tps[i + 1][1] and tps[i][2] and (not tps[i + 1][2]):
		print('NO')
		exit(0)
for (l, r, t) in tps:
	if t:
		ans[l - 1:r - 1] = [1 for i in range(r - l)]
for i in range(1, n):
	tans.append(0)
	tans[i] = tans[i - 1] + ans[i - 1]
for (l, r, t) in tps:
	if t:
		if not all((tans[i] <= tans[i + 1] for i in range(l - 1, r - 1))):
			print('NO')
			exit(0)
	elif all((tans[i] <= tans[i + 1] for i in range(l - 1, r - 1))):
		print('NO')
		exit(0)
print('YES')
for i in tans:
	print(i, end=' ')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(lens, tips) = RMI()
pos = [[], []]
for i in range(tips):
	(mode, *ind) = RMI()
	pos[mode].append(ind)
canbe = True
maybe = [-1] * (lens - 1)
for lr in pos[1]:
	for curr in range(lr[0] - 1, lr[1] - 1):
		maybe[curr] = 0
for lr in pos[0]:
	if sum(maybe[lr[0] - 1:lr[1] - 1]) == 0:
		canbe = False
		break
if not canbe:
	print('NO')
else:
	print('YES')
	answer = [int(10000000.0)]
	for i in range(lens - 1):
		answer += [answer[-1] + maybe[i]]
	print(*answer)


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

class UnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for _ in range(N)]

	def find(self, x):
		if self.parent[x] == x:
			return x
		else:
			return self.find(self.parent[x])

	def union(self, x, y):
		px = self.find(x)
		py = self.find(y)
		if px == py:
			return
		if self.size[px] < self.size[py]:
			self.parent[px] = py
			self.size[py] += self.size[px]
		else:
			self.parent[py] = px
			self.size[px] += self.size[py]

	def same(self, x, y):
		return self.find(x) == self.find(y)

def solve():
	(N, M) = map(int, input().split())
	inc_query = []
	non_inc_query = []
	for _ in range(M):
		(t, l, r) = map(lambda x: int(x) - 1, input().split())
		if t == 0:
			inc_query.append([l, r])
		else:
			non_inc_query.append([l, r])
	Un = UnionFind(N)
	for (l, r) in inc_query:
		for i in range(l, r):
			Un.union(i, i + 1)
	for (l, r) in non_inc_query:
		for i in range(l, r):
			if Un.same(l, r):
				print('NO')
				return
	s = 10 ** 4
	ans = [s]
	for i in range(1, N):
		if Un.same(i, i - 1):
			ans.append(s)
		else:
			ans.append(s - 1)
			s -= 1
	print('YES')
	print(*ans)
solve()


(n, m) = map(int, input().split())
events = []
badguys = []
for _ in range(m):
	(t, l, r) = map(int, input().split())
	if t:
		events += [(l, 0), (r, 1)]
	else:
		badguys += [(l, r)]
events.sort()
goodguys = []
current = 0
for event in events:
	if event[1] == 0:
		if current == 0:
			goodguys += [[event[0], -1]]
		current += 1
	else:
		current -= 1
		if current == 0:
			goodguys[-1][-1] = event[0]
for badguy in badguys:
	for goodguy in goodguys:
		if badguy[0] >= goodguy[0] and badguy[1] <= goodguy[1]:
			print('NO')
			exit(0)
answer = [n + 1] * n
good_index = 0
i = 1
try:
	while i < n:
		if good_index < len(goodguys) and i == goodguys[good_index][0]:
			while i != goodguys[good_index][1]:
				answer[i] = answer[i - 1]
				i += 1
			good_index += 1
		else:
			answer[i] = answer[i - 1] - 1
			i += 1
	print('YES')
	print(' '.join(list(map(str, answer))))
except IndexError:
	print('NO')


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def read_string():
	return sys.stdin.readline().strip()

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)

def print_list(l, delim=' '):
	print(delim.join(map(str, l)))
(n, q) = read_int_list()
diffs = [1 for _ in range(n)]
tlrs = []
for _ in range(q):
	tlrs.append(read_int_list())
for (t, l, r) in tlrs:
	if t == 1:
		for i in range(l, r):
			diffs[i] = 0
for (t, l, r) in tlrs:
	if t == 0:
		all_0 = True
		for i in range(l, r):
			if diffs[i] != 0:
				all_0 = False
				break
		if all_0:
			print('NO')
			sys.exit()
		for i in range(l, r):
			if diffs[i] == 1:
				diffs[i] = -1
print('YES')
last = n
print(last, end=' ')
for i in range(1, n):
	last += diffs[i]
	print(last, end=' ')
print()