Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions.

So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime.

Input

The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day.

Output

In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them.

Examples

Input

1 48
5 7


Output

NO


Input

2 5
0 1
3 5


Output

YES
1 4

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms

Constructive algorithms


Solutions:
def print_arr(arr):
	for a in arr:
		print(a, end=' ')

def solution():
	(d, hr) = input().split()
	(d, hr) = (int(d), int(hr))
	intervals = []
	first = []
	for _ in range(d):
		(vmin, vmax) = input().split()
		(vmin, vmax) = (int(vmin), int(vmax))
		intervals.append((vmin, vmax))
		first.append(vmin)
	vmin = 0
	vmax = 0
	for (i, j) in intervals:
		vmin += i
		vmax += j
	if vmin > hr:
		print('NO')
		return
	if vmax < hr:
		print('NO')
		return
	hr -= vmin
	while True:
		for i in range(d):
			if first[i] < intervals[i][1]:
				first[i] += 1
				hr -= 1
			if hr == 0:
				print('YES')
				print_arr(first)
				return
solution()


d_summ = input()
d_summ = d_summ.split()
days = int(d_summ[0])
summ = int(d_summ[1])
maxx = []
minn = []
for day in range(days):
	mx_mn = input()
	mx_mn = mx_mn.split()
	mx = int(mx_mn[1])
	mn = int(mx_mn[0])
	maxx.append(mx)
	minn.append(mn)
raspis = []
for day in range(days):
	d = min(maxx[day], summ)
	raspis.append(d)
	summ = summ - d
if summ != 0:
	print('NO')
else:
	for i in range(days):
		if minn[i] > raspis[i]:
			for j in range(i):
				r = raspis[j] - minn[j]
				n = minn[i] - raspis[i]
				h = min(r, n)
				raspis[i] = raspis[i] + h
				raspis[j] = raspis[j] - h
	flag = True
	for i in range(days):
		if raspis[i] < minn[i]:
			flag = False
			break
	if flag:
		print('YES')
		pravo = []
		for elem in raspis:
			elem = str(elem)
			pravo.append(elem)
		print(' '.join(pravo))
	else:
		print('NO')


(x, y) = map(int, input().split())
r = []
total = 0
tac = 0
for i in range(x):
	(a, b) = map(int, input().split())
	r.append([a, b, b])
	total = total + b
	tac = tac + a
if total < y or y < tac:
	print('NO')
else:
	i = 0
	while i < x:
		if total == y:
			break
		if r[i][2] - 1 >= r[i][0]:
			r[i][2] = r[i][2] - 1
			total = total - 1
		if total == y:
			break
		if i == x - 1:
			i = 0
			continue
		i = i + 1
	print('YES')
	k = []
	for i in range(x):
		k.append(r[i][2])
	print(' '.join(map(str, k)))


l = lambda : map(int, input().split())
(d, s) = l()
a = [[*map(int, input().split())] for _ in [0] * d]
(b, c) = (sum((x[0] for x in a)), sum((x[1] for x in a)))
if b <= s <= c:
	print('YES')
	v = s - b
	r = []
	for (x, y) in a:
		if v > 0:
			l = min(v, y - x)
			v -= l
			x += l
		r += [x]
	print(*r)
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [tuple(map(int, l.split())) for l in sys.stdin]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(d, s) = LI()
	aa = [LI() for _ in range(d)]
	mis = sum(map(lambda x: x[0], aa))
	mas = sum(map(lambda x: x[1], aa))
	if s < mis or s > mas:
		return 'NO'
	r = []
	for (mi, ma) in aa:
		mis -= mi
		mas -= ma
		for k in range(mi, ma + 1):
			if mis <= s - k <= mas:
				r.append(k)
				s -= k
				break
	return 'YES\n{}'.format(' '.join(map(str, r)))
print(main())


from sys import stdin

def main():
	data = stdin.readline().strip()
	(days, total_time) = map(int, data.split())
	days_data = []
	days_output = [0] * days
	for i in range(days):
		days_data.append(tuple(map(int, stdin.readline().strip().split())))
	for (i, day_data) in enumerate(days_data):
		total_time -= day_data[0]
		days_output[i] += day_data[0]
		if total_time < 0:
			print('NO')
			exit(0)
	for (i, day_data) in enumerate(days_data):
		remaining = day_data[1] - days_output[i]
		used = min(total_time, remaining)
		total_time -= used
		days_output[i] += used
		if total_time == 0:
			break
	if total_time > 0:
		print('NO')
		exit(0)
	print('YES')
	print(' '.join(map(str, days_output)))
main()


(d, sumTime) = map(int, input().split())
minTimes = []
maxTimes = []
timeDiffs = []
sumMaxTimes = 0
sumMinTimes = 0
curTimes = []
for _ in range(d):
	(t1, t2) = map(int, input().split())
	minTimes.append(t1)
	maxTimes.append(t2)
	timeDiffs.append(t2 - t1)
	sumMinTimes += t1
	sumMaxTimes += t2
	curTimes.append(t2)
if not sumMinTimes <= sumTime <= sumMaxTimes:
	print('NO')
else:
	reduction = sumMaxTimes - sumTime
	for num in range(d):
		if reduction >= timeDiffs[num]:
			curTimes[num] = minTimes[num]
			reduction = reduction - timeDiffs[num]
		else:
			curTimes[num] = curTimes[num] - reduction
			break
	print('YES')
	for i in range(d):
		print(curTimes[i], end=' ')


import sys

def main():
	input_line = [int(x) for x in input().split(' ')]
	(days, sum_time) = (input_line[0], input_line[1])
	min_sum = 0
	max_sum = 0
	times = []
	study_time = []
	for day in range(days):
		time_line = input().split(' ')
		(min_time, max_time) = (int(time_line[0]), int(time_line[1]))
		times.append((min_time, max_time))
		study_time.append(min_time)
		min_sum += min_time
		max_sum += max_time
	if sum_time < min_sum or sum_time > max_sum:
		print('NO')
	else:
		left = sum_time - min_sum
		for t in range(len(times)):
			diff = times[t][1] - times[t][0]
			if diff < left:
				study_time[t] = times[t][1]
				left -= diff
			else:
				study_time[t] += left
				break
		print('YES')
		output = ''
		for time in study_time:
			output += str(time) + ' '
		print(output)
main()


(d, s) = map(int, input().split())
a = [0] * d
b = [0] * d
c = [0] * d
x = 0
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
k = s - sum(a)
for i in range(d):
	c[i] = b[i] - a[i]
if s < sum(a) or s > sum(b):
	print('NO')
else:
	print('YES')
	while k > 0:
		if k - c[x] >= 0:
			k -= c[x]
			print(b[x], end=' ')
			x = x + 1
		elif k - c[x] < 0:
			print(b[x] + k - c[x], end=' ')
			k -= c[x]
			x += 1
			break
	if x <= d - 1:
		for j in range(x, d):
			print(a[j], end=' ')


(d, s) = map(int, input().split())
mM = []
m_ = 0
M_ = 0
for i in range(d):
	(m, M) = map(int, input().split())
	m_ += m
	M_ += M
	mM.append((m, M))
if m_ <= s <= M_:
	ans = [-1] * d
	t = s - m_
	for i in range(d):
		(m, M) = mM[i]
		if t:
			if m + t <= M:
				ans[i] = m + t
				t = 0
			else:
				ans[i] = M
				t -= M - m
		else:
			ans[i] = m
	print('YES')
	print(*ans)
else:
	print('NO')


(d, sumTime) = map(int, input().split(' '))
lower = []
upper = []
for _ in range(d):
	(l, u) = map(int, input().split(' '))
	lower += [l]
	upper += [u]
totalUpper = sum(upper)
totalLower = sum(lower)
if sumTime > totalUpper or sumTime < totalLower:
	print('NO')
else:
	print('YES')
	index = 0
	while totalLower < sumTime:
		if lower[index] == upper[index]:
			index += 1
		else:
			lower[index] += 1
			totalLower += 1
	print(' '.join([str(i) for i in lower]))


(d, sumtime) = [int(i) for i in input().split()]
time = [0] * d
(mintime, maxtime) = (0, 0)
for i in range(d):
	time[i] = [int(i) for i in input().split()]
	mintime += time[i][0]
	maxtime += time[i][1]
if sumtime < mintime or sumtime > maxtime:
	print('NO')
else:
	print('YES')
	ans = [i[0] for i in time]
	i = 0
	while mintime < sumtime:
		if ans[i] < time[i][1]:
			ans[i] += 1
			mintime += 1
		else:
			i += 1
	print(*ans)


(n, m) = map(int, input().split())
l = []
f = 0
l1 = []
for _ in range(n):
	(c, t) = map(int, input().split())
	l1.append((c, t))
	l.append(c)
	m -= c
	if m < 0:
		print('NO')
		f = 1
		break
if f == 0:
	for i in range(n):
		if m >= l1[i][1] - l1[i][0]:
			m -= l1[i][1] - l1[i][0]
			l[i] = l1[i][1]
		else:
			l[i] += m
			m = 0
			break
	if m > 0:
		print('NO')
	else:
		print('YES')
		print(*l)


(a, b) = map(int, input().split())
d = []
e = []
f = []
for i in range(a):
	c = list(map(int, input().split()))
	d.append(c[0])
	e.append(c[1])
if sum(d) > b or sum(e) < b:
	print('NO')
else:
	print('YES')
	if sum(d) < b:
		z = b - sum(d)
		for j in range(a):
			if e[j] - d[j] >= z:
				d[j] = d[j] + z
				break
			else:
				z = z - e[j] + d[j]
				d[j] = e[j]
		print(*d)
	else:
		print(*d)


__author__ = 'Darren'

def solve():
	import sys
	stdin = sys.stdin if True else open('data')
	(d, sum_time) = map(int, next(stdin).split())
	min_max = []
	(min_total, max_total) = (0, 0)
	for line in stdin:
		temp = list(map(int, line.split()))
		min_max.append(temp)
		min_total += temp[0]
		max_total += temp[1]
	if min_total <= sum_time <= max_total:
		print('YES')
		extra = sum_time - min_total
		for item in min_max:
			if extra >= item[1] - item[0]:
				print(item[1], end=' ')
				extra -= item[1] - item[0]
			elif extra == 0:
				print(item[0], end=' ')
			else:
				print(item[0] + extra, end=' ')
				extra = 0
	else:
		print('NO')
solve()


(a, b) = [int(x) for x in input().split()]
(m, n) = ([], [])
for i in range(a):
	(x, y) = [int(x) for x in input().split()]
	m.append(x)
	n.append(y)
if sum(m) <= b <= sum(n):
	b -= sum(m)
	for i in range(a):
		add = min(b, n[i] - m[i])
		m[i] = m[i] + add
		b -= add
	print('YES')
	for j in m:
		print(j, end=' ')
else:
	print('NO')


(d, sumtime) = map(int, input().rstrip().split())
limit = list()
orig = sumtime
lowlim = 0
highlim = 0
res = []
for i in range(d):
	temp = list(map(int, input().rstrip().split()))
	limit.append(temp)
	lowlim += temp[0]
	highlim += temp[1]
	if sumtime >= 0:
		res.append(temp[0])
		sumtime -= temp[0]
if orig >= lowlim and orig <= highlim:
	print('YES')
	for k in range(d):
		if sumtime > 0:
			if sumtime >= limit[k][1] - limit[k][0]:
				res[k] = limit[k][1]
				sumtime -= limit[k][1] - limit[k][0]
			else:
				res[k] += sumtime
				sumtime = 0
		else:
			break
	for l in res:
		print(l, end=' ')
else:
	print('NO')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

@lru_cache(None)
def rec(i, count):
	if i == d:
		if count == st:
			global pos
			pos = 1
			return True
		return False
	if count > st or count + 8 * (d - i) < st:
		return False
	for j in range(A[i][0], A[i][1] + 1):
		if rec(i + 1, count + j):
			ans.append(j)
			return True
	return False
(d, st) = L()
A = [L() for i in range(d)]
global pos
pos = 0
ans = []
rec(0, 0)
if pos == 1:
	print('YES')
	print(*ans[::-1])
else:
	print('NO')
endtime = time.time()


(d, s) = map(int, input().split())
arr = []
for i in range(d):
	arr.append(tuple(map(int, input().split())))
val = [0] * d
for i in range(d):
	val[i] = arr[i][0]
	s -= arr[i][0]
else:
	if s < 0:
		print('NO')
		exit(0)
for i in range(d):
	diff = min(arr[i][1] - arr[i][0], s)
	val[i] += diff
	s -= diff
else:
	if s > 0:
		print('NO')
	else:
		print('YES')
		print(*val, sep=' ')


str1 = input().split()
n = int(str1[0])
s = int(str1[1])
minimum = list()
maximum = list()
for i in range(n):
	str2 = input().split()
	minimum.append(int(str2[0]))
	maximum.append(int(str2[1]))
if sum(minimum) > s or sum(maximum) < s:
	print('NO')
else:
	val = sum(maximum) - s
	ans = list()
	print('YES')
	ct = 0
	while val > 0:
		v2 = min(val, maximum[ct] - minimum[ct])
		maximum[ct] -= v2
		val -= v2
		ct += 1
	for i in range(n):
		ans.append(str(maximum[i]) + ' ')
	print(''.join(ans))


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(d, st) = f()
lmin = []
lmax = []
for _ in range(d):
	(a, b) = f()
	lmax.append(b)
	lmin.append(a)
if st < sum(lmin) or st > sum(lmax):
	print('NO')
else:
	st -= sum(lmin)
	for i in range(d):
		t = min(st, lmax[i] - lmin[i])
		st -= t
		lmin[i] += t
	print('YES')
	print(*lmin)


I = lambda : list(map(int, input().split()))
(d, s) = I()
mm = [I() for i in range(d)]
if sum([i[0] for i in mm]) > s or sum([i[1] for i in mm]) < s:
	print('NO')
else:
	print('YES')
	ans = []
	rem = s - sum([i[0] for i in mm])
	for i in mm:
		add = min(rem, i[1] - i[0])
		rem -= add
		ans.append(i[0] + add)
	print(' '.join(map(str, ans)))


import sys
(d, total_time) = map(int, sys.stdin.readline().split(' '))
minhrs = []
maxhrs = []
mi = 0
ma = 0
for x in range(d):
	(min1, max) = map(int, sys.stdin.readline().split(' '))
	minhrs.append(min1)
	maxhrs.append(max)
	mi += min1
	ma += max
if total_time < mi or total_time > ma:
	print('NO')
else:
	print('YES')
	total_time -= mi
	for y in range(d):
		next = min(maxhrs[y] - minhrs[y], total_time)
		print(minhrs[y] + next, end=' ')
		total_time -= next


(d, sumTime) = map(int, input().split())
LT = []
Summin = 0
Summax = 0
for i in range(d):
	(m, n) = map(int, input().split())
	Summin += m
	Summax += n
	LT.append([m, n])
if sumTime > Summax:
	print('NO')
elif sumTime < Summin:
	print('NO')
elif sumTime == Summax:
	print('YES')
	for i in range(d):
		print(LT[i][1], end=' ')
elif sumTime == Summin:
	print('YES')
	for i in range(d):
		print(LT[i][0], end=' ')
else:
	dem = -1
	print('YES')
	for i in range(d):
		Summin = Summin - LT[i][0]
		for j in range(LT[i][0], LT[i][1] + 1, 1):
			Summin += j
			if sumTime == Summin:
				LT[i][1] = j
				dem = i
				break
			Summin -= j
		Summin = Summin + LT[i][1]
		if dem != -1:
			break
	for i in range(d):
		if i <= dem:
			print(LT[i][1], end=' ')
		elif i > dem:
			if i != d - 1:
				print(LT[i][0], end=' ')
			else:
				print(LT[i][0])


(d, sumTime) = map(int, input().split())
minTimes = []
maxTimes = []
for i in range(d):
	(mins, maxs) = map(int, input().split())
	minTimes.append(mins)
	maxTimes.append(maxs)
if sum(minTimes) <= sumTime <= sum(maxTimes):
	print('YES')
	sumTime -= sum(minTimes)
	ans = []
	for i in range(d):
		a = min(sumTime, maxTimes[i] - minTimes[i])
		sumTime -= a
		ans.append(str(minTimes[i] + a))
	print(' '.join(ans))
else:
	print('NO')


(d, s) = map(int, input().split())
sum1 = 0
sum2 = 0
list1 = []
list2 = []
for i in range(d):
	(a, b) = map(int, input().split())
	sum1 += b
	list2.append(b)
	sum2 += b - a
	list1.append(b - a)
if s == sum1:
	print('YES')
	print(*list2)
elif s > sum1:
	print('NO')
else:
	diff = sum1 - s
	for i in range(d):
		if list1[i] > 0 and diff:
			if list1[i] <= diff:
				list2[i] -= list1[i]
				diff -= list1[i]
			else:
				list2[i] -= diff
				diff = 0
	if sum(list2) == s:
		print('YES')
		print(*list2)
	else:
		print('NO')


(d, s) = map(int, input().split())
mins = []
maxs = []
s_min = 0
s_max = 0
for i in range(d):
	(a, b) = map(int, input().split())
	mins.append(a)
	maxs.append(b)
	s_min += a
	s_max += b
if s < s_min or s > s_max:
	print('NO')
else:
	print('YES')
	for i in range(len(mins)):
		if maxs[i] - mins[i] < s - s_min:
			s_min += maxs[i] - mins[i]
			mins[i] = maxs[i]
		else:
			mins[i] += s - s_min
			break
	z = ''
	for x in mins:
		z += str(x) + ' '
	print(z)


def readln(inp=None):
	return tuple(map(int, (inp or input()).split()))
(d, s) = readln()
(a, b) = list(zip(*[readln() for _ in range(d)]))
if not sum(a) <= s <= sum(b):
	print('NO')
else:
	print('YES')
	cur = sum(a)
	for (i, j) in zip(a, b):
		if cur - i + j < s:
			cur += j - i
			print(j, end=' ')
		elif cur - i + j >= s:
			print(s - cur + i, end=' ')
			cur = s
		else:
			print(i, end=' ')
print()


(d, tot_h) = [int(x) for x in input().split(' ')]
hours = []
for _ in range(d):
	(min_h, max_h) = [int(x) for x in input().split(' ')]
	hours.append((min_h, max_h, max_h - min_h))
tot_min = sum([x for (x, _, _) in hours])
tot_max = sum([x for (_, x, _) in hours])
if tot_h < tot_min or tot_h > tot_max:
	print('NO')
else:
	base_sol = [x for (x, _, _) in hours]
	rest = tot_h - tot_min
	i = 0
	while rest > 0:
		add_up = min(rest, hours[i][2])
		base_sol[i] += add_up
		rest -= add_up
		i += 1
	print('YES')
	print(' '.join([str(i) for i in base_sol]))


(d, s) = map(int, input().split())
t = [tuple(map(int, input().split())) for i in range(d)]
(m, M) = map(sum, zip(*t))
if m <= s <= M:
	print('YES')
	ans = []
	s -= m
	for (a, b) in t:
		ans.append(a + min(s, b - a))
		s = max(0, s - b + a)
	print(' '.join(map(str, ans)))
else:
	print('NO')


entrada = input().split(' ')
d = int(entrada[0])
sumTime = int(entrada[1])
schedule = []
b = []
for i in range(d):
	entrada = input().split(' ')
	minTime = int(entrada[0])
	maxTime = int(entrada[1])
	schedule.append([minTime, maxTime])
	b.append(minTime)
s = sum(b)
if s > sumTime:
	print('NO')
else:
	modified = True
	while modified and s < sumTime:
		modified = False
		i = 0
		while i < len(b) and s < sumTime:
			if schedule[i][1] > b[i]:
				s += 1
				b[i] += 1
				modified = True
			i += 1
	if s == sumTime:
		print('YES')
		for k in b:
			print(k, end=' ')
	else:
		print('NO')


(d, sumTime) = map(int, input().split())
minl = []
maxl = []
for i in range(d):
	(a, b) = map(int, input().split())
	minl += [a]
	maxl += [b]
if sum(minl) <= sumTime <= sum(maxl):
	print('YES')
	sumTime -= sum(minl)
	for i in range(d):
		print(minl[i] + min(sumTime, maxl[i] - minl[i]))
		sumTime = max(0, sumTime - maxl[i] + minl[i])
else:
	print('NO')


(d, sum_time) = map(int, input().split())
min_time = []
max_time = []
for i in range(d):
	(cur_min_time, cur_max_time) = map(int, input().split())
	min_time.append(cur_min_time)
	max_time.append(cur_max_time)
if sum(min_time) <= sum_time <= sum(max_time):
	print('YES')
	left_max_time = sum(max_time)
	ans = []
	for i in range(d):
		left_max_time -= max_time[i]
		today_time = max(min_time[i], sum_time - left_max_time)
		ans.append(today_time)
		sum_time -= today_time
	print(' '.join(map(str, ans)))
else:
	print('NO')


def CF_4B():
	(d, sumTime) = list(map(int, input().split()))
	days = []
	minTime = 0
	maxTime = 0
	for i in range(d):
		days.append(list(map(int, input().split())))
		minTime += days[-1][0]
		maxTime += days[-1][1]
	if minTime <= sumTime <= maxTime:
		schedule = []
		print('YES')
		for i in range(d):
			schedule.append(days[i][0])
		i = 0
		while minTime != sumTime:
			if days[i][0] < days[i][1]:
				if sumTime - minTime >= days[i][1] - days[i][0]:
					schedule[i] = days[i][1]
					minTime += days[i][1] - days[i][0]
					i += 1
				else:
					schedule[i] += sumTime - minTime
					break
			else:
				i += 1
				continue
		print(' '.join(map(repr, schedule)))
	else:
		print('NO')
	return
CF_4B()


(d, sumTime) = map(int, input().split())
smin = []
smax = []
for _ in range(d):
	(mi, ma) = map(int, input().split())
	smin.append(mi)
	smax.append(ma)
if sumTime < sum(smin) or sumTime > sum(smax):
	print('NO')
else:
	print('YES')
	s = sumTime - sum(smin)
	for i in range(d):
		f = min(s, smax[i] - smin[i])
		s -= f
		print(smin[i] + f, end=' ')


(d, sumT) = map(int, input().split())
sums = []
(minT, maxT) = map(int, input().split())
for j in range(minT, maxT + 1):
	sums.append((j, [j]))
for i in range(1, d):
	(minT, maxT) = map(int, input().split())
	ns = []
	val = set()
	for s in sums:
		x = s[0]
		if not x in val:
			val.add(x)
			for j in range(minT, maxT + 1):
				su = x + j
				if su <= sumT:
					ns.append((x + j, s[1] + [j]))
				else:
					break
	sums = ns
good = False
for s in sums:
	if s[0] == sumT:
		good = True
		print('YES')
		print(*s[1])
		break
if not good:
	print('NO')


(d, sumtime) = map(int, input().split())
a = [0] * d
b = [0] * d
(upper_bound, bottom_line) = (0, 0)
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
	bottom_line += a[i]
	upper_bound += b[i]
if bottom_line <= sumtime <= upper_bound:
	print('YES')
	p = sumtime - bottom_line
	for i in range(d):
		print(a[i] + min(p, b[i] - a[i]), end=' ')
		p -= min(p, b[i] - a[i])
else:
	print('NO')


(d, sumtime) = list(map(int, input().split()))
mint = []
maxt = []
maxtt = 0
mintt = 0
tmin = 0
tmax = 0
pmin = []
pmax = []
pmin.append(0)
pmax.append(0)
for _ in range(d):
	(mintt, maxtt) = list(map(int, input().split()))
	tmin += mintt
	tmax += maxtt
	pmin.append(pmin[-1] + mintt)
	pmax.append(pmax[-1] + maxtt)
	mint.append(mintt)
	maxt.append(maxtt)
if sumtime < tmin or sumtime > tmax:
	print('NO')
else:
	print('YES')
	for k in range(d):
		while tmin < sumtime:
			if mint[k] < maxt[k]:
				mint[k] += 1
				sumtime -= 1
			else:
				break
	for i in mint:
		print(i, end=' ')


(d, t) = map(int, input().split())
minimum = 0
maximum = 0
min_list = []
max_list = []
ans = []
for i in range(d):
	(mi, ma) = map(int, input().split())
	min_list.append(mi)
	max_list.append(ma)

def hours(time):
	if sum(min_list) == time:
		return min_list
	else:
		k = 0
		while sum(min_list) < time:
			if min_list[k] < max_list[k]:
				min_list[k] = min_list[k] + 1
			else:
				k = k + 1
		return min_list
if sum(min_list) <= t <= sum(max_list):
	print('YES')
	answer = hours(t)
	print(*answer, sep=' ')
else:
	print('NO')


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	(d, st) = Scanner.map_int()
	M = Scanner.int_list_list(d)
	(mi, ma) = (0, 0)
	for i in range(d):
		mi += M[i][0]
		ma += M[i][1]
	if mi <= st <= ma:
		print('YES')
		ans = [m[0] for m in M]
		st -= mi
		for i in range(d):
			a = min(st, M[i][1] - M[i][0])
			ans[i] += a
			st -= a
		print(*ans)
	else:
		print('NO')
main()


(d, sumTime) = map(int, input().split())
_min = 0
_max = 0
times = []
for i in range(d):
	(minTime, maxTime) = map(int, input().split())
	_min += minTime
	_max += maxTime
	times.append([minTime, maxTime])
if _max >= sumTime >= _min:
	print('YES')
	FFLAG = False
	for i in range(d):
		s = times[i][0]
		e = times[i][1]
		for j in range(e - s):
			if _max == sumTime:
				FFLAG = True
				break
			_max -= 1
			times[i][1] -= 1
		if FFLAG:
			break
	for i in range(d):
		print(times[i][1], end=' ')
else:
	print('NO')


line = input()
(days, sumTotal) = [int(i) for i in line.split(' ')]
minTotal = maxTotal = 0
timetable = []
soFar = 0
maximums = []
for d in range(days):
	line = input()
	(minTime, maxTime) = [int(i) for i in line.split(' ')]
	minTotal += minTime
	maxTotal += maxTime
	maximums.append(maxTime)
	soFar += minTime
	timetable.append(minTime)
leftover = sumTotal - soFar
for i in range(len(maximums)):
	maximum = maximums[i]
	maxExtra = maximum - timetable[i]
	extraTime = min(maxExtra, leftover)
	timetable[i] += extraTime
	leftover -= extraTime
	if leftover == 0:
		break
if sumTotal >= minTotal and sumTotal <= maxTotal:
	print('YES')
	print(' '.join([str(t) for t in timetable]))
else:
	print('NO')


(num_days, hours) = (int(x) for x in input().split())
days = []
for _ in range(num_days):
	days.append(tuple((int(x) for x in input().split())))
(min_total, max_total) = (sum(x) for x in zip(*days)) if len(days) > 1 else days[0]
if min_total <= hours <= max_total:
	final_days = [x for (x, y) in days]
	current = min_total
	for (idx, d) in enumerate(days):
		if current == hours:
			break
		(min_days, max_day) = d
		final_days[idx] = max_day
		current += final_days[idx] - min_days
		if current > hours:
			final_days[idx] -= current - hours
			current = hours
	print('YES')
	print(*(str(x) for x in final_days))
else:
	print('NO')


(d, sunTime) = map(int, input().split())
mini = 0
maxi = 0
c = []
for q in range(d):
	(a, b) = map(int, input().split())
	c.append([a, b])
	mini += a
	maxi += b
if mini <= sunTime and maxi >= sunTime:
	print('YES')
	ans = mini
	ind = 0
	while ans != sunTime:
		if c[ind][0] < c[ind][1]:
			c[ind][0] += 1
			ans += 1
		else:
			ind += 1
	for i in c:
		print(i[0], end=' ')
else:
	print('NO')


ls = list(map(int, input().split()))
(d, sumtime) = (ls[0], ls[1])
mins = 0
maxs = 0
ls1 = []
for i in range(d):
	s = list(map(int, input().split()))
	mins = s[0] + mins
	maxs = s[1] + maxs
	ls1.append(s)
j = 0
if mins <= sumtime and maxs >= sumtime:
	print('YES')
	sum1 = sumtime - mins
	while sum1 != 0:
		if ls1[j][1] - ls1[j][0] <= sum1:
			sum1 = sum1 - (ls1[j][1] - ls1[j][0])
			ls1[j][0] = ls1[j][1]
			j = j + 1
		else:
			ls1[j][0] = ls1[j][0] + sum1
			sum1 = 0
			j = j + 1
			break
	for k in range(d):
		print(str(ls1[k][0]) + ' ', end='')
else:
	print('NO')


(d, sumTime) = map(int, input().split())
minTimeList = []
maxTimeList = []
for i in range(d):
	(minTime, maxTime) = map(int, input().split())
	minTimeList.append(minTime)
	maxTimeList.append(maxTime)
minSum = sum(minTimeList)
maxSum = sum(maxTimeList)
if minSum <= sumTime <= maxSum:
	print('YES')
	assignments = []
	for (minBound, maxBound) in zip(minTimeList, maxTimeList):
		excess = min(maxBound - minBound, sumTime - minSum)
		sumTime -= excess
		print(minBound + excess, end=' ')
else:
	print('NO')


(d, T) = list(map(int, input().split()))
(a, b) = (0, 0)
Min = []
Max = []
Dif = []
for _ in range(d):
	(nota, notb) = list(map(int, input().split()))
	a += nota
	b += notb
	Min.append(nota)
	Max.append(notb)
	Dif.append(notb - nota)
if T < a or T > b:
	print('NO')
else:
	print('YES')
	T -= a
	for i in range(d):
		if T >= Dif[i]:
			print(Min[i] + Dif[i], end=' ')
			T -= Dif[i]
		elif T > 0 and T < Dif[i]:
			print(Min[i] + T, end=' ')
			T = 0
		else:
			print(Min[i], end=' ')


import sys
firstline = sys.stdin.readline().split()
d = int(firstline[0])
sum_times = int(firstline[1])
lower = []
higher = []
for i in range(d):
	line = sys.stdin.readline().split()
	lower.append(int(line[0]))
	higher.append(int(line[1]))
if sum_times >= sum(lower) and sum_times <= sum(higher):
	print('YES')
	excess = sum_times - sum(lower)
	for i in range(d):
		removed = min(higher[i] - lower[i], excess)
		print(str(lower[i] + removed), end=' ')
		excess -= removed
else:
	print('NO')


def start():
	(n, m) = [int(i) for i in input().split()]
	l = []
	for i in range(n):
		l.append([int(i) for i in input().split()])
	(max, minx) = (0, 0)
	for i in l:
		minx += i[0]
		max += i[1]
	if m >= minx and m <= max:
		print('YES')
		m -= minx
		for i in l:
			print(min(i[1], i[0] + m), end=' ')
			m = m - min(i[1], i[0] + m) + i[0]
	else:
		print('NO')
tc = 1
while tc:
	start()
	tc = tc - 1


(d, s) = map(int, input().split(' '))
a = []
b = []
e = []
for i in range(d):
	(g, h) = map(int, input().split(' '))
	a.append(g)
	b.append(h)
	e.append(h - g)
if sum(a) <= s <= sum(b):
	print('YES')
	c = s - sum(a)
	if c == 0:
		for i in a:
			print(i, end=' ')
		print()
	elif c == sum(e):
		for i in b:
			print(i, end=' ')
		print()
	else:
		for i in range(len(a)):
			if c != 0:
				c = c - b[i] + a[i]
				if c > 0:
					print(b[i], end=' ')
				elif c == 0:
					print(b[i], end=' ')
				else:
					c = c + b[i]
					if a[i] <= c <= b[i]:
						print(c, end=' ')
						c = c - c
			elif c == 0:
				print(a[i], end=' ')
		print()
else:
	print('NO')


(d, s_time) = map(int, input().split())
l_time = []
h_time = []
for i in range(d):
	(l, h) = map(int, input().split())
	l_time += [l]
	h_time += [h]
if s_time < sum(l_time) or s_time > sum(h_time):
	print('NO')
else:
	print('YES')
	ans = l_time
	tot_time = sum(l_time)
	for i in range(d):
		if tot_time < s_time:
			ch_time = min(h_time[i] - l_time[i], s_time - tot_time)
			tot_time += ch_time
			l_time[i] += ch_time
		else:
			break
	print(' '.join((str(x) for x in l_time)))


def Exam(d, sumTime, minTime, maxTime):
	hours = minTime
	sumHours = sum(hours)
	i = 1
	while i <= d and sumHours < sumTime:
		if hours[i] == maxTime[i]:
			i += 1
		else:
			hours[i] += 1
			sumHours += 1
	if sumHours == sumTime:
		print('YES')
		print(*hours[1:])
	else:
		print('NO')
(d, sumTime) = [int(x) for x in input().split()]
minTime = [0] * (d + 1)
maxTime = [0] * (d + 1)
for i in range(1, d + 1):
	(minTime[i], maxTime[i]) = [int(x) for x in input().split()]
Exam(d, sumTime, minTime, maxTime)


def main():
	(total_days, hours) = [int(i) for i in input().split()]
	min_hour = []
	max_hour = []
	for i in range(total_days):
		(x, y) = [int(x) for x in input().split()]
		min_hour.append(x)
		max_hour.append(y)
	if sum(max_hour) < hours or sum(min_hour) > hours:
		print('NO')
		exit()
	hours -= sum(min_hour)
	for i in range(total_days):
		add = min(max_hour[i] - min_hour[i], hours)
		min_hour[i] = str(min_hour[i] + add)
		hours -= add
	print('YES')
	print(' '.join(min_hour))
main()


(d, sT) = map(int, input().split())
mi = []
ma = []
for i in range(d):
	(a, b) = map(int, input().split())
	mi.append(a)
	ma.append(b)
if not sum(mi) <= sT <= sum(ma):
	print('NO')
else:
	print('YES')
	q = sT - sum(mi)
	for i in range(d):
		if ma[i] - mi[i] <= q:
			q -= ma[i] - mi[i]
			print(ma[i], end=' ')
		else:
			print(mi[i] + q, end=' ')
			q = 0


def printSchedule(sumTime, intervals):
	schedule = list()
	for i in intervals:
		if sumTime < i[0]:
			print('NO')
			return
		sumTime -= i[0]
		schedule.append(i[0])
	for i in range(len(intervals)):
		diff = intervals[i][1] - intervals[i][0]
		if sumTime <= diff:
			schedule[i] += sumTime
			print('YES')
			print(*schedule)
			return
		sumTime -= diff
		schedule[i] += diff
	if sumTime > 0:
		print('NO')
(d, sumTime) = list(map(int, input().split()))
intervals = list()
for _ in range(d):
	(minTime, maxTime) = list(map(int, input().split()))
	intervals.append((minTime, maxTime))
printSchedule(sumTime, intervals)


(d, sumTime) = [int(a) for a in input().strip().split(' ')]
hours = []
for i in range(d):
	lim = [int(a) for a in input().strip().split(' ')]
	hours.append(lim)
schedule = [x[1] for x in hours]
if not (sumTime >= sum((x[0] for x in hours)) and sumTime <= sum((x[1] for x in hours))):
	print('NO')
else:
	print('YES')
	remainingHours = sum(schedule) - sumTime
	for i in range(d):
		t = min(remainingHours, schedule[i] - hours[i][0])
		schedule[i] -= t
		remainingHours -= t
		if remainingHours == 0:
			break
	for x in schedule:
		print(x, end=' ')
	print()


(x, y) = map(int, input().split())
(min1, max1) = (0, 0)
li = []
li1 = []
for i in range(x):
	(m, n) = map(int, input().split())
	li.append(m)
	li1.append(n)
	min1 += m
	max1 += n
if min1 <= y <= max1:
	print('YES')
	if min1 == y:
		print(*li)
	else:
		a = y - min1
		i = 0
		while a and i < x:
			p = min(a, li1[i] - li[i])
			li[i] += p
			a -= p
			i += 1
		print(*li)
else:
	print('NO')


import sys

def main():
	(days, hours) = map(int, sys.stdin.readline().strip().split())
	min_hours = []
	max_hours = []
	for _ in range(days):
		(a, b) = map(int, sys.stdin.readline().strip().split())
		min_hours.append(a)
		max_hours.append(b)
	sum_min_hours = sum(min_hours)
	sum_max_hours = sum(max_hours)
	if sum_min_hours <= hours <= sum_max_hours:
		sys.stdout.write('YES' + '\n')
		for d in range(days):
			sum_min_hours -= min_hours[d]
			study = max_hours[d] - max(0, sum_min_hours - (hours - max_hours[d]))
			sys.stdout.write(str(study) + ' ')
			hours -= study
		sys.stdout.write('\n')
	else:
		sys.stdout.write('NO' + '\n')
main()


x = input()
days = int(x.split(' ')[0])
time_total = int(x.split(' ')[1])
min_max = []
for i in range(days):
	v = input()
	min_max.append((int(v.split(' ')[0]), int(v.split(' ')[1])))

def main(days, time_total, min_max):
	mi = 0
	ma = 0
	for i in min_max:
		mi += i[0]
		ma += i[1]
	if mi <= time_total <= ma:
		x = time_total - mi
		lis = [i[0] for i in min_max]
		z = 0
		while x > 0:
			if min_max[z][1] - min_max[z][0] >= x:
				lis[z] = lis[z] + x
				x = 0
			else:
				lis[z] = lis[z] + (min_max[z][1] - min_max[z][0])
				x = x - (min_max[z][1] - min_max[z][0])
				z += 1
		print('YES')
		print(' '.join((str(x) for x in lis)))
	else:
		print('NO')
main(days, time_total, min_max)


(d, total) = list(map(int, input().split()))
(a, b) = ({}, {})
for i in range(1, d + 1):
	(mi, ma) = list(map(int, input().split()))
	a[i] = mi
	b[i] = ma
(p, q) = (0, 0)
for i in a:
	p += a[i]
for i in b:
	q += b[i]
if q < total:
	print('NO')
elif p > total:
	print('NO')
else:
	w = 0
	for i in a:
		while a[i] <= b[i]:
			if p == total:
				w = w + 1
				break
			else:
				a[i] = a[i] + 1
				p = p + 1
		if w == 1:
			print('YES')
			for i in a:
				print(a[i], end=' ')
			break
		if w == 0:
			a[i] = a[i] - 1
			p = p - 1


def r():
	(d, s) = map(int, input().split())
	ma = mi = 0
	z = []
	for i in range(d):
		k = list(map(int, input().split()))
		ma += k[1]
		mi += k[0]
		z.append(k + [mi, ma])
	if not mi <= s <= ma:
		print('NO')
	else:
		print('YES')
		i = 0
		for i in z:
			k = i[0]
			s -= k
			while k < i[1] and s > mi - i[2] and (s > 0):
				k += 1
				s -= 1
			print(k, end=' ')
r()


(days, sum_of_hours) = map(int, input().split())
lis = [tuple(map(int, input().split())) for i in range(days)]
(min_hours, max_hours) = map(sum, zip(*lis))
if min_hours <= sum_of_hours <= max_hours:
	print('YES')
	ans = []
	sum_of_hours -= min_hours
	for (a, b) in lis:
		ans.append(a + min(sum_of_hours, b - a))
		sum_of_hours = max(0, sum_of_hours - b + a)
	print(' '.join(map(str, ans)))
else:
	print('NO')


(n, k) = map(int, input().rstrip().split(' '))
min_list = [0] * n
max_list = [0] * n
d = [0] * n
i = 0
while n:
	(a, b) = map(int, input().rstrip().split(' '))
	min_list[i] = a
	max_list[i] = b
	d[i] = b - a
	n -= 1
	i += 1
ma = sum(max_list)
mi = sum(min_list)
if ma < k:
	print('NO')
elif mi > k:
	print('NO')
elif sum(max_list) == k:
	print('YES')
	for i in max_list:
		print(i, end=' ')
elif mi == k:
	print('YES')
	for i in min_list:
		print(i, end=' ')
else:
	print('YES')
	s = sum(min_list)
	i = 0
	while s < k:
		min_list[i] += d[i]
		s += d[i]
		i += 1
	if s > k:
		min_list[i - 1] = min_list[i - 1] - s + k
	for j in min_list:
		print(j, end=' ')


(d, s) = map(int, input().split())
m1 = m2 = 0
a = []
ans = []
for y in range(d):
	(l, r) = map(int, input().split())
	m1 += l
	ans.append(l)
	m2 += r
	a.append([l, r])
if m1 <= s <= m2:
	print('YES')
	s -= m1
	for i in range(d):
		if s == 0:
			break
		u = a[i][1] - a[i][0]
		if u > s:
			ans[i] += s
			s = 0
		else:
			ans[i] += u
			s -= u
	for i in ans:
		print(i, end=' ')
else:
	print('NO')


from __future__ import print_function
import sys
(d, sum_time) = [int(x) for x in input().split()]
min_arr = []
max_arr = []
for i in range(d):
	(min_time, max_time) = [int(x) for x in input().split()]
	min_arr.append(min_time)
	max_arr.append(max_time)
if sum_time >= sum(min_arr) and sum_time <= sum(max_arr):
	print('YES')
	schedule = []
	for i in range(d):
		schedule.append(min_arr[i])
		sum_time -= min_arr[i]
	while sum_time > 0:
		for i in range(d):
			if not sum_time > 0:
				break
			if schedule[i] < max_arr[i]:
				schedule[i] += 1
				sum_time -= 1
	print(*schedule)
else:
	print('NO')


(d, sum_time) = map(int, input().split())
times = [tuple(map(int, input().split())) for _ in range(d)]
schedule = [t[0] for t in times]
need = sum_time - sum(schedule)
if need < 0:
	print('NO')
	exit()
for i in range(len(schedule)):
	study = min(need, times[i][1] - schedule[i])
	schedule[i] += study
	need -= study
if need > 0:
	print('NO')
	exit()
print('YES')
print(' '.join((str(a) for a in schedule)))


(days, total) = [int(i) for i in input().split(' ')]
hours_per_day = []
difference = []
minSum = maxSum = 0
for day in range(days):
	(min, max) = [int(i) for i in input().split(' ')]
	hours_per_day.append(min)
	difference.append(max - min)
	minSum += min
	maxSum += max
if total < minSum or total > maxSum:
	print('NO')
else:
	print('YES')
	i = 0
	while total != minSum:
		if difference[i] <= total - minSum:
			minSum += difference[i]
			hours_per_day[i] += difference[i]
			i += 1
		else:
			hours_per_day[i] += total - minSum
			break
	print(*hours_per_day)


RESULT = 'NO'
hours_day = dict()
(count_days, sum_time) = input().split(' ')
count_days = int(count_days)
sum_time = int(sum_time)
days = list()
mn_hours = 0
mx_hours = 0
for i in range(count_days):
	(min_time, max_time) = input().split(' ')
	min_time = int(min_time)
	max_time = int(max_time)
	mn_hours += min_time
	mx_hours += max_time
	tm = [min_time] + [1 for _ in range(1, max_time - min_time + 1)]
	days.append(tm)
	if sum(tm) == 0:
		hours_day[i] = 0
full = False
if mn_hours <= sum_time <= mx_hours:
	RESULT = 'YES'
	idx = 0
	while sum(hours_day.values()) < sum_time:
		take_hours = days[idx].pop(0) if days[idx] else 0
		hours_day[idx] = hours_day.get(idx, 0) + take_hours
		if idx == count_days - 1:
			idx = 0
			full = True
		else:
			idx += 1
	if not full:
		for n in range(idx, count_days):
			hours_day[idx] = 0
print(RESULT)
if hours_day and RESULT == 'YES':
	resp = ' '.join((str(hours_day[k]) for k in sorted(hours_day, key=lambda x: x)))
	print(resp)


s1 = input()
b = s1.strip().split()
d = int(b[0])
sumTime = int(b[1])
minTime = []
maxTime = []
delta = []
Shed = []
bufTime = 0
maxDelta = 0
for i in range(d):
	s1 = input()
	b = s1.strip().split()
	b1 = int(b[0])
	b2 = int(b[1])
	bufTime += b1
	minTime.append(b1)
	Shed.append(b1)
	maxDelta += b2 - b1
	maxTime.append(b2)
	if bufTime > sumTime:
		print('NO')
		exit()
if sumTime == bufTime:
	print('YES')
	print(' '.join([str(item) for item in Shed]))
	exit()
desired_delta = sumTime - bufTime
if desired_delta > maxDelta:
	print('NO')
	exit()
else:
	for i in range(0, d):
		ddd = maxTime[i] - minTime[i]
		if ddd == desired_delta:
			Shed[i] = maxTime[i]
			break
		elif ddd < desired_delta:
			Shed[i] = maxTime[i]
			desired_delta -= ddd
		else:
			Shed[i] += desired_delta
			break
	print('YES')
	print(' '.join([str(item) for item in Shed]))


(d, sumTime) = [int(i) for i in input().split()]
parent_times = []
time_spent = []
for _ in range(d):
	parent_times.append([int(i) for i in input().split()])
for pair in parent_times:
	sumTime -= pair[0]
	time_spent.append(pair[0])
if sumTime < 0:
	print('NO')
else:
	for (i, pair) in enumerate(parent_times):
		sumTime -= pair[1] - pair[0]
		time_spent[i] += pair[1] - pair[0]
		if sumTime <= 0:
			print('YES')
			time_spent[i] += sumTime
			output = ''
			for (idx, t) in enumerate(time_spent):
				output += str(t) + (' ' if idx != len(parent_times) - 1 else '\n')
			print(output)
			break
		elif i == len(parent_times) - 1:
			print('NO')


(n, time) = map(int, input().split())
arr1 = []
arr2 = []
for i in range(0, n):
	(v1, v2) = map(int, input().split())
	arr1.append(v1)
	arr2.append(v2)
res = []
temp = 0
for i in range(0, n):
	res.append(arr1[i])
	temp += arr2[i] - arr1[i]
	time -= arr1[i]
	if time < 0:
		break
if time < 0:
	print('NO')
elif time == 0:
	print('YES')
	print(' '.join(map(str, res)))
elif time > temp:
	print('NO')
else:
	for i in range(0, n):
		if arr2[i] - arr1[i] < time:
			res[i] = arr2[i]
			time -= arr2[i] - arr1[i]
		else:
			res[i] = time + arr1[i]
			break
	print('YES')
	print(' '.join(map(str, res)))


(d, sumTime) = map(int, input().split())
sumMinTime = 0
sumMaxTime = 0
l = [0 for i in range(d)]
l_max = [0 for i in range(d)]
for i in range(d):
	(minTime, maxTime) = map(int, input().split())
	sumMinTime += minTime
	sumMaxTime += maxTime
	l[i] = minTime
	l_max[i] = maxTime
if sumTime < sumMinTime or sumTime > sumMaxTime:
	print('NO')
else:
	print('YES')
	ind = 0
	while sum(l) < sumTime:
		l[ind] += min(sumTime - sum(l), l_max[ind] - l[ind])
		ind += 1
	for item in l:
		print(item, end=' ')


(days, sumTime) = map(int, input().split())
min = []
max = []
for i in range(0, days):
	(o, p) = map(int, input().split())
	min.append(o)
	max.append(p)
maxTime = sum(max)
minTime = sum(min)
if minTime <= sumTime <= maxTime:
	print('YES')
	for i in range(0, days):
		if min[i] == 9 and max[i] == 9:
			print('Error')
		else:
			if min[i] + sumTime - minTime < max[i]:
				t = min[i] + sumTime - minTime
			else:
				t = max[i]
			print(t, end=' ')
			sumTime -= t - min[i]
else:
	print('NO')


import sys
(d, sum_time) = map(int, input().split())
days = [tuple(map(int, input().split())) for _ in range(d)]
mini = sum((x for (x, _) in days))
maxi = sum((x for (_, x) in days))
if sum_time < mini:
	print('NO')
	sys.exit(0)
sum_time -= mini
schedule = []
for i in range(d):
	(mini_, maxi_) = days[i]
	fill_in = min(sum_time, maxi_ - mini_)
	schedule.append(mini_ + fill_in)
	sum_time -= fill_in
if sum_time > 0:
	print('NO')
	sys.exit(0)
print('YES')
print(' '.join((str(x) for x in schedule)))


(n, m) = map(int, input().split())
p = 0
q = 0
lis = []
for i in range(n):
	(a, b) = map(int, input().split())
	lis.append([a, b])
	p = p + a
	q = q + b
if p <= m and q >= m:
	print('YES')
	k = m - p
	for i in range(n):
		if k != 0:
			if lis[i][1] - lis[i][0] < k:
				print(lis[i][1], end=' ')
				k = k - (lis[i][1] - lis[i][0])
			else:
				print(lis[i][0] + k, end=' ')
				k = 0
		else:
			print(lis[i][0], end=' ')
else:
	print('NO')


ch = input()
(n, m) = map(int, ch.split())
l = []
summin = 0
summax = 0
ch = ''
ch1 = ''
for i in range(n):
	ch = input()
	(n1, n2) = map(int, ch.split())
	l.append((n1, n2))
	summin = summin + n1
	summax = summax + n2
if m < summin or m > summax:
	print('NO')
else:
	print('YES')
	for i in range(n):
		summin = summin - l[i][0]
		summax = summax - l[i][1]
		j = l[i][0]
		while j <= l[i][1]:
			if m - j < summin or m - j > summax:
				j = j + 1
			else:
				m = m - j
				ch1 = ch1 + str(j) + ' '
				break
	l = len(ch1)
	ch1 = ch1[0:l - 1]
	print(ch1)


(d, st) = list(map(int, input().split()))
(mns, mxs) = (0, 0)
p = False
ds = []
for i in range(d):
	(mn, mx) = list(map(int, input().split()))
	ds.append([mn, mx])
	mns += mn
	mxs += mx
if st >= mns and st <= mxs:
	p = True
if not p:
	print('NO')
else:
	print('YES')
	st -= mns
	for i in ds:
		if st == 0:
			break
		ch = min(i[1] - i[0], st)
		i[0] += ch
		st -= ch
	for i in ds:
		print(i[0], end=' ')


import sys

def main():
	(days, hours) = map(int, sys.stdin.readline().strip().split())
	day_limits = [tuple(map(int, sys.stdin.readline().strip().split())) for _ in range(days)]
	sum_min_hours = sum((h[0] for h in day_limits))
	sum_max_hours = sum((h[1] for h in day_limits))
	if sum_min_hours <= hours <= sum_max_hours:
		sys.stdout.write('YES' + '\n')
		for limits in day_limits:
			sum_min_hours -= limits[0]
			sum_max_hours -= limits[1]
			study = limits[1] - max(0, sum_min_hours - (hours - limits[1]))
			sys.stdout.write(str(study) + ' ')
			hours -= study
		sys.stdout.write('\n')
	else:
		sys.stdout.write('NO' + '\n')
main()


(d, sum_time) = map(int, input().split())
ranges = [None for _ in range(d)]
max_possible = min_possible = 0
for i in range(d):
	ranges[i] = list(map(int, input().split()))
	max_possible += ranges[i][1]
	min_possible += ranges[i][0]
if sum_time < min_possible or sum_time > max_possible:
	print('NO')
else:
	print('YES')
	diff = max_possible - sum_time
	for (low, high) in ranges:
		if diff == 0:
			print(high, end=' ')
		elif diff < high - low:
			print(high - diff, end=' ')
			diff = 0
		else:
			print(low, end=' ')
			diff -= high - low


sticks = input().split()
day = int(sticks[0])
timetotle = int(sticks[1])
timemin = []
timemax = []
for i in range(day):
	sticks = input().split()
	timemin.append(int(sticks[0]))
	timemax.append(int(sticks[1]))
timemintotle = 0
timemaxtotle = 0
for i in timemin:
	timemintotle = timemintotle + i
for i in timemax:
	timemaxtotle = timemaxtotle + i
if timemaxtotle < timetotle or timemintotle > timetotle:
	print('NO')
	exit()
else:
	print('YES')
timeleft = timetotle - timemintotle
res = timemin.copy()
for i in range(day):
	if timeleft <= timemax[i] - timemin[i]:
		res[i] = res[i] + timeleft
		break
	else:
		res[i] = timemax[i]
		timeleft = timeleft - timemax[i] + timemin[i]
a = ''
for q in res:
	if a == '':
		a = str(q)
	else:
		a = a + ' ' + str(q)
print(a)


import sys
d = 0
sumTime = 0
days = []
minTime = 0
maxTime = 0
count = 0
for line in sys.stdin:
	if count == 0:
		d = int(line.split()[0])
		sumTime = int(line.split()[1])
		count += 1
	else:
		minTime = int(line.split()[0])
		maxTime = int(line.split()[1])
		days.append((minTime, maxTime))
		count += 1
		if d == len(days):
			break
minTotal = 0
maxTotal = 0
for item in days:
	minTime = item[0]
	maxTime = item[1]
	minTotal += minTime
	maxTotal += maxTime
if minTotal <= sumTime <= maxTotal:
	print('YES')
	output_days = []
	hoursLeft = sumTime
	for i in range(len(days)):
		minTime = days[i][0]
		output_days.append(minTime)
		hoursLeft -= minTime
	for i in range(len(days)):
		minTime = days[i][0]
		maxTime = days[i][1]
		gap = maxTime - minTime
		if gap > hoursLeft:
			output_days[i] += hoursLeft
			hoursLeft -= hoursLeft
		else:
			output_days[i] += gap
			hoursLeft -= gap
	for item in output_days:
		print(item)
else:
	print('NO')


(d, s) = input().split()
(d, s) = (int(d), int(s))
(a, b, n) = (0, 0, 0)
(minTime, maxTime) = ([] * d, [] * d)
ans = [] * d
for i in range(d):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	minTime.append(x)
	maxTime.append(y)
	a += x
	b += y
	n += x
	ans.append(x)
if s < a or s > b:
	print('NO')
else:
	print('YES')
	i = 0
	while n < s:
		ans[i] = min(maxTime[i], ans[i] + s - n)
		n += ans[i] - minTime[i]
		i += 1
	ans = [str(i) for i in ans]
	print(' '.join(ans))


(d, total) = [int(i) for i in input().split()]
minT = 0
maxT = 0
planL = []
planG = []
for i in range(d):
	(a, b) = [int(i) for i in input().split()]
	minT += a
	maxT += b
	planL.append(a)
	planG.append(b)
if minT <= total and maxT >= total:
	print('YES')
	extra = total - minT
	for i in range(d):
		if extra > 0:
			pos = planG[i] - planL[i]
			if pos > extra:
				planL[i] = planL[i] + extra
				extra = 0
			else:
				extra -= planG[i] - planL[i]
				planL[i] = planG[i]
		else:
			break
	print(' '.join([str(i) for i in planL]))
else:
	print('NO')


lines = []
max = 0
min = 0
sum = 0
flag = False
line = input()
a = int(line.split(' ')[0])
b = int(line.split(' ')[1])
min_list = [0] * a
max_list = [0] * a
day = a
sum = b
for i in range(day):
	line = input()
	a = int(line.split(' ')[0])
	min_list[i] = a
	b = int(line.split(' ')[1])
	max_list[i] = b
	min += a
	max += b
if sum <= max and sum >= min:
	print('YES')
	only_min = False
	tmp = min
	for i in range(day):
		if only_min:
			print(min_list[i], end=' ')
			continue
		if tmp + (max_list[i] - min_list[i]) >= sum:
			only_min = True
			print(sum - tmp + min_list[i], end=' ')
		else:
			tmp += max_list[i] - min_list[i]
			print(max_list[i], end=' ')
else:
	print('NO')


import sys
read = lambda : input()
readint = lambda : int(input())
readint_list = lambda : map(int, input().split())

def solve(mn, mx, total):
	lowerbound = sum(mn)
	upperbound = sum(mx)
	possible = lowerbound <= total <= upperbound
	if not possible:
		print('NO')
		return
	studied = []
	total -= lowerbound
	for (lo, hi) in zip(mn, mx):
		hrs = min(total, hi - lo)
		studied.append(lo + hrs)
		total -= hrs
	print('YES')
	print(*studied)

def main():
	(days, total) = readint_list()
	(mn, mx) = ([0] * days, [0] * days)
	for i in range(days):
		(mn[i], mx[i]) = readint_list()
	solve(mn, mx, total)
	return 0
sys.exit(main())


(n, d) = map(int, input().split())
a = []
b = []
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
if sum(a) <= d <= sum(b):
	print('YES')
	d -= sum(a)
	for i in range(n):
		m = min(d, b[i] - a[i])
		d = d - m
		print(a[i] + m, end=' ')
else:
	print('NO')


(d, total) = map(int, input().split())
minmlist = []
maxmlist = []
for i in range(d):
	(minm, maxm) = map(int, input().split())
	minmlist.append(minm)
	maxmlist.append(maxm)
x = sum(minmlist)
y = sum(maxmlist)
if total >= x and total <= y:
	print('YES')
	total = total - x
	i = 0
	while total != 0:
		z = min(maxmlist[i] - minmlist[i], total)
		minmlist[i] = minmlist[i] + z
		i = i + 1
		total = total - z
	for i in minmlist:
		print(i, end=' ')
else:
	print('NO')


import copy

def main():
	(days, spentHours) = map(int, input().split())
	minHours = [0] * days
	maxHours = [0] * days
	for i in range(days):
		(minHours[i], maxHours[i]) = map(int, input().split())
	if not (sum(minHours) <= spentHours and spentHours <= sum(maxHours)):
		print('NO')
		return
	else:
		spentDailyHours = copy.deepcopy(minHours)
		spentHours -= sum(minHours)
		print('YES')
		for i in range(days):
			if spentHours > 0:
				if spentHours > maxHours[i] - minHours[i]:
					spentDailyHours[i] = maxHours[i]
					spentHours -= maxHours[i] - minHours[i]
				else:
					spentDailyHours[i] += spentHours
					break
			else:
				break
		for time in spentDailyHours:
			print(time, end=' ')
main()


import sys
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial, pi, gcd

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

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

def input():
	return sys.stdin.readline().strip()
(n, total) = get_ints()
Arr = []
for i in range(n):
	(mini, maxi) = get_ints()
	Arr.append((mini, maxi))
minimum = 0
maximum = 0
for i in range(n):
	minimum += Arr[i][0]
	maximum += Arr[i][1]
if total < minimum or total > maximum:
	print('NO')
	exit()
ans = [Arr[i][0] for i in range(n)]
current = minimum
i = 0
while current < total:
	if ans[i % n] < Arr[i % n][1]:
		ans[i % n] += 1
		current += 1
	i += 1
print('YES')
print(*ans)


(d, sum) = input().split()
d = int(d)
sum = int(sum)
l = list()
for i in range(d):
	(min, max) = input().split()
	min = int(min)
	max = int(max)
	l.append((min, max))
max_sum = 0
min_sum = 0
for i in range(len(l)):
	max_sum += l[i][1]
	min_sum += l[i][0]
if max_sum < sum or min_sum > sum:
	print('NO')
else:
	dist = [0] * d
	for i in range(len(l)):
		dist[i] = l[i][0]
		sum -= dist[i]
	i = 0
	while sum != 0:
		if dist[i] + 1 <= l[i][1]:
			dist[i] += 1
			sum -= 1
		if i == d - 1 and sum != 0:
			i = 0
		else:
			i += 1
	print('YES')
	for i in range(d):
		(print(dist[i], end=' '),)


(d, t) = map(int, input().split())
a1 = []
a2 = []
for i in range(d):
	(b, c) = map(int, input().split())
	a1.append(b)
	a2.append(c)
su1 = sum(a1)
su2 = sum(a2)
if su1 > t or t > su2:
	print('NO')
else:
	t = t - su1
	i = 1
	print('YES')
	mi = min(a2[0] - a1[0], t)
	t -= mi
	a1[0] += mi
	while t > 0:
		mi = min(a2[i] - a1[i], t)
		t -= mi
		a1[i] += mi
		i += 1
	print(*a1)


(days, total) = list(map(int, input().split(' ')))
(times, minimum, maximum) = ([], 0, 0)
for day in range(days):
	(mini, maxi) = list(map(int, input().split(' ')))
	minimum += mini
	maximum += maxi
	times.append((mini, maxi))
if total < minimum or total > maximum:
	print('NO')
else:
	print('YES')
	worked = [day[0] for day in times]
	running = minimum
	i = 0
	while running < total:
		dif = total - running
		worked[i] = times[i][1] if times[i][1] - times[i][0] < dif else worked[i] + dif
		running += times[i][1] - times[i][0]
		i += 1
	print(' '.join(list(map(str, worked))))


import random
m = []
(d, sumTime) = map(int, input().split())
for i in range(d):
	(minTime, maxTime) = map(int, input().split())
	row = []
	row.extend([minTime, maxTime])
	m.append(row)
summation = 0
summation_min = 0
for i in range(d):
	summation = summation + m[i][1]
	summation_min += m[i][0]
if d == 1:
	if sumTime in range(minTime, minTime + (maxTime - minTime + 1)):
		print('YES')
		print(sumTime)
	else:
		print('NO')
elif summation >= sumTime and summation_min <= sumTime:
	hrs = []
	for i in range(len(m)):
		hrs.append(m[i][0])
	remainder = sumTime - sum(hrs)
	if remainder == 0:
		print('YES')
		for i in hrs:
			print(i)
	if remainder < 0:
		new_remainder = sum(hrs) - sumTime
		j = 0
		while new_remainder > 0:
			if hrs[j] + 1 in range(m[j][0], m[j][1] + 1):
				hrs[j] = hrs[j] + 1
				new_remainder = new_remainder - 1
			else:
				j = j + 1
		print('YES')
		for i in hrs:
			print(i, end=' ')
	if remainder > 0:
		j = 0
		while remainder > 0:
			if hrs[j] + 1 in range(m[j][0], m[j][1] + 1):
				hrs[j] = hrs[j] + 1
				remainder = remainder - 1
			else:
				j = j + 1
		print('YES')
		for i in hrs:
			print(i, end=' ')
else:
	print('NO')


(d, H) = map(int, input().split())
mnmx = []
mxi = 0
mni = 0
h = [0] * d
for i in range(d):
	(mn, mx) = map(int, input().split())
	mnmx.append((mn, mx))
	mxi += mx
	mni += mn
	h[i] = mn
if mxi < H or mni > H:
	print('NO')
else:
	H -= mni
	for i in range(d):
		new_val = mnmx[i][1] - mnmx[i][0]
		if H - new_val <= 0:
			h[i] = H + mnmx[i][0]
			print('YES')
			print(*h)
			exit()
		h[i] = mnmx[i][1]
		H -= new_val


(d, sumTime) = list(map(int, input().rstrip().split()))
maxTime = []
minTime = []
maxHour = 0
minHour = 0
for _ in range(d):
	x = list(map(int, input().rstrip().split()))
	minTime += [x[0]]
	maxTime += [x[1]]
	maxHour += x[1]
	minHour += x[0]
if sumTime <= maxHour and sumTime >= minHour:
	print('YES')
	diff = sumTime - minHour
	for i in range(d):
		if diff == 0:
			show = minTime[i]
		elif diff > 0:
			show = min(maxTime[i], minTime[i] + diff)
			diff = diff - (show - minTime[i])
		print(show, end=' ')
else:
	print('NO')


(d, sumTime) = map(int, input().split())
minTime = [0] * d
maxTime = [0] * d
for i in range(d):
	(minTime[i], maxTime[i]) = map(int, input().split())
if sum(minTime) > sumTime or sum(maxTime) < sumTime:
	print('NO')
else:
	print('YES')
	sumTime -= sum(minTime)
	for i in range(d):
		if sumTime >= maxTime[i] - minTime[i]:
			sumTime -= maxTime[i] - minTime[i]
			print(maxTime[i], end=' ')
		else:
			print(sumTime + minTime[i], end=' ')
			sumTime = 0


(d, s) = map(int, input().split())
T = []
(minDT, maxDT) = (0, 0)
for _ in range(d):
	(minT, maxT) = map(int, input().split())
	minDT += minT
	maxDT += maxT
	T.append((minT, maxT))
if s < minDT or s > maxDT:
	print('NO')
else:
	S = [t[0] for t in T]
	bonus = s - minDT
	for i in range(d):
		while bonus > 0 and S[i] < T[i][1]:
			S[i] += 1
			bonus -= 1
	print('YES')
	print(*S, end=' ')
	print()


(n, m) = [int(x) for x in input().split()]
mini = []
maxi = []
for i in range(n):
	(s, l) = [int(x) for x in input().split()]
	mini.append(s)
	maxi.append(l)
if sum(mini) <= m and sum(maxi) >= m:
	print('YES')
	p = sum(mini)
	for i in range(n):
		a = min(mini[i] + m - p, maxi[i])
		if i != n - 1:
			print(a, end=' ')
		else:
			print(a)
		m -= a - mini[i]
else:
	print('NO')


(d, s) = map(int, input().split())
lst = []
tab = []
for i in range(d):
	tmp = list(map(int, input().split()[:2]))
	lst.append(tmp)
	tab.append(tmp[0])
if s < sum(tab):
	print('NO')
else:
	check = False
	for i in range(d - 1, -1, -1):
		z = sum(tab)
		e = s - z
		if lst[i][1] - lst[i][0] >= e:
			tab[i] = lst[i][0] + e
			check = True
			break
		else:
			tab[i] = lst[i][1]
	if check:
		print('YES')
		print(*tab)
	else:
		print('NO')


arr = [int(x) for x in input().split()]
_min = []
_max = []
rasp = []
for i in range(arr[0]):
	s = [int(x) for x in input().split()]
	_min.append(s[0])
	_max.append(s[1])

def beforeExam():
	for x in range(len(_min)):
		rasp.append(_min[x])
	if sum(rasp) == arr[1]:
		print('YES')
		print(' '.join(map(str, rasp)))
	else:
		need_hours = arr[1] - sum(rasp)
		for y in range(len(rasp)):
			exit_hours = _max[y] - _min[y]
			if exit_hours > need_hours and need_hours != 0:
				rasp[y] = rasp[y] + (exit_hours - need_hours)
				need_hours -= exit_hours - need_hours
			elif exit_hours < need_hours:
				rasp[y] = rasp[y] + exit_hours
				need_hours -= exit_hours
			elif exit_hours == need_hours:
				rasp[y] = rasp[y] + exit_hours
				need_hours -= exit_hours
		if sum(rasp) < arr[1]:
			print('NO')
		if sum(rasp) > arr[1]:
			print('NO')
		elif sum(rasp) == arr[1]:
			print('YES')
			print(' '.join(map(str, rasp)))
beforeExam()


import itertools
import time

def timer(f):

	def tmp(*args, **kwargs):
		t = time.time()
		res = f(*args, **kwargs)
		print('Время выполнения функции: %f' % (time.time() - t))
		return res
	return tmp
(d, summ) = map(int, input().split(' '))
array = [list(map(int, input().split(' '))) for i in range(d)]
mins = [i[0] for i in array]
maxs = [i[1] for i in array]
minSum = sum(mins)
maxSum = sum(maxs)
if minSum <= summ <= maxSum:
	print('YES')
	res = [i for i in mins]
	value = summ - minSum
	for i in range(value):
		for j in range(len(res)):
			if res[j] + 1 <= maxs[j]:
				res[j] += 1
				break
	if sum(res) == summ:
		print(res.__str__().replace('[', '').replace(']', '').replace(',', ''))
else:
	print('NO')


from sys import stdin, stdout, exit
(days, sum_time) = map(int, stdin.readline().strip().split())
minmaxes = []
for _ in range(days):
	(_min, _max) = stdin.readline().strip().split()
	minmaxes.append((int(_min), int(_max)))
(min_sum, max_sum) = (0, 0)
for (_min, _max) in minmaxes:
	min_sum += _min
	max_sum += _max
if not min_sum <= sum_time <= max_sum:
	print('NO')
	exit(0)
ls = []
for (_min, _max) in minmaxes:
	rem = sum_time - min_sum
	used_t = max(min(rem + _min, _max), 0)
	ls.append(used_t)
	sum_time -= used_t - _min
print('YES')
print(' '.join((str(l) for l in ls)))


(days, sumTime) = (int(x) for x in input().split())
limits = []
for _ in range(days):
	limits.append([int(x) for x in input().split()])
curSum = sum((x[0] for x in limits))
if curSum > sumTime:
	print('NO')
else:
	for i in range(days):
		if curSum < sumTime:
			sub = min(sumTime - curSum, limits[i][1] - limits[i][0])
			limits[i][0] += sub
			curSum += sub
		if curSum == sumTime:
			break
	if curSum < sumTime:
		print('NO')
	if curSum == sumTime:
		print('YES')
		print(' '.join((str(x[0]) for x in limits)))


(d, sumTime) = input().split()
d = int(d)
sumTime = int(sumTime)
if 1 <= d <= 30 and 0 <= sumTime <= 240:
	sumTime = int(sumTime)
	maxTime = []
	minTime = []
	for i in range(0, d):
		(lowtime, hightime) = input().split()
		maxTime.append(int(hightime))
		minTime.append(int(lowtime))
	if sum(minTime) <= sumTime <= sum(maxTime):
		print('YES')
		left = sumTime - sum(minTime)
		prtList = []
		for i in range(0, d):
			while sum(minTime) < sumTime:
				if minTime[i] < maxTime[i] and minTime[i] < 8:
					minTime[i] = minTime[i] + 1
				else:
					break
		prtList = minTime
		for i in prtList:
			(print(i, end=' '),)
	else:
		print('NO')
else:
	print('NO')


list = []
(d, sumtime) = map(int, input().split())
for i in range(d):
	(mintime, maxtime) = map(int, input().split())
	list.append([mintime, maxtime])
summin = 0
summax = 0
for i in range(d):
	summin = summin + list[i][0]
for i in range(d):
	summax = summax + list[i][1]
if summin <= sumtime <= summax:
	print('YES')
	for i in range(d):
		T = min(list[i][0] + sumtime - summin, list[i][1])
		if i + 1 < d:
			print(T)
		else:
			print(str(T) + '\n')
		sumtime = sumtime - (T - list[i][0])
else:
	print('NO')


[d, sumtime] = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for i in range(d)]
sum_max = 0
sum_min = 0
for i in range(d):
	sum_max += a[i][1]
	sum_min += a[i][0]
if sumtime > sum_max or sumtime < sum_min:
	print('NO')
else:
	print('YES')
	l = []
	if sumtime - sum_min <= sum_max - sumtime:
		k = sumtime - sum_min
		for i in range(0, d):
			if a[i][1] - a[i][0] <= k:
				l.append(a[i][1])
				k -= a[i][1] - a[i][0]
			elif 0 < k < a[i][1] - a[i][0]:
				l.append(a[i][0] + k)
				k = 0
			elif k == 0:
				l.append(a[i][0])
	else:
		k = sum_max - sumtime
		for i in range(0, d):
			if k >= a[i][1] - a[i][0]:
				l.append(a[i][0])
				k -= a[i][1] - a[i][0]
			elif 0 < k < a[i][1] - a[i][0]:
				l.append(a[i][1] - k)
				k = 0
			elif k == 0:
				l.append(a[i][1])
	print(*l)


import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
mod = 1000000007
ch = 'abcdefghijklmnopqrstuvwxyz'
lcm = lambda a, b: a * b // gcd(a, b)
setbit = lambda x: bin(x)[2:].count('1')
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace('\n', '')
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())

def solve():
	(n, tot) = NUMS(int)
	inp = []
	ok = [False] * n
	ans = [None] * n
	for _ in range(n):
		(a, b) = NUMS(int)
		inp.append([a, b])
	for i in range(len(inp)):
		if tot < inp[i][0]:
			ok[i] = False
		else:
			ok[i] = True
	if ok.count(True) == n:
		for i in range(len(inp)):
			ans[i] = inp[i][0]
		s = sum(ans)
		need = tot - s
		for i in range(n):
			while ans[i] < inp[i][1] and need:
				ans[i] += 1
				need -= 1
				s += 1
		if s == tot:
			print('YES')
			print(*ans)
		else:
			print('NO')
	else:
		print('NO')
solve()


def main():
	(days, hours) = input().split()
	hours = int(hours)
	days = int(days)
	arr = []
	smi = 0
	sma = 0
	sch = []
	summ = 0
	for _ in range(days):
		(mi, ma) = input().split()
		mi = int(mi)
		ma = int(ma)
		smi += mi
		sma += ma
		sch.append(mi)
		summ += mi
		arr.append((mi, ma))
	if sma < hours:
		print('NO')
		return
	if smi > hours:
		print('NO')
		return
	for i in range(days):
		d = hours - summ
		if d <= 0:
			break
		if arr[i][0] + d <= arr[i][1]:
			sch[i] += d
			summ += d
		elif d >= arr[i][0]:
			summ -= sch[i]
			sch[i] = arr[i][1]
			summ += arr[i][1]
	if hours == summ:
		print('YES')
		print(*sch, sep=' ')
main()


(d, summ) = map(int, input().split())
periods = []
(mintime, maxtime) = ([], [])
for i in range(d):
	(mi, mx) = map(int, input().split())
	mintime.append(mi)
	maxtime.append(mx)
min_sum = sum(mintime)
max_sum = sum(maxtime)
if min_sum > summ or summ > max_sum:
	print('NO')
else:
	res = mintime[:]
	for i in range(d):
		if sum(res) == sum:
			break
		elif res[i] == maxtime[i]:
			i += 1
		else:
			while res[i] != maxtime[i]:
				if sum(res) == summ:
					break
				res[i] += 1
	print('YES')
	print(*res)


import sys
mem = {}

def go(t, mm):
	if (t, len(mm)) in mem:
		return mem[t, len(mm)]
	if t == 0 and len(mm) == 0:
		mem[t, len(mm)] = (True, [])
		return mem[t, len(mm)]
	if t < 0 or len(mm) == 0:
		mem[t, len(mm)] = (False, [])
		return mem[t, len(mm)]
	for x in range(mm[-1][0], mm[-1][1] + 1):
		(ok, r) = go(t - x, mm[:-1])
		if ok:
			mem[t, len(mm)] = (True, r + [x])
			return mem[t, len(mm)]
	mem[t, len(mm)] = (False, [])
	return mem[t, len(mm)]

def main():
	(d, t) = [int(i) for i in sys.stdin.readline().split()]
	mm = [[int(i) for i in sys.stdin.readline().split()] for i in range(d)]
	(ok, r) = go(t, mm)
	if ok:
		print('YES')
		print(' '.join((str(i) for i in r)))
	else:
		print('NO')
main()


ln = input().split(' ')
d = int(ln[0])
total = int(ln[1])
min = 0
max = 0
arr = []
for i in range(d):
	ln = input().split(' ')
	lo = int(ln[0])
	hi = int(ln[1])
	min += lo
	max += hi
	arr.append((lo, hi))
if total < min or total > max:
	print('NO')
elif total == min:
	print('YES')
	for i in arr:
		print(i[0], end=' ')
elif total == max:
	print('YES')
	for i in arr:
		print(i[1], end=' ')
else:
	fin = []
	print('YES')
	for i in range(len(arr)):
		tup = arr[i]
		avg = sum(tup) // 2
		fin.append(avg)
		total -= avg
	i = 0
	while total != 0:
		ind = i % len(fin)
		picked = fin[ind]
		if total > 0:
			if picked + 1 <= arr[ind][1]:
				total -= 1
				fin[ind] += 1
		if total < 0:
			if picked - 1 >= arr[ind][0]:
				total += 1
				fin[ind] -= 1
		i += 1
	for i in fin:
		print(i, end=' ')


(d, sumTime) = input().split(' ')
d = int(d)
sumTime = int(sumTime)
sim = 0
Lmin = []
minimum = 0
maximum = 0
Lmax = []
for i in range(d):
	(minTime, maxTime) = input().split(' ')
	minTime = int(minTime)
	maxTime = int(maxTime)
	minimum += minTime
	maximum += maxTime
	Lmin.append(minTime)
	Lmax.append(maxTime)
diff = abs(sumTime - minimum)
if minimum <= sumTime <= maximum:
	print('YES')
	n = 0
	while True:
		while True:
			if diff == 0 or Lmin[n] == Lmax[n]:
				break
			Lmin[n] += 1
			diff -= 1
		n += 1
		if diff == 0 or n == len(Lmin):
			break
	for x in Lmin:
		print(x, end=' ')
else:
	print('NO')


(d, h) = map(int, input().split())
(upper, lower) = ([], [])
for i in range(d):
	(a, b) = input().split()
	lower.append(int(a))
	upper.append(int(b))
totalmin = sum(lower)
totalmax = sum(upper)
if h < totalmin or h > totalmax:
	print('NO')
else:
	print('YES')
	plan = []
	for i in range(d):
		if totalmax - upper[i] + lower[i] > h:
			totalmax -= upper[i] - lower[i]
			plan.append(lower[i])
		else:
			plan.append(-totalmax + upper[i] + h)
			break
	upper[:len(plan)] = plan
	print(' '.join((str(i) for i in upper)))


(d, sumtime) = map(int, input().split(' '))
mins = [None] * d
maxs = [None] * d
for i in range(d):
	(mins[i], maxs[i]) = map(int, input().split(' '))

def sum(list):
	sum = 0
	for x in list:
		sum += x
	return sum
summim = sum(mins)
summax = sum(maxs)
if sumtime <= summax and sumtime >= summim:
	print('YES')
	diff = summax - sumtime
	suml = 0
	for i in range(d):
		if diff != 0:
			if diff - maxs[i] + 1 < 0:
				print(abs(maxs[i] - diff), end=' ')
				suml += abs(maxs[i] - diff)
				diff -= maxs[i] - abs(diff - maxs[i])
			elif diff - mins[i] < 0:
				print(abs(mins[i] - diff), end=' ')
				suml += abs(mins[i] - diff)
				diff -= diff[i] - abs(diff - mins[i])
			else:
				print(mins[i], end=' ')
				suml += mins[i]
				diff -= maxs[i] - mins[i]
		else:
			print(maxs[i], end=' ')
			suml += maxs[i]
else:
	print('NO')


(d, s) = map(int, input().split())
(a, b) = ([], [])
for i in range(d):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
if sum(a) > s or s > sum(b):
	print('NO')
	exit(0)
s -= sum(a)
for i in range(d):
	c = min(s, b[i] - a[i])
	a[i] = str(a[i] + c)
	s -= c
print('YES')
print(' '.join(a))


(d, sumTime) = map(int, input().split())
days = [list(map(int, input().split())) for i in range(d)]
table = [0] * d
ans = None
if sum((i[1] for i in days)) >= sumTime >= sum((i[0] for i in days)):
	ans = 'YES'
if ans:
	for i in range(d):
		table[i] += days[i][0]
		sumTime -= days[i][0]
i = 0
if ans:
	while sumTime and i <= d - 1:
		diff = days[i][1] - table[i]
		if diff > sumTime:
			table[i] += sumTime
			sumTime = 0
		else:
			table[i] += diff
			sumTime -= diff
		i += 1
if ans:
	print(ans)
	print(*table)
else:
	print('NO')


(n, s) = map(int, input().split())
minl = []
maxl = []
(x, y) = (0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	minl.append(a)
	maxl.append(b)
	x += a
	y += b
if s < x or s > y:
	print('NO')
else:
	print('YES')
	d = list(maxl)
	t = abs(s - y)
	i = 0
	while t > 0 and i < n:
		d[i] -= min(t, maxl[i] - minl[i])
		t -= min(t, maxl[i] - minl[i])
		i -= 1
	print(*d)


X = list(map(int, input().split()))
Days = [list(map(int, input().split())) for i in range(X[0])]
SumMin = sum((i[0] for i in Days))
SumMax = sum((i[1] for i in Days))
if X[1] not in range(SumMin, SumMax + 1):
	print('NO')
else:
	print('YES')
	for i in range(X[0]):
		Temp = min(X[1] - SumMin, Days[i][1] - Days[i][0])
		print(Days[i][0] + Temp, end=' ')
		X[1] -= Temp


a = list(map(int, input().split()))
n = a[0]
b = [[0 for i in range(2)] for j in range(n)]
sum_total = a[1]
for i in range(n):
	b[i] = list(map(int, input().split()))
sum1 = 0
sum2 = 0
for i in range(n):
	sum1 += b[i][0]
	sum2 += b[i][1]
temp = []
str = ''
if sum_total > sum2 or sum_total < sum1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		sum1 -= b[i][0]
		if sum_total - b[i][1] >= sum1 and sum_total >= b[i][1]:
			str += f'{b[i][1]}'
			str += ' '
			sum_total -= b[i][1]
		elif sum_total >= sum1:
			str += f'{sum_total - sum1}'
			str += ' '
			sum_total -= sum_total - sum1
		else:
			str += f'{b[i][0]}'
			str += ' '
			sum_total -= b[i][0]
	print(str[:-1])


(d, s) = list(map(int, input().split(' ')))
a = []
b = []
for i in range(d):
	(x, y) = list(map(int, input().split(' ')))
	a.append(x)
	b.append(y)
m = sum(a)
n = sum(b)
if s >= m and s <= n:
	s -= m
	schedule = ''
	for i in range(d):
		if s == 0:
			schedule += str(a[i]) + ' '
		elif s > b[i] - a[i]:
			schedule += str(b[i]) + ' '
			s -= b[i] - a[i]
		elif s <= b[i] - a[i]:
			schedule += str(s + a[i]) + ' '
			s = 0
	print('YES')
	print(schedule.strip())
else:
	print('NO')


(days, total) = map(int, input().split())
mat = []
ma = 0
mi = 0
for i in range(days):
	arr = list(map(int, input().split()))
	ma += max(arr)
	mi += min(arr)
	mat.append(arr)
if mi <= total and total <= ma:
	print('YES')
	f = []
	for i in range(days):
		y = mat[i][0] + total - mi
		t = min(y, mat[i][1])
		total = total - (t - mat[i][0])
		f.append(t)
	print(*f)
else:
	print('NO')


(d, s) = map(int, input().split())
l = [[*map(int, input().split())] for _ in ' ' * d]
if sum((i[0] for i in l)) > s or sum((i[1] for i in l)) < s:
	print('NO')
else:
	t = s - sum((i[0] for i in l))
	a = []
	for i in range(d):
		if t >= l[i][1] - l[i][0]:
			a.append(str(l[i][1]))
			t -= l[i][1] - l[i][0]
		else:
			a.append(str(l[i][0] + t))
			t = 0
	print('YES')
	print(' '.join(a))


(d, s) = map(int, input().split())
a = []
m = []
for i in range(d):
	(x, y) = map(int, input().split())
	a.append(x)
	m.append(y)
	s -= x
if s == 0:
	print('YES')
	print(*a)
elif s < 0:
	print('NO')
else:
	for i in range(d):
		if s < m[i]:
			a[i] += s
			s = 0
			if a[i] > m[i]:
				s += a[i] - m[i]
				a[i] = m[i]
		else:
			s = s + a[i] - m[i]
			a[i] = m[i]
	if s == 0:
		print('YES')
		print(*a)
	else:
		print('NO')


(d, summ) = map(int, input().split())
minT = maxT = 0
(a, b, diff) = ([0] * d, [0] * d, [0] * d)
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
	minT += a[i]
	maxT += b[i]
	diff[i] = b[i] - a[i]
if summ > maxT or summ < minT:
	print('NO')
else:
	print('YES')
	for i in range(d):
		today = a[i]
		if summ - minT > 0:
			today += min(diff[i], summ - minT)
		summ -= today
		minT -= a[i]
		maxT -= b[i]
		print(today, end=' ')
	print()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))
hash_map = {}

def helper(i, s, p=[]):
	if i == len(arr) and s == 0:
		return (True, p)
	if i == len(arr):
		return (False, p)
	if (i, s) in hash_map and (not hash_map[i, s]):
		return (False, p)
	for ind in range(arr[i][0], arr[i][1] + 1):
		if ind > s:
			break
		(res, t) = helper(i + 1, s - ind, p + [ind])
		if res:
			return (True, t)
	hash_map[i, s] = False
	return (False, p)

def solve(s):
	(res, res_a) = helper(0, s)
	if not res:
		print('NO')
	else:
		print('YES')
		print(' '.join(map(str, res_a)))
ds = inlt()
arr = []
for i in range(ds[0]):
	arr.append(inlt())
solve(ds[1])


import math
(d, sumTime) = map(int, input().split())
minT = []
maxT = []
for i in range(0, d):
	(mi, ma) = map(int, input().split())
	minT.append(mi)
	maxT.append(ma)
summin = sum(minT)
summax = sum(maxT)
if summin <= sumTime and sumTime <= summax:
	print('YES')
	ans = []
	for i in range(0, d):
		ans.append(minT[i])
	if sumTime >= sum(ans):
		diff = sumTime - sum(ans)
		for i in range(0, d):
			diff_ava = maxT[i] - minT[i]
			if diff <= diff_ava:
				ans[i] += diff
				diff -= diff
			else:
				ans[i] += diff_ava
				diff = diff - diff_ava
			if diff == 0:
				break
	for i in range(0, len(ans)):
		print(ans[i], end=' ')
else:
	print('NO')


def BeforeAnExam():
	(numDays, sumTimes) = map(int, input().split(' '))
	minMaxTimes = [list(map(int, input().split(' '))) for i in range(numDays)]
	timetable = [minMaxTimes[i][0] for i in range(numDays - 1)]
	lastTerm = [sumTimes - sum(timetable)]
	timetable = timetable + lastTerm
	if timetable[-1] < minMaxTimes[-1][0]:
		print('NO')
	elif timetable[-1] <= minMaxTimes[-1][1]:
		print('YES')
		print(*timetable, sep=' ')
	else:
		diff = timetable[-1] - minMaxTimes[-1][1]
		a = [minMaxTimes[i][1] - timetable[i] for i in range(numDays - 1)]
		if sum(a) < diff:
			print('NO')
		else:
			for i in range(len(timetable)):
				diffi = minMaxTimes[i][1] - timetable[i]
				if timetable[-1] in range(minMaxTimes[-1][0], minMaxTimes[-1][1] + 1):
					print('YES')
					print(*timetable)
					break
				if diffi <= diff:
					timetable[-1] -= diffi
					timetable[i] = minMaxTimes[i][1]
				else:
					timetable[i] += diff
					timetable[-1] = minMaxTimes[-1][1]
					print('YES')
					print(*timetable, sep=' ')
					break
	return None

def main():
	BeforeAnExam()
main()


(d, s_t) = map(int, input().split())
a = [0] * d
b = [0] * d
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
sa = sum(a)
sb = sum(b)
r = s_t - sa
if sa <= s_t <= sb:
	for i in range(d):
		r2 = b[i] - a[i]
		a[i] += min(r2, r)
		r -= min(r2, r)
	print('YES')
	print(*a)
else:
	print('NO')


(d, total) = [int(x) for x in input().split()]
hours = []
days = []
minTotal = 0
maxTotal = 0
for i in range(d):
	(a, b) = [int(x) for x in input().split()]
	days.append(a)
	minTotal += a
	maxTotal += b
	hours.append([a, b])
if total >= minTotal and total <= maxTotal:
	print('YES')
	total -= minTotal
	for i in range(d):
		if total > 0 and days[i] < hours[i][1]:
			if total - hours[i][1] + hours[i][0] < 0:
				days[i] += total
				total = 0
			else:
				days[i] += hours[i][1] - hours[i][0]
				total -= hours[i][1] - hours[i][0]
	for x in days:
		print(x, end=' ')
else:
	print('NO')


(n, total) = [int(_) for _ in input().split()]
times = []
(mini, maxi) = (0, 0)
for _ in range(n):
	times.append([int(_) for _ in input().split()])
	mini += times[-1][0]
	maxi += times[-1][1]
if not mini <= total <= maxi:
	print('NO')
	exit()
idx = -1
val = 0
print('YES')
rt = total - mini
for i in range(n):
	if rt <= times[i][1] - times[i][0]:
		idx = i
		val = rt
		break
	rt -= times[i][1] - times[i][0]
ret = []
for i in range(n):
	if i < idx:
		ret.append(str(times[i][1]))
	if i == idx:
		ret.append(str(val + times[i][0]))
	if i > idx:
		ret.append(str(times[i][0]))
print(' '.join(ret))


(d, s) = map(int, input().split())
l = []
tw = []
one = []
k = 0
for i in range(d):
	(a, b) = map(int, input().split())
	y = [a, b]
	one.append(a)
	tw.append(b)
	k = k + b
	l.append(y)
if k < s:
	print('NO')
elif k == s:
	print('YES')
	print(*tw)
else:
	k = sum(one)
	for j in range(len(l)):
		r1 = l[j][0]
		r2 = l[j][1]
		lp = r2 - r1
		if k >= s:
			break
		elif k + lp > s:
			q = s - k
			k = k + q
			one[j] = one[j] + q
		elif k + lp <= s:
			k = k + lp
			one[j] = one[j] + lp
	if k == s:
		print('YES')
		print(*one)
	else:
		print('NO')


(days, s) = map(int, input().split())
ans = []
limits = []
for _ in range(days):
	limits.append(list(map(int, input().split())))
mis = 0
mas = 0
for (i, j) in limits:
	mis += i
	mas += j
	ans.append(i)
if s < mis or s > mas:
	print('NO')
else:
	print('YES')
	todo = s - mis
	curr = 0
	for (i, j) in limits:
		if todo > j - i:
			todo -= j - i
			ans[curr] = j
		else:
			ans[curr] += todo
			break
		curr += 1
	print(*ans)


L = [int(s) for s in input().split()]
(d, sumTime) = (L[0], L[1])
(min, max) = ([], [])
for i in range(d):
	Time = [int(s) for s in input().split()]
	min.append(Time[0])
	max.append(Time[1])
if sum(min) > sumTime or sum(max) < sumTime:
	print('NO')
else:
	print('YES')
	r = sum(max) - sumTime
	i = 0
	while r > 0:
		if r > max[i] - min[i]:
			print('%d' % min[i], end=' ')
			r -= max[i] - min[i]
		else:
			print('%d' % (max[i] - r), end=' ')
			r = 0
		i += 1
	for j in range(i, d):
		print('%d' % max[j], end=' ')


from collections import defaultdict
import sys
from typing import List, Union

def rl(int_: bool=True) -> Union[List[str], List[int]]:
	if int_:
		return [int(w) for w in sys.stdin.readline().split()]
	return [w for w in sys.stdin.readline().split()]
(d, sumTime) = rl()
days = []
(min_, max_) = (0, 0)
for _ in range(d):
	(s, e) = rl()
	min_ += s
	max_ += e
	days.append((s, e, min_, max_))
if min_ <= sumTime <= max_:
	print('YES')
	times = []
	for i in range(d - 1, -1, -1):
		if i == 0:
			times.append(sumTime)
			break
		if sumTime > days[i - 1][3] and sumTime - days[i - 1][3] >= days[i][0]:
			times.append(sumTime - days[i - 1][3])
			sumTime -= sumTime - days[i - 1][3]
		else:
			times.append(days[i][0])
			sumTime -= days[i][0]
	print(' '.join(map(str, times[::-1])))
else:
	print('NO')


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

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

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

def main():
	(d, s) = vars()
	arr = []
	for i in range(d):
		(x, y) = vars()
		arr.append((x, y))
	ans = []
	ns = 0
	for (x, y) in arr:
		ans.append(y)
		ns += y
	ns -= s
	if ns >= 0:
		for i in range(d):
			lower = arr[i][0]
			temp = min(ns, arr[i][1] - arr[i][0])
			ans[i] -= temp
			ns -= temp
		if ns:
			print('NO')
		else:
			print('YES')
			print(*ans)
	else:
		print('NO')
t = 1
for _ in range(t):
	main()


(d, sumTime) = map(int, input().split())
sm1 = 0
sm2 = 0
hi = []
lo = []
res = []
for n in range(d):
	(a, b) = map(int, input().split())
	lo.append(a)
	hi.append(b)
	res.append(a)
	sm1 += a
	sm2 += b
if sm1 > sumTime or sm2 < sumTime:
	print('NO')
	exit(0)
else:
	print('YES')
	rem = sumTime - sm1
	for n in range(d):
		sat = hi[n] - res[n]
		if sat < rem:
			print(hi[n], end=' ')
			rem -= sat
		elif sat >= rem and rem > 0:
			print(lo[n] + rem, end=' ')
			rem = 0
		elif rem == 0:
			print(lo[n], end=' ')


(n, d) = map(int, input().split())
(a, b) = ([0] * n, [0] * n)
suma = sumb = 0
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
	suma += a[i]
	sumb += b[i]
if suma <= d <= sumb:
	print('YES')
	d -= suma
	for i in range(n):
		m = min(d, b[i] - a[i])
		d -= m
		print(a[i] + m, end=' ')
else:
	print('NO')


(n, k) = map(int, input().split())
s = 0
c = 0
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
	s += l[i][1]
	c += l[i][0]
if s < k or c > k:
	print('NO')
else:
	d = []
	r = k - c
	for i in range(n):
		d.append(l[i][0] + min(l[i][1] - l[i][0], r))
		r -= min(l[i][1] - l[i][0], r)
	print('YES')
	print(*d)


(d, s) = map(int, input().split())
mn = []
mx = []
for i in range(d):
	(x, y) = map(int, input().split())
	mn.append(x)
	mx.append(y)
if sum(mn) <= s <= sum(mx):
	ans = mn.copy()
	k = s - sum(mn)
	i = 0
	while k != 0:
		x = min(mx[i] - mn[i], k)
		ans[i] += x
		i += 1
		k -= x
	print('YES')
	print(*ans)
else:
	print('NO')


(n, s) = map(int, input().split())
d = []
(sum1, sum2) = (0, 0)
for i in range(n):
	d.append(list(map(int, input().split())))
for (x, y) in d:
	sum1 += x
	sum2 += y
if s < sum1 or s > sum2:
	print('NO')
	exit()
ans = [0] * n
for i in range(n):
	ans[i] += d[i][0]
x = s - sum1
for i in range(n):
	if x > d[i][1]:
		ans[i] += d[i][1] - d[i][0]
		x -= d[i][1] - d[i][0]
	elif d[i][0] + x > d[i][1]:
		ans[i] += d[i][1] - d[i][0]
		x -= d[i][1] - d[i][0]
	else:
		ans[i] += x
		break
print('YES')
print(*ans)


(d, sumTime) = map(int, input().split())
minTime = []
maxTime = []
miniS = 0
maxS = 0
for i in range(0, d):
	(mt, mxt) = map(int, input().split())
	miniS += mt
	maxS += mxt
	minTime.append(mt)
	maxTime.append(mxt)
ans = 'YES'
if sumTime < miniS or sumTime > maxS:
	ans = 'NO'
	print('NO')
if ans == 'YES':
	ansarr = []
	difarr = []
	for i in range(0, d):
		ansarr.append(minTime[i])
		difarr.append(maxTime[i] - minTime[i])
	remT = sumTime - miniS
	while remT != 0:
		for i in range(0, d):
			if remT > difarr[i]:
				ansarr[i] += difarr[i]
				remT = remT - difarr[i]
				difarr[i] = 0
			else:
				ansarr[i] += remT
				difarr[i] -= remT
				remT = 0
				break
	print('YES')
	for i in range(0, d):
		print(ansarr[i], end=' ')


(d, su) = map(int, input().split())
a = []
b = []
for i in range(d):
	(l, m) = map(int, input().split())
	a.append(l)
	b.append(m)
if sum(a) <= su <= sum(b):
	m = sum(a)
	print('YES')
	k = 0
	for i in range(d):
		if su - b[i] > m - a[i]:
			print(b[i], end=' ')
			su -= b[i]
			m -= a[i]
			k += b[i]
		elif m == su:
			print(a[i], end=' ')
		else:
			print(a[i] + su - m, end=' ')
			su = m
else:
	print('NO')


(n, m) = map(int, input().split())
min_ = []
max_ = []
for i in range(n):
	(x, y) = map(int, input().split())
	min_.append(x)
	max_.append(y)
if sum(min_) > m or sum(max_) < m:
	print('NO')
	exit()
i = 0
while sum(min_) != m and i < n:
	while sum(min_) < m and min_[i] < max_[i]:
		min_[i] += 1
	i += 1
print('YES')
print(*min_)


(d, sumTime) = map(int, input().split())
sсhedule_min = [0] * d
sсhedule_max = [0] * d
for i in range(d):
	(sсhedule_min[i], sсhedule_max[i]) = map(int, input().split())
	sumTime -= sсhedule_min[i]
if sumTime == 0:
	print('YES')
	print(*sсhedule_min)
elif sumTime > 0:
	for i in range(d):
		if sсhedule_max[i] - sсhedule_min[i] >= sumTime:
			sсhedule_min[i] = sсhedule_min[i] + sumTime
			sumTime = 0
			print('YES')
			print(*sсhedule_min)
			break
		else:
			sumTime -= sсhedule_max[i] - sсhedule_min[i]
			sсhedule_min[i] += sсhedule_max[i] - sсhedule_min[i]
if sumTime != 0:
	print('NO')


(d, sum_time) = map(int, input().split())
s = []
t_max = 0
t_min = 0
for i in range(d):
	(min_time, max_time) = map(int, input().split())
	s.append([min_time, max_time])
	t_max = t_max + max_time
	t_min = t_min + min_time
if t_max < sum_time or sum_time < t_min:
	print('NO')
else:
	ss = []
	for i in range(len(s)):
		middle_time = (s[i][0] + s[i][1]) // 2
		ss.append(middle_time)
	import math
	razn = math.fabs(sum(ss) - sum_time)
	razn = int(razn)
	if sum(ss) == sum_time:
		print('YES')
		print(' '.join(map(str, ss)))
	elif sum(ss) < sum_time:
		c = 0
		for i in range(d):
			if c == razn:
				break
			else:
				while ss[i] < s[i][1]:
					ss[i] = ss[i] + 1
					c = c + 1
					if c == razn:
						break
					else:
						continue
		print('YES')
		print(' '.join(map(str, ss)))
	else:
		c = 0
		for i in range(d):
			if c == razn:
				break
			else:
				while ss[i] > s[i][0]:
					ss[i] = ss[i] - 1
					c = c + 1
					if c == razn:
						break
					else:
						continue
		print('YES')
		print(' '.join(map(str, ss)))


(d, t) = (int(x) for x in input().split())
s = []
for i in range(d):
	s.append(tuple((int(x) for x in input().split())))
a = sum((x[0] for x in s))
b = sum((x[1] for x in s))
if t >= a and t <= b:
	print('YES')
	z = t - a
	for x in s:
		d = min(z, x[1] - x[0])
		print(x[0] + d, end=' ')
		z -= d
	print()
else:
	print('NO')


(d, s) = map(int, input().split())
l = []
for i in range(d):
	l.append(list(map(int, input().split())))
mi = sum([x[0] for x in l])
ma = sum([x[1] for x in l])
if s < mi or s > ma:
	print('NO')
else:
	print('YES')
	cha = s - mi
	for i in range(d):
		if cha >= l[i][1] - l[i][0]:
			print(l[i][1], end=' ')
			cha -= l[i][1] - l[i][0]
		elif 0 < cha < l[i][1] - l[i][0]:
			print(l[i][0] + cha, end=' ')
			cha = 0
		else:
			print(l[i][0], end=' ')


(d, st) = map(int, input().split())
days = []
for _ in range(d):
	days.append([*map(int, input().split())])
for r in range(d):
	days[r][1] -= days[r][0]
	st -= days[r][0]
for r in range(d):
	if days[r][1] <= st > 0:
		days[r][0] += days[r][1]
		st -= days[r][1]
	elif st > 0:
		diff = days[r][1] - st
		days[r][0] += diff
		st = 0
if st == 0:
	print('YES')
	for r in range(d):
		print(days[r][0], end=' ')
else:
	print('NO')


(d, sumTime) = map(int, input().split())
minTime = []
maxTime = []
actualTime = []
for i in range(1, d + 1):
	(minTime_i, maxTime_i) = map(int, input().split())
	minTime.append(minTime_i)
	maxTime.append(maxTime_i)
if sumTime < sum(minTime) or sumTime > sum(maxTime):
	print('NO')
else:
	for i in range(0, d):
		actualTime.append(minTime[i])
		if sum(maxTime[i + 1:]) > sumTime - sum(actualTime):
			continue
		else:
			actualTime.pop()
			for j in range(minTime[i], maxTime[i] + 1):
				if sumTime - sum(actualTime) - j == sum(maxTime[i + 1:]):
					actualTime.append(j)
	print('YES')
	output = ''
	for time in actualTime:
		output += str(time) + ' '
	print(output)


(numDays, totalTime) = input().split()
numDays = int(numDays)
totalTime = int(totalTime)
minTotal = 0
maxTotal = 0
minTimes = []
maxTimes = []
results = []
for x in range(0, numDays):
	(minTime, maxTime) = input().split()
	minTime = int(minTime)
	maxTime = int(maxTime)
	minTotal += minTime
	maxTotal += maxTime
	minTimes.append(minTime)
	maxTimes.append(maxTime)
if minTotal <= totalTime and totalTime <= maxTotal:
	print('YES')
	for y in range(0, numDays):
		time = min(minTimes[y] + totalTime - minTotal, maxTimes[y])
		results.append(time)
		totalTime -= time - minTimes[y]
	for times in results:
		print(times)
else:
	print('NO')


(d, s) = map(int, input().split())
mint = []
delta = []
smin = 0
smax = 0
for _ in range(d):
	(minT, maxT) = map(int, input().split())
	mint.append(minT)
	delta.append(maxT - minT)
	smin += minT
	smax += maxT
if s < smin or s > smax:
	print('NO')
else:
	r = s - smin
	for i in range(d):
		if r <= delta[i]:
			mint[i] += r
			break
		else:
			mint[i] += delta[i]
			r -= delta[i]
	print('YES')
	print(' '.join(map(str, mint)))


(d, sumTime) = input().split()
d = int(d)
sumTime = int(sumTime)
minTime = []
maxTime = []
for day in range(d):
	(time1, time2) = input().split()
	minTime.append(int(time1))
	maxTime.append(int(time2))
if sum(minTime) > sumTime or sum(maxTime) < sumTime:
	print('NO')
else:
	print('YES')
	Time = []
	for day in range(d):
		Time.append(minTime[day])
		sumTime -= minTime[day]
	day = 0
	while sumTime > 0:
		if sumTime > maxTime[day] - minTime[day]:
			Time[day] += maxTime[day] - minTime[day]
			sumTime -= maxTime[day] - minTime[day]
			day += 1
		else:
			Time[day] += sumTime
			sumTime = 0
			day += 1
	solution = ''
	for day in range(d):
		solution = solution + str(Time[day]) + ' '
	solution = solution[0:len(solution) - 1]
	print(solution)


(d, maxtime) = map(int, input().split())
mini = []
maxi = []
for i in range(d):
	(start, end) = map(int, input().split())
	mini.append(start)
	maxi.append(end)
totaltime = sum(mini)
if totaltime == maxtime:
	print('YES')
	print(*mini)
elif totaltime > maxtime:
	print('NO')
else:
	maxtime -= totaltime
	i = 0
	while maxtime != 0 and i != d:
		diff = maxi[i] - mini[i]
		if maxtime - diff > 0:
			mini[i] = maxi[i]
			maxtime -= diff
		elif maxtime - diff <= 0:
			mini[i] += maxtime
			maxtime = 0
		i += 1
	if maxtime == 0:
		print('YES')
		print(*mini)
	else:
		print('NO')


t = input().split()
n = int(t[0])
sumTime = int(t[1])
tempMA = tempMI = 0
list = []
mi = []
ma = []
for i in range(n):
	t = input().split()
	tempMI += int(t[0])
	tempMA += int(t[1])
	mi.append(int(t[0]))
	ma.append(int(t[1]))
	list.append(int(t[0]))
if tempMI <= sumTime and sumTime <= tempMA:
	print('YES')
	if sumTime != tempMI:
		for i in range(n):
			temp = ma[i] - list[i]
			if temp + tempMI > sumTime:
				temp = sumTime - tempMI
			list[i] += temp
			tempMI += temp
			if sumTime == tempMI:
				break
	print(' '.join(map(str, list)))
else:
	print('NO')


(d, st) = map(int, input().split())
li = []
for i in range(d):
	li.append(list(map(int, input().split())))
maxst = 0
minst = 0
for i in li:
	maxst += i[1]
	minst += i[0]
if minst > st or st > maxst:
	print('NO')
else:
	print('YES')
	a = []
	st = st - minst
	for i in range(0, d):
		maxst = min(st, li[i][1] - li[i][0])
		a.append(str(li[i][0] + maxst))
		st -= maxst
	print(' '.join(a))


def fun(a, p, d, st):
	if sum(p) > st:
		return False
	else:
		st -= sum(p)
		for i in range(d):
			if st > a[i] - p[i]:
				st -= a[i] - p[i]
				p[i] = a[i]
			else:
				st -= a[i] - p[i]
				p[i] = a[i] + st
				return True
	return False
(d, st) = map(int, input().split())
a = []
p = []
for i in range(d):
	(mint, maxt) = map(int, input().split())
	a.append(maxt)
	p.append(mint)
if fun(a, p, d, st):
	print('YES')
	for i in p:
		print(i, end=' ')
else:
	print('NO')


(d, sumi) = list(map(int, input().split()))
a = []
sum1 = 0
sum2 = 0
dp = [0] * d
for i in range(d):
	(m, n) = list(map(int, input().split()))
	a.append((m, n))
	sum1 += m
	sum2 += n
if sum2 < sumi or sumi < sum1:
	print('NO')
	exit()
for i in range(d):
	dp[i] = a[i][0]
	sumi -= a[i][0]
while sumi > 0:
	for i in range(d):
		if dp[i] + 1 <= a[i][1] and sumi > 0:
			dp[i] = dp[i] + 1
			sumi -= 1
print('YES')
print(*dp)


import sys
a = [int(i) for i in input().split(' ')]
d = a[0]
sumTime = a[1]
min = 0
max = 0
found = False
solution = []
days = []
for i in range(d):
	day = [int(i) for i in input().split(' ')]
	min += day[0]
	max += day[1]
	days.append((day[0], day[1]))
	solution.append(day[0])
	if min > sumTime:
		found = True
		print('NO')
		break
if max < sumTime and (not found):
	print('NO')
if max >= sumTime and (not found):
	curr_sum = sum(solution)
	i = 0
	while curr_sum < sumTime:
		diff = days[i][1] - days[i][0]
		if sumTime - curr_sum >= diff:
			solution[i] += diff
			curr_sum += diff
		elif sumTime - curr_sum < diff:
			solution[i] += sumTime - curr_sum
			curr_sum += sumTime - curr_sum
		i += 1
	print('YES')
	toPrint = ''
	for i in solution:
		toPrint += str(i) + ' '
	print(toPrint)


(d, sum) = map(int, input().strip().split(' '))
x = [() for _ in range(d)]
ans = [None for _ in range(d)]
for i in range(d):
	(a, b) = map(int, input().strip().split(' '))
	x[i] = (a, b)
	ans[i] = a
for pair in x:
	sum -= pair[0]
	if sum < 0:
		print('NO')
		exit()
for i in range(d):
	(a, b) = (x[i][0], x[i][1])
	diff = b - a
	if diff <= sum:
		ans[i] = b
		sum -= diff
	else:
		ans[i] += sum
		sum -= diff
		break
if sum <= 0:
	print('YES')
	print(' '.join(map(str, ans)))
else:
	print('NO')


(d, sumtime) = [int(i) for i in input().split()]
summax = d * [0]
summin = d * [0]
for i in range(d):
	(summin[i], summax[i]) = [int(i) for i in input().split()]
if not sum(summin) <= sumtime <= sum(summax):
	print('NO')
else:
	print('YES')
	i = 0
	while i < d:
		summin[i] += min(sumtime - sum(summin), summax[i] - summin[i])
		i += 1
	for i in summin:
		print(i, end=' ')


from sys import stdin
(lend, sumtime, day) = (None, None, None)

def solve_aux(n, h, memo, prev):
	(ans, key) = (None, (n, h))
	if key in memo:
		ans = memo[key]
	else:
		if n == 0:
			ans = h == 0
			if ans:
				prev[key] = None
		elif h < day[n - 1][0]:
			ans = False
		else:
			(i, ub) = (day[n - 1][0], min(h, day[n - 1][1]) + 1)
			while ans != True and i != ub:
				ans = solve_aux(n - 1, h - i, memo, prev)
				if ans:
					prev[key] = (n - 1, i)
				i += 1
		memo[key] = ans
	return ans

def solve():
	(memo, prev) = (dict(), dict())
	(ans, witness) = (solve_aux(lend, sumtime, memo, prev), None)
	if ans:
		(witness, w, s) = ([None for _ in range(lend)], (lend, sumtime), sumtime)
		while prev[w] != None:
			witness[w[0] - 1] = prev[w][1]
			s -= prev[w][1]
			w = (w[0] - 1, s)
	return (ans, witness)

def main():
	global lend, sumtime, day
	(lend, sumtime) = map(int, stdin.readline().split())
	day = list()
	for _ in range(lend):
		tok = stdin.readline().split()
		day.append((int(tok[0]), int(tok[1])))
	(ans, wit) = solve()
	if ans:
		print('YES\n{0}'.format(' '.join((str(x) for x in wit))))
	else:
		print('NO')
main()


(d, sumTime) = map(int, input().split())
(minTime, maxTime) = ([], [])
for _ in range(d):
	(temp, var) = map(int, input().split())
	minTime.append(temp)
	maxTime.append(var)
totalmin = sum(minTime)
totalmax = sum(maxTime)
if sumTime < totalmin or sumTime > totalmax:
	print('NO')
else:
	print('YES')
	for i in range(d):
		for j in range(minTime[i], maxTime[i] + 1):
			sumTime = sumTime - j
			totalmin = totalmin - minTime[i]
			totalmax = totalmax - maxTime[i]
			if totalmin <= sumTime <= totalmax:
				print(j, end=' ')
				break
			else:
				sumTime = sumTime + j
				totalmin = totalmin + minTime[i]
				totalmax = totalmax + maxTime[i]


from sys import stdin, stdout
INF = 100000000000.0
import bisect

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

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

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

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
import math
(d, sumtime) = get_ints()
arr = []
ans = [0] * d
s = 0
for i in range(d):
	(a, b) = get_ints()
	arr.append((a, b))
	ans[i] = a
	s += a
sumtime -= s
for i in range(d):
	if sumtime < 0:
		break
	if sumtime >= arr[i][1]:
		ans[i] = arr[i][1]
		sumtime = sumtime - (arr[i][1] - arr[i][0])
	elif ans[i] + sumtime <= arr[i][1]:
		ans[i] += sumtime
		sumtime = 0
		break
if sumtime == 0:
	print('YES')
	for i in ans:
		print(i, end=' ')
	print()
else:
	print('NO')


(d, sumTime) = [int(i) for i in input().split()]
A = []
lower = 0
upper = 0
for i in range(d):
	tmp = [int(i) for i in input().split()]
	A.append(tmp)
	lower += tmp[0]
	upper += tmp[1]
if sumTime < lower or sumTime > upper:
	print('NO')
else:
	print('YES')
	ans = [a[0] for a in A]
	sumTime -= lower
	for i in range(d):
		if sumTime <= 0:
			break
		portion = A[i][1] - A[i][0]
		ans[i] += min(portion, sumTime)
		sumTime -= portion
	for i in ans:
		print(i, end=' ')


def compute(d, total_sum, max_sum, min_sum, arr):
	if min_sum <= total_sum <= max_sum:
		print('YES')
		cur_sum = 0
		for i in range(d):
			(cur_min, cur_max) = (arr[i][0], arr[i][1])
			(min_sum, max_sum) = (min_sum - cur_min, max_sum - cur_max)
			if min_sum <= total_sum - cur_max <= max_sum:
				print(cur_max, end=' ')
				total_sum -= cur_max
			elif min_sum <= total_sum - cur_min <= max_sum:
				print(cur_min, end=' ')
				total_sum -= cur_min
			else:
				for x in range(cur_min, cur_max + 1):
					if min_sum <= total_sum - x <= max_sum:
						print(x, end=' ')
						total_sum -= x
						break
	else:
		print('NO')
(d, total_sum) = map(int, input().split())
arr = []
(min_sum, max_sum) = (0, 0)
for _ in range(d):
	temp = list(map(int, input().split()))
	arr.append(temp)
	min_sum += temp[0]
	max_sum += temp[1]
compute(d, total_sum, max_sum, min_sum, arr)


I = lambda : map(int, input().split())
(d, s_t) = I()
a = []
b = []
for i in range(d):
	h = list(I())
	a.append(h[0])
	b.append(h[1])
sa = sum(a)
sb = sum(b)
r = s_t - sa
if sa <= s_t <= sb:
	for i in range(d):
		r2 = b[i] - a[i]
		a[i] += min(r2, r)
		r -= min(r2, r)
	print('YES')
	print(*a)
else:
	print('NO')


(d, sumtime) = map(int, input().split())
s = []
ans = []
ls = rs = 0
for _ in range(d):
	(l, r) = map(int, input().split())
	ls += l
	rs += r
	s.append(l)
	ans.append(r)
if sumtime > rs or sumtime < ls:
	exit(print('NO'))
print('YES')
i = 0
cs = rs
while cs > sumtime:
	if ans[i] == s[i]:
		i += 1
	else:
		ans[i] -= 1
		cs -= 1
print(*ans)


import collections
import math
import sys
lines = sys.stdin.readlines()
(d, sum_time) = [int(x) for x in lines[0].split()]
min_time = []
max_time = []
spent = []
for day in range(d):
	(mn, mx) = [int(x) for x in lines[day + 1].split()]
	min_time.append(mn)
	max_time.append(mx)
	spent.append(0)
for day in range(d):
	sum_time -= min_time[day]
	spent[day] = min_time[day]
if sum_time < 0:
	print('NO')
else:
	for day in range(d):
		take = min(max_time[day] - min_time[day], sum_time)
		sum_time -= take
		spent[day] += take
	if sum_time <= 0:
		print('YES')
		print(' '.join((str(s) for s in spent)))
	else:
		print('NO')


(d, sumtime) = map(int, input().split())
min_time = []
max_time = []
for i in range(d):
	(a, b) = map(int, input().split())
	min_time.append(a)
	max_time.append(b)
	sumtime -= a
day_time = min_time * 1
if sumtime < 0:
	print('NO')
else:
	for i in range(d):
		k = max_time[i] - min_time[i]
		if k > sumtime:
			day_time[i] += sumtime
			sumtime = 0
		else:
			sumtime -= k
			day_time[i] = max_time[i]
		if sumtime == 0:
			print('YES')
			for j in range(d):
				print(day_time[j], end=' ')
			break
	else:
		print('NO')


def solve(s, mini, maxi):
	flag = 0
	if sum(maxi) < s or sum(mini) > s:
		print('NO')
	else:
		while 1:
			if flag == 1:
				break
			for i in range(len(mini)):
				mem = mini[i]
				mini[i] = maxi[i]
				if sum(mini) == s:
					flag = 1
					print('YES')
					break
				elif sum(mini) > s:
					mini[i] = mem
					diff = s - sum(mini)
					mini[i] += diff
					flag = 1
					print('YES')
					break
		print(' '.join(map(str, mini)))
l = list(map(int, input().split()))
mini = []
maxi = []
for i in range(l[0]):
	(a, b) = map(int, input().split())
	mini.append(a)
	maxi.append(b)
solve(l[1], mini, maxi)


import sys

def get_tuple():
	inp = sys.stdin.readline()
	return tuple((int(x) for x in inp.split(' ')))
(d, S) = get_tuple()
mM = [get_tuple() for _ in range(d)]
(min_hours, max_hours) = zip(*mM)
(minimum, maximum) = (sum(min_hours), sum(max_hours))
if not minimum <= S <= maximum:
	print('NO')
else:
	hours = [0] * d
	remaining = S - minimum
	for (i, (m, M)) in enumerate(mM):
		value = min(M - m, remaining)
		remaining -= value
		hours[i] = m + value
	print('YES')
	print(' '.join((str(u) for u in hours)))


def solution():
	a = [int(x) for x in input().split()]
	d = a[0]
	sumtime = a[1]
	time = []
	i = 0
	(possible, final) = ([], [])
	while i < d:
		b = [int(x) for x in input().split()]
		possible.append(b[0])
		final.append(b[1])
		i += 1
	i = 0
	smalls = possible.copy()
	if sum(final) < sumtime or sum(possible) > sumtime:
		return 'NO'
	while i < len(possible):
		j = 0
		while sum(possible) < sumtime and j < len(possible):
			possible[j] = final[j]
			j += 1
		if sum(possible) == sumtime:
			break
		if sum(possible) > sumtime:
			targ = sum(possible) - sumtime
			l = 0
			finals = []
			while l < len(smalls):
				finals.append(final[l] - smalls[l])
				l += 1
			k = 0
			done = 0
			while k < len(finals):
				if finals[k] >= targ:
					possible[k] -= targ
					done = 1
					break
				k += 1
			if done:
				break
		i += 1
	c_out = ''
	for x in possible:
		c_out += str(x) + ' '
	print('YES')
	return c_out
print(solution())


(d, total) = map(int, input().split())
extra = 0
case = 1
res = []
maxi = []
mini = []
for i in range(d):
	(mn, mx) = map(int, input().split())
	maxi.append(mx)
	mini.append(mn)
	res.append(mn)
if sum(res) > total:
	print('NO')
else:
	extra = total - sum(res)
	i = 0
	while extra > 0 and i < d:
		if maxi[i] - mini[i] > extra:
			res[i] += extra
		else:
			res[i] += maxi[i] - mini[i]
		extra -= maxi[i] - mini[i]
		i += 1
	if extra > 0:
		print('NO')
	else:
		print('YES')
		print(*res)


def printing(count, string):
	for x in range(count):
		print(string)

def main():
	start = input().split(' ')
	for x in range(len(start)):
		start[x] = int(start[x])
	arr = []
	for holder in range(start[0]):
		string = input().split(' ')
		arr.append((int(string[0]), int(string[1])))
	minimum = 0
	maximum = 0
	for holder in arr:
		minimum += holder[0]
		maximum += holder[1]
	if minimum <= start[1] and maximum >= start[1]:
		print('YES')
		bank = start[1] - minimum
		string = ''
		count = 0
		while bank > 0:
			difference = arr[count][1] - arr[count][0]
			if bank >= difference:
				bank -= difference
				string += str(arr[count][1]) + ' '
			else:
				string += str(arr[count][0] + bank) + ' '
				bank = 0
			count += 1
		for x in range(count, len(arr)):
			string += str(arr[x][0]) + ' '
		print(string)
	else:
		print('NO')
main()


import sys
(d, sum_time) = map(int, sys.stdin.readline().split())
tn = []
(sum_min, sum_max) = (0, 0)
for i in range(0, d):
	(mmin, mmax) = map(int, sys.stdin.readline().split())
	tn.append((mmin, mmax))
	sum_min += mmin
	sum_max += mmax
if sum_time < sum_min or sum_time > sum_max:
	print('NO')
else:
	print('YES')
	index = 0
	ans = []
	while index < d and sum_time > sum_min:
		sum_min -= tn[index][0]
		sum_max -= tn[index][1]
		if sum_min < sum_time - tn[index][1]:
			sum_time -= tn[index][1]
			ans.append(tn[index][1])
		else:
			ans.append(sum_time - sum_min)
			sum_time = sum_min
		index += 1
	for i in range(index, d):
		ans.append(tn[i][0])
	print(' '.join(map(str, ans)))


from sys import stdin
l1 = stdin.readline().strip().split()
days = int(l1[0])
sum_time = int(l1[1])
max_times = [None] * days
min_times = [None] * days
max_sum = 0
min_sum = 0
for i in range(days):
	times = stdin.readline().strip().split()
	max_sum += int(times[1])
	min_sum += int(times[0])
	min_times[i] = int(times[0])
	max_times[i] = int(times[1])
if max_sum < sum_time or min_sum > sum_time:
	print('NO')
else:
	print('YES')
	need = sum_time - min_sum
	for i in range(days):
		if need == 0:
			print(min_times[i], end=' ')
		elif need > max_times[i] - min_times[i]:
			print(max_times[i], end=' ')
			need -= max_times[i] - min_times[i]
		else:
			print(min_times[i] + need, end=' ')
			need = 0


(days, hours) = map(int, input().split())
min_hours = []
max_hours = []
rem_hours = []
for i in range(days):
	(mi, ma) = map(int, input().split())
	min_hours.append(mi)
	max_hours.append(ma)
	rem_hours.append((ma - mi, i))
total_min = sum(min_hours)
total_max = sum(max_hours)
if not total_min <= hours <= total_max:
	print('NO')
	exit()
elif total_min == hours:
	print('YES')
	for i in range(days):
		print(min_hours[i], end=' ')
else:
	rem_hours = sorted(rem_hours, reverse=True, key=lambda x: x[0])
	remaining = hours - total_min
	indx = 0
	while remaining != 0:
		if remaining >= rem_hours[indx][0]:
			remaining -= rem_hours[indx][0]
			min_hours[rem_hours[indx][1]] = max_hours[rem_hours[indx][1]]
		else:
			min_hours[rem_hours[indx][1]] += remaining
			remaining = 0
		indx += 1
	print('YES')
	for i in range(days):
		print(min_hours[i], end=' ')


(d, s) = map(int, input().split())
a = []
b = []
(s1, s2) = (0, 0)
for i in range(d):
	(l, m) = map(int, input().split())
	s1 += l
	s2 += m
	a.append(l)
	b.append(m)
if s1 == s:
	print('YES')
	print(*a)
elif s2 == s:
	print('YES')
	print(*b)
elif s1 < s < s2:
	i = 0
	k = s - s1
	while k > b[i] - a[i]:
		k = k - (b[i] - a[i])
		a[i] = b[i]
		i += 1
	a[i] = a[i] + k
	print('YES')
	print(*a)
else:
	print('NO')


(d, sumTime) = list(map(int, input().split()))
minTime = [0] * d
maxTime = [0] * d
for i in range(d):
	(minTime[i], maxTime[i]) = list(map(int, input().split()))
if sum(maxTime) < sumTime or sum(minTime) > sumTime:
	print('NO')
else:
	ans = minTime
	j = 0
	while sum(ans) < sumTime:
		ans[j] = maxTime[j]
		j = j + 1
	ans[j - 1] = ans[j - 1] - (sum(ans) - sumTime)
	print('YES')
	print(*ans, sep=' ')


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	(d, st) = map(int, input().split())
	a = []
	mnt = 0
	mxt = 0
	for _ in range(d):
		a.append(tuple(map(int, input().split())))
		mnt += a[-1][0]
		mxt += a[-1][1]
	if mxt >= st >= mnt:
		print('YES')
		t = []
		rt = st - mnt
		for (i, j) in a:
			x = min(rt, j - i)
			print(i + x, end=' ')
			rt -= x
	else:
		print('NO')
main()


(d, sum_time) = map(int, input().split())
(min_sum, max_sum) = (0, 0)
gap = []
ans = []
for i in range(d):
	(min_time, max_time) = map(int, input().split())
	ans.append(min_time)
	gap.append(max_time - min_time)
	min_sum += min_time
	max_sum += max_time
if sum_time < min_sum or sum_time > max_sum:
	print('NO')
else:
	print('YES')
	rest = sum_time - sum(ans)
	i = 0
	while rest > 0:
		x = min(rest, gap[i])
		ans[i] += x
		rest -= x
		i += 1
	print(*ans)


(d, total) = [int(x) for x in input().split(' ')]
d_min = []
d_max = []
for i in range(0, d):
	split = [int(x) for x in input().split(' ')]
	d_min.append(split[0])
	d_max.append(split[1])
min_sum = sum(d_min)
max_sum = sum(d_max)
if min_sum <= total <= max_sum:
	print('YES')
	for i in range(0, d):
		t = min(d_min[i] + total - min_sum, d_max[i])
		print(str(t), end=' ')
		total -= t - d_min[i]
else:
	print('NO')


inp = input().split()
d = int(inp[0])
sumT = int(inp[1])
schMax = [0] * d
schMin = [0] * d
hours = 0
for i in range(d):
	inp = input().split()
	mi = int(inp[0])
	ma = int(inp[1])
	schMin[i] = mi
	schMax[i] = ma
	sumT = sumT - mi
	hours += ma - mi
if hours < sumT or sumT < 0:
	print('NO')
	quit()
else:
	print('YES')
if hours == sumT:
	for i in range(d):
		print(schMax[i], end=' ')
	quit()
if 0 == sumT:
	for i in range(d):
		print(schMin[i], end=' ')
	quit()
for i in range(d):
	mi = schMin[i]
	ma = schMax[i]
	dif = ma - mi
	if sumT == 0:
		print(mi, end=' ')
		continue
	if sumT - dif < 0:
		print(mi + sumT)
		sumT = 0
	else:
		sumT -= dif
		print(ma, end=' ')


(d, sumTime) = [int(x) for x in input().split()]
l = []
for i in range(d):
	l.append([int(x) for x in input().split()])
sum = 0
i = 0
ans = []
while i < d:
	sum += l[i][0]
	ans.append(l[i][0])
	i += 1
if sum == sumTime:
	print('YES')
	print(*ans)
elif sumTime < sum:
	print('NO')
else:
	i = 0
	f = 0
	while sum < sumTime:
		sum += l[i][1] - l[i][0]
		ans[i] = l[i][1]
		i += 1
		if i == d:
			f = 1
			break
	if sum == sumTime:
		print('YES')
		print(*ans)
	elif f == 1 and sum < sumTime:
		print('NO')
	else:
		i -= 1
		ans[i] = ans[i] - (sum - sumTime)
		print('YES')
		print(*ans)


import sys
(d, s) = map(int, input().split())
l = []
mi = 0
ma = 0
for i in range(d):
	(x, y) = map(int, input().split())
	l.append([x, y])
	mi += x
	ma += y
if s <= ma and s >= mi:
	print('YES')
	s -= mi
	for i in range(d):
		curr = l[i][0]
		curr += min(l[i][1] - l[i][0], s)
		s -= min(l[i][1] - l[i][0], s)
		print(curr, end=' ')
else:
	print('NO')


s = input().strip().split()
d = int(s[0])
sumTime = int(s[1])
l_p = []
for i in range(d):
	s = input().strip().split()
	l_p.append({'min': int(s[0]), 'max': int(s[1])})
min_time = 0
max_time = 0
for sh_d in l_p:
	min_time = min_time + sh_d['min']
	max_time = max_time + sh_d['max']
if min_time > sumTime or sumTime > max_time:
	print('NO')
else:
	print('YES')
	l_m = []
	for sh_d in l_p:
		l_m.append(sh_d['min'])
	for i in range(len(l_m)):
		add = sumTime - sum(l_m)
		if add == 0:
			break
		l_m[i] = l_m[i] + min(add, l_p[i]['max'] - l_m[i])
	for sh_d in l_m:
		print(sh_d)


def main(n, sm, days):
	lo = hi = 0
	ans = []
	for d in days:
		lo += d[0]
		hi += d[1]
		ans.append(d[0])
	if lo <= sm <= hi:
		print('YES')
		rm = sm - lo
		i = 0
		while rm > 0:
			ans[i] += min(days[i][1] - days[i][0], rm)
			rm -= days[i][1] - days[i][0]
			i += 1
		ans = ' '.join(map(str, ans))
		print(ans)
	else:
		print('NO')
(n, sm) = [int(x) for x in input().split(' ')]
days = []
for i in range(n):
	days.append([int(x) for x in input().split(' ')])
main(n, sm, days)


(d, time) = map(int, input().split())
days = list()
arr = list()
sum1 = 0
sum2 = 0
for i in range(0, d):
	day = list(map(int, input().split()))
	days.append(day)
	arr.append(day[0])
	sum1 += day[0]
	sum2 += day[1]
if sum2 < time or sum1 > time:
	print('NO')
else:
	diff = time - sum1
	for i in range(0, len(days)):
		dif = days[i][1] - days[i][0]
		diff -= dif
		arr[i] += dif
		if diff < 0:
			arr[i] += diff
			diff = 0
			break
	print('YES')
	print(*arr)


(d, sumTime) = map(int, input().split())
tmin = []
tmax = []
for i in range(d):
	(mi, ma) = map(int, input().split())
	tmin.append(mi)
	tmax.append(ma)
if sum(tmax) < sumTime or sum(tmin) > sumTime:
	print('NO')
else:
	ans = tmin.copy()
	i = 0
	while sumTime - sum(tmin) > 0:
		if ans[i] == tmax[i]:
			i += 1
			continue
		ans[i] += 1
		sumTime -= 1
	print('YES')
	print(' '.join((str(ans[i]) for i in range(d))))


(d, t) = [int(i) for i in input().split()]
ttt = list()
(min_s, max_s) = (0, 0)
for i in range(d):
	(a, b) = [int(j) for j in input().split()]
	min_s += a
	max_s += b
	ttt.append((a, b))
if min_s <= t <= max_s:
	print('YES')
	r = list()
	for i in reversed(ttt):
		min_s -= i[0]
		max_s -= i[1]
		if t - max_s >= i[0]:
			new_t = max_s
		else:
			new_t = t - i[0]
		r.append(t - new_t)
		t = new_t
	print(' '.join([str(i) for i in r[::-1]]))
else:
	print('NO')


nhap = input().split(' ')
(d, sumTime) = (int(nhap[0]), int(nhap[1]))
minmax = [0, 0]
mang = []
ans = []
for i in range(d):
	nhap = input().split(' ')
	minmax[0] += int(nhap[0])
	minmax[1] += int(nhap[1])
	ans.append(int(nhap[1]))
	mang.append(nhap)
if minmax[0] < sumTime and sumTime < minmax[1]:
	count = minmax[1]
	i = d - 1
	while i >= 0:
		space = int(mang[i][1]) - int(mang[i][0])
		if count - space <= sumTime:
			ans[i] -= int(count - sumTime)
			break
		ans[i] = int(mang[i][0])
		count -= space
		i -= 1
	print('YES')
	for i in range(d):
		print(ans[i], end=' ')
elif minmax[0] == sumTime:
	print('YES')
	for i in range(len(mang)):
		print(mang[i][0], end=' ')
elif minmax[1] == sumTime:
	print('YES')
	for i in range(len(mang)):
		print(mang[i][1], end=' ')
else:
	print('NO')


t = 0
i = 0
j = 0
k = 0
lo = input()
lo = [int(s) for s in lo.split()]
d = lo[0]
sum1 = lo[1]
a = [0 for s in range(0, 1000)]
b = [0 for s in range(0, 1000)]
for cc in range(1):
	for i in range(1, d + 1):
		la = input()
		la = la.split()
		la = [int(n) for n in la]
		a[i] = la[0]
		b[i] = la[1]
		sum1 -= a[i]
	if sum1 < 0:
		print('NO')
		continue
	elif sum1 == 0:
		print('YES')
		for i in range(1, d + 1):
			print(str(a[i]), end=' ')
		print()
		continue
	for i in range(1, d + 1):
		t = sum1
		sum1 -= b[i] - a[i]
		if sum1 <= 0:
			break
	if sum1 > 0:
		print('NO')
		continue
	print('YES')
	for j in range(1, d + 1):
		if j < i:
			print(str(b[j]), end=' ')
		elif j == i:
			print(str(a[j] + t), end=' ')
		else:
			print(str(a[j]), end=' ')
	print()


(d, s) = map(int, input().split())
a = list()
b = list()
for _ in range(d):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
if sum(a) <= s <= sum(b):
	print('YES')
	s -= sum(a)
	for i in range(d):
		x = min(b[i] - a[i], s)
		a[i] += x
		s -= x
	print(*a)
else:
	print('NO')


(d, s) = map(int, input().split())
(q, w) = ([], [])
for i in range(d):
	(n, m) = map(int, input().split())
	q.append(n)
	w.append(m)
if s >= sum(q) and s <= sum(w):
	print('YES')
	s -= sum(q)
	for i in range(d):
		if w[i] - q[i] >= s:
			q[i] += s
			break
		else:
			s -= w[i] - q[i]
			q[i] = w[i]
	print(*q)
else:
	print('NO')


__author__ = 'linh'

def main():
	str = input().split()
	d = int(str[0])
	sumTime = int(str[1])
	minTime = []
	maxTime = []
	for i in range(0, d):
		str = input().split()
		minTime.append(int(str[0]))
		maxTime.append(int(str[1]))
	m = sum(minTime)
	if sum(minTime) > sumTime or sum(maxTime) < sumTime:
		print('NO')
		return
	else:
		print('YES')
		r = sumTime - m
		i = 0
		while r != 0:
			if r > maxTime[i] - minTime[i]:
				r -= maxTime[i] - minTime[i]
				i += 1
			else:
				minTime[i] += r
				r = 0
		print(*maxTime[:i] + minTime[i:])
main()


def main():
	(days, sum_time) = map(int, input().split())
	least_most = tuple((tuple(map(int, input().split())) for _ in range(days)))
	(least_sum, most_sum) = map(sum, zip(*least_most))
	if least_sum <= sum_time <= most_sum:

		def spent():
			need = sum_time - least_sum
			for (least, most) in least_most:
				if not need:
					yield least
				else:
					adjust = most - least
					if need > adjust:
						yield most
						need -= adjust
					else:
						yield (least + need)
						need = 0
		print('YES')
		print(*spent())
	else:
		print('NO')
main()


(d, sumTime) = list(map(int, input().split()))
mint = list()
maxt = list()
allmin = 0
allmax = 0
rasp = list()
for i in range(d):
	a = list(map(int, input().split()))
	mint.append(a[0])
	maxt.append(a[1])
	allmin += a[0]
	allmax += a[1]
	rasp.append(a[0])
if allmin <= sumTime and sumTime <= allmax:
	print('YES')
	sumTime -= allmin
	i = 0
	while sumTime > 0:
		add = min(sumTime, maxt[i] - mint[i])
		rasp[i] += add
		sumTime -= add
		i += 1
	print(*rasp)
else:
	print('NO')


(d, st) = map(int, input().split())
l = []
l1 = []
for i in range(d):
	(mt, xt) = map(int, input().split())
	l.append(mt)
	l1.append(xt)
if sum(l) <= st <= sum(l1):
	print('YES')
	if sum(l) == st:
		print(' '.join(map(str, l)))
	elif sum(l1) == st:
		print(' '.join(map(str, l1)))
	else:
		for j in range(d):
			n = st - sum(l)
			d = min(n, l1[j] - l[j])
			l[j] += d
			n -= d
			if n == 0:
				break
		print(' '.join(map(str, l)))
else:
	print('NO')


(d, sumTime) = [int(x) for x in input().split(' ')]
times = []
for x in range(d):
	times.append([int(y) for y in input().split(' ')])
totalTime = 0
maxTime = 0
timesEachDay = []
index = 0
for day in times:
	totalTime += day[0]
	timesEachDay.append(day[0])
	maxTime += day[1]
	index += 1
if totalTime > sumTime or maxTime < sumTime:
	print('NO')
else:
	index = 0
	while True:
		if totalTime == sumTime:
			break
		hoursInDay = times[index][1] - times[index][0]
		if totalTime + hoursInDay < sumTime:
			totalTime += hoursInDay
			timesEachDay[index] += hoursInDay
			index += 1
		elif totalTime + hoursInDay >= sumTime:
			extra = totalTime + hoursInDay - sumTime
			timesEachDay[index] += hoursInDay - extra
			break
	print('YES')
	print(*timesEachDay)


(d, sum) = map(int, input().split())
l = []
for i in range(d):
	l.append(input().split())
avg = []
s1 = 0
s2 = 0
s3 = 0
for i in range(len(l)):
	a = 0
	a = (int(l[i][0]) + int(l[i][1])) // 2
	avg.append(a)
	s1 += int(l[i][0])
	s2 += int(l[i][1])
for j in avg:
	s3 += j
if sum >= s1 and sum <= s2:
	if s3 == sum:
		print('YES')
		for i in avg:
			print(i, end=' ')
	elif s3 > sum:
		c = 0
		k = 0
		while k < len(avg):
			while int(l[k][0]) < avg[k] and c < abs(s3 - sum):
				avg[k] -= 1
				c += 1
			k += 1
		print('YES')
		for i in avg:
			if i < 0:
				print(0, end=' ')
			print(i, end=' ')
	else:
		c1 = 0
		k = 0
		while k < len(avg):
			while int(l[k][1]) > avg[k] and c1 < abs(s3 - sum):
				avg[k] += 1
				c1 += 1
			k += 1
		print('YES')
		for i in avg:
			print(i, end=' ')
else:
	print('NO')


(d, total) = map(int, input().strip().split())
base = [0] * d
cap = [0] * d
for i in range(d):
	(base[i], cap[i]) = map(int, input().strip().split())
bs = sum(base)
cs = sum(cap)
remainder1 = total - bs
if bs <= total <= cs:
	for i in range(d):
		remainder2 = cap[i] - base[i]
		base[i] += min(remainder1, remainder2)
		remainder1 -= min(remainder1, remainder2)
	print('YES')
	print(*base)
else:
	print('NO')


temp1 = input().split()
day = int(temp1[0])
sumtime = int(temp1[1])
list1 = []
list2 = []
for i in range(day):
	temp2 = [int(i) for i in input().split()]
	list1.append(temp2)
for i in list1:
	list2.append(i[0])
summintime = 0
maxmintime = 0
for i in list1:
	summintime += i[0]
	maxmintime += i[1]
if sumtime < summintime or sumtime > maxmintime:
	print('NO')
else:
	print('YES')
	i = 0
	total = summintime
	while total < sumtime:
		total += list1[i][1]
		total -= list1[i][0]
		list2[i] = list1[i][1]
		i += 1
	if total == sumtime:
		for each in list2:
			print(each, end=' ')
	else:
		more = total - sumtime
		last = list1[i - 1][0] + more
		list2[i - 1] = last
		for each in list2:
			print(each, end=' ')


from sys import stdin, stdout
(d, s) = map(int, stdin.readline().split())
(a, b) = zip(*[[int(t) for t in l.split()] for l in stdin.readlines()])
sa = sum(a)
sb = sum(b)
if sa <= s <= sb:
	stdout.write('YES\n')
	e = s - sa
	for i in range(d):
		add = min(b[i] - a[i], e)
		e -= add
		stdout.write(f'{a[i] + add} ')
else:
	stdout.write('NO')


(d, sumTime) = map(int, input().split())
(minTime, maxTime) = ([None for _ in range(d)], [None for _ in range(d)])
for i in range(d):
	(minTime[i], maxTime[i]) = map(int, input().split())
answer = [None for _ in range(d)]
for i in range(d):
	sumTime -= minTime[i]
	answer[i] = minTime[i]
	maxTime[i] -= minTime[i]
	minTime[i] = 0
for i in range(d):
	if sumTime > 0:
		timeSpend = min(sumTime, maxTime[i])
		sumTime -= timeSpend
		answer[i] += timeSpend
		maxTime[i] -= timeSpend
if sumTime == 0:
	print('YES')
	print(' '.join(map(str, answer)))
else:
	print('NO')


a = []
b = []
(d, sumtime) = map(int, input().split())
summin = summax = 0
for i in range(d):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
	summin += x
	summax += y
if sumtime < summin or sumtime > summax:
	print('NO')
else:
	print('YES')
	for i in range(d):
		for j in range(a[i], b[i] + 1):
			if sumtime - j >= summin - a[i] and sumtime - j <= summax - b[i]:
				sumtime -= j
				summin -= a[i]
				summax -= b[i]
				print(j)
				break


(d, sumTime) = [int(x) for x in input().split()]
minh = [0 for i in range(d)]
maxh = [0 for i in range(d)]
for i in range(d):
	(minh[i], maxh[i]) = [int(x) for x in input().split()]
sumMin = sum(minh)
sumMax = sum(maxh)
if sumMin <= sumTime <= sumMax:
	print('YES')
	lie = [minh[i] for i in range(d)]
	i = 0
	while i < d and lie[i] <= maxh[i]:
		if sum(lie) == sumTime:
			break
		else:
			if lie[i] == maxh[i]:
				i += 1
				continue
			lie[i] += 1
	for hours in lie:
		print(hours, end=' ')
else:
	print('NO')


(n, d) = map(int, input().split())
Smin = 0
Smax = 0
Dm = []
Mm = []
for i in range(n):
	(Imin, Imax) = map(int, input().split())
	Smin += Imin
	Smax += Imax
	Mm.append(Imin)
	Dm.append(Imax - Imin)
if Smin <= d <= Smax:
	print('YES')
	Nd = d - Smin
	i = 0
	while Nd:
		if Dm[i] != 0:
			dif = min(Nd, Dm[i])
			Nd -= dif
			Mm[i] += dif
		i += 1
	print(*Mm)
else:
	print('NO')


(d, hrs) = [int(x) for x in input().split()]
hrs1 = hrs
a = []
for i in range(d):
	t = input().split()
	a.append(t)
sum1 = 0
sum2 = 0
for j in range(d):
	sum1 = int(a[j][0]) + sum1
	sum2 = int(a[j][1]) + sum2
count = 0
if sum1 <= hrs <= sum2:
	print('YES')
	count = count + 1
else:
	print('NO')
b = []
sum3 = 0
sum4 = 0
if len(a) >= 2 and count == 1:
	for k in range(d - 1, -1, -1):
		sum3 = int(a[k][0]) + sum3
		sum4 = int(a[k][1]) + sum4
		m = [sum3, sum4]
		b.append(m)
	b.reverse()
	c = []
	if count == 1:
		for g in range(d - 1):
			for n in range(int(a[g][0]), int(a[g][1]) + 1):
				l = hrs - n
				if int(b[g + 1][0]) <= l <= int(b[g + 1][1]):
					hrs = l
					c.append(n)
					break
	sum_5 = sum(c)
	op = hrs1 - sum_5
	c.append(op)
	for lll in c:
		print(lll, end=' ')
if len(a) == 1 and count == 1:
	print(hrs1)


(d, sumTime) = map(int, input().split())
a = {}
for i in range(d):
	a[i] = list(map(int, input().split()))
schedule = []
for i in range(d):
	schedule.append(a[i][0])
rem = sumTime - sum(schedule)
if rem > 0:
	for i in range(d):
		if a[i][1] - a[i][0] < rem:
			schedule[i] += a[i][1] - a[i][0]
			rem -= a[i][1] - a[i][0]
		else:
			schedule[i] += rem
			rem = 0
			break
if rem == 0:
	print('YES')
	print(*schedule)
else:
	print('NO')


info = input().split(' ')
days = int(info[0])
hours = int(info[1])
min = 0
max = 0
alldays = []
for i in range(0, days):
	today = input().split(' ')
	min = min + int(today[0])
	max = max + int(today[1])
	today[0] = int(today[0])
	today[1] = int(today[1])
	alldays.append(today)
	i += 1
if hours > max or hours < min:
	print('NO')
	quit()
else:
	print('YES')
freetime = max - hours
schedule = []
for day in alldays:
	if freetime == 0:
		schedule.append(str(day[1]))
	elif freetime <= day[1] - day[0]:
		schedule.append(str(day[1] - freetime))
		freetime = 0
	else:
		schedule.append(str(day[0]))
		freetime = freetime - (day[1] - day[0])
schedule = ' '.join(schedule)
print(schedule)


from sys import stdin
(d, thour) = list(map(int, stdin.readline().split()))
marr = []
for _ in range(d):
	marr.append(list(map(int, stdin.readline().split())))
arr = [0] * d
remain = thour
for i in range(d):
	(mn, mx) = marr[i]
	arr[i] += mn
	remain -= mn
if remain < 0:
	print('NO')
	exit()
else:
	i = 0
	count = dict()
	while remain > 0 and len(count) < d:
		(mn, mx) = marr[i]
		if arr[i] == mx:
			count[i] = True
		else:
			arr[i] += 1
			remain -= 1
		i += 1
		i %= d
	if len(count) == d and remain > 0:
		print('NO')
		exit()
	for i in range(d):
		(mn, mx) = marr[i]
		if arr[i] >= mn and arr[i] <= mx:
			pass
		else:
			print('NO')
			exit()
	print('YES')
	print(*arr)


try:
	mt = []
	mx = []
	(d, sumtime) = list(map(int, input().split()))
	for _ in range(d):
		(mintime, maxtime) = list(map(int, input().split()))
		mt.append(mintime)
		mx.append(maxtime)
	if sumtime >= sum(mt) and sumtime <= sum(mx):
		print('YES')
		for i in range(d):
			t = min(mt[i] - sum(mt) + sumtime, mx[i])
			if i + 1 < d:
				print(t, end=' ')
			else:
				print(t)
			sumtime -= t - mt[i]
	else:
		print('NO')
except EOFError:
	pass


(d, sumTime) = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(d)]
(mn, mx) = (sum([x[0] for x in a]), sum([x[1] for x in a]))
if mn > sumTime or mx < sumTime:
	print('NO')
else:
	print('YES')
	for i in range(d):
		mn -= a[i][0]
		d = min(a[i][1], sumTime - mn)
		print(d, end=' ')
		sumTime -= d


import math

def main():
	(days, sumTime) = map(int, input().split())
	lb = []
	up = []
	for x in range(days):
		(mi, ma) = map(int, input().split())
		lb.append(mi)
		up.append(ma)
	addtil = sum(lb)
	if addtil > sumTime or sum(up) < sumTime:
		print('NO')
		return
	print('YES')
	res = ''
	for x in range(days):
		if addtil > sumTime:
			res = res[0:-1]
			print(res)
			return
		target = sumTime - addtil
		up_day = up[x] - lb[x]
		h = min(target, up_day)
		addtil += h
		res = res + str(h + lb[x]) + ' '
	res = res[0:-1]
	print(res)
	return
main()


from sys import stdin
(d, s) = tuple(map(int, input().split()))
times = [tuple(map(int, line.split())) for line in stdin.readlines()]
(mn, mx) = tuple(map(sum, zip(*times)))
flag = mn <= s and s <= mx
print('YES' if flag else 'NO')
if flag:
	ans = [p[0] for p in times]
	remain = s - sum(ans)
	for (idx, (n, x)) in enumerate(times):
		df = min(remain, x - n)
		ans[idx] += df
		remain -= df
	print(*ans)


(d, s) = map(int, input().split())
mn = []
mx = []
for i in range(d):
	(x, y) = map(int, input().split())
	mn.append(x)
	mx.append(y)
if sum(mn) > s or sum(mx) < s:
	print('NO')
	exit()
need = sum(mx) - s
for i in range(d):
	diff = min(need, mx[i] - mn[i])
	mx[i] -= diff
	need -= diff
	if need == 0:
		break
print('YES')
print(*mx)


(days, sum_time) = map(int, input().split())
list_of_min_time = []
list_of_remaining_time = []
sum_of_max = 0
for _ in range(days):
	(min_time, max_time) = map(int, input().split())
	list_of_min_time.append(min_time)
	list_of_remaining_time.append(max_time - min_time)
	sum_of_max += max_time - min_time
	sum_time -= min_time
if sum_time >= 0 and sum_time <= sum_of_max:
	if sum_time > 0:
		for i in range(days):
			if list_of_remaining_time[i] > sum_time:
				list_of_min_time[i] += sum_time
				break
			else:
				list_of_min_time[i] += list_of_remaining_time[i]
				sum_time -= list_of_remaining_time[i]
				list_of_remaining_time[i] = 0
	output = 'YES\n'
	for i in range(days):
		output += str(list_of_min_time[i]) + ' '
	print(output)
else:
	print('NO')


(d, s) = map(int, input().split())
a = []
b = []
sa = 0
sb = 0
for i in range(d):
	(m, n) = map(int, input().split())
	a.append(m)
	b.append(n)
	sa += m
	sb += n
if s < sa or s > sb:
	print('NO')
	exit(0)
print('YES')
p = s - sa
for i in range(d):
	while p:
		if a[i] < b[i]:
			a[i] += 1
			p -= 1
		else:
			break
for i in range(d):
	print(a[i], end=' ')


inp = lambda : [*map(int, input().split())]
(d, sumTime) = inp()
a = [inp() for i in range(d)]
big = sum([i[1] for i in a])
small = sum([i[0] for i in a])
if big < sumTime or small > sumTime:
	print('NO')
	quit()
print('YES')
current = small
f = False
for i in range(d):
	if f:
		print(a[i][0], end=' ')
		continue
	if current + a[i][1] - a[i][0] <= sumTime:
		current += a[i][1] - a[i][0]
		print(a[i][1], end=' ')
		continue
	print(a[i][0] + sumTime - current, end=' ')
	f = True
print()


(d, sum_time) = map(int, input().split())
limitations = []
for _ in range(d):
	limitations.append(list(map(int, input().split())))

def cumsum(a):
	sum = 0
	cumsum = []
	for (x, _) in a[::-1]:
		sum += x
		cumsum = [sum] + cumsum
	return cumsum
min_times = cumsum(limitations)
schedule = []
total_time = 0

def relu(x):
	return x * (x > 0)
for (i, (min_time, max_time)) in enumerate(limitations):
	time = min(min_time + relu(sum_time - min_times[i]), max_time)
	schedule.append(time)
	sum_time -= time
if sum_time == 0:
	print('YES')
	print(*schedule)
else:
	print('NO')


(d, sum_time) = input().split()
d = int(d)
sum_time = int(sum_time)
mins = []
maxs = []
for i in range(d):
	(min_val, max_val) = input().split()
	mins.append(int(min_val))
	maxs.append(int(max_val))
min_sum = sum(mins)
max_sum = sum(maxs)
if min_sum <= sum_time and sum_time <= max_sum:
	print('YES')
	result = []
	for i in range(d):
		t = min(mins[i] + sum_time - min_sum, maxs[i])
		result.append(str(t))
		sum_time -= t - mins[i]
	print(' '.join(result))
else:
	print('NO')


(d, s) = map(int, input().split())
(a, b) = ([0] * d, [0] * d)
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
(A, B) = (sum(a), sum(b))
if A > s or s > B:
	print('NO')
else:
	s -= A
	i = 0
	while s > 0:
		s += a[i] - b[i]
		a[i] = b[i]
		i += 1
	a[i - 1] += s
	print('YES')
	print(' '.join((str(i) for i in a)))


(d, sumTime) = [int(x) for x in input().split(' ')]
times = []
for x in range(d):
	times.append([int(y) for y in input().split(' ')])
minSum = sum([x[0] for x in times])
maxSum = sum([x[1] for x in times])
if sumTime / d > 8:
	print('NO')
elif minSum > sumTime or maxSum < sumTime:
	print('NO')
else:
	amountToDeduct = maxSum - sumTime
	guessTime = [x[1] for x in times]
	for i in range(len(times)):
		cTime = times[i]
		guessTime[i] = cTime[0]
		amountToDeduct = amountToDeduct - (cTime[1] - cTime[0])
		if amountToDeduct == 0:
			break
		if amountToDeduct < 0:
			guessTime[i] = guessTime[i] - amountToDeduct
			break
	print('YES')
	print(*guessTime)


SMi = []
SMa = []
(d, k) = map(int, input().split())
for i in range(d):
	(Min, Max) = map(int, input().split())
	SMi.append(Min)
	SMa.append(Max)
	k -= Min
if k < 0:
	print('NO')
	exit()
if k == 0:
	print('YES')
	print(*SMi)
	exit()
for i in range(d):
	yy = SMa[i] - SMi[i]
	if yy >= k:
		SMi[i] += k
		print('YES')
		print(*SMi)
		exit()
	else:
		SMi[i] = SMa[i]
		k -= yy
print('NO')


(d, sumTime) = map(int, input().split())
s = 0
need = 0
a = [0] * d
m = [0] * d
for i in range(d):
	(m[i], a[i]) = map(int, input().split())
	s += m[i]
need = sumTime - s
if need < 0:
	print('NO')
else:
	for i in range(d):
		if need > 0:
			if need < a[i] - m[i]:
				m[i] = m[i] + need
				need = 0
			else:
				need -= a[i] - m[i]
				m[i] = a[i]
	if need > 0:
		print('NO')
	else:
		print('YES')
		for i in m:
			print(i, end=' ')


(d, sumtime) = list(map(int, input().split()))
(mintime, maxtime) = ([], [])
for i in range(d):
	(a, b) = list(map(int, input().split()))
	mintime.append(a)
	maxtime.append(b)
if sumtime < sum(mintime) or sumtime > sum(maxtime):
	print('NO')
else:
	print('YES')
	falta = sumtime - sum(mintime)
	available = [j - i for (i, j) in zip(mintime, maxtime)]
	for (i, av) in enumerate(available):
		if falta == 0:
			break
		if falta - av >= 0:
			falta -= av
			mintime[i] += av
		else:
			mintime[i] += falta
			falta = 0
	mintime = [str(i) for i in mintime]
	print(' '.join(mintime))


import math
d = input().split()
days = int(d[0])
sumTime = int(d[1])
min = 0
max = 0
totaldat = []
avg = []
sum = 0
for _ in range(days):
	da = input().split()
	min += int(da[0])
	max += int(da[1])
	avg.append(math.floor((int(da[0]) + int(da[1])) / 2))
	sum += math.floor((int(da[0]) + int(da[1])) / 2)
	totaldat.append((int(da[0]), int(da[1])))
b = False
if min <= sumTime <= max:
	print('YES')
	b = True
else:
	print('NO')
sumAvg = 0
if sum == min and b:
	for j in range(days):
		print(totaldat[j][0], end=' ')
	b = False
if sum == max and b:
	for j in range(days):
		print(totaldat[j][1], end=' ')
	b = False
i = 0
while sum != sumTime and b:
	i = i % days
	if sum < sumTime:
		if avg[i] < totaldat[i][1]:
			avg[i] += 1
			sum += 1
	elif sum > sumTime:
		if avg[i] > totaldat[i][0]:
			avg[i] -= 1
			sum -= 1
	i += 1
if b:
	for i in range(days):
		print(avg[i], end=' ')


while True:
	try:

		def soln(d, hr, rot):
			th = 0
			res = list()
			for i in range(d):
				th += rot[i][0]
				res.append(rot[i][0])
			if th < hr:
				for i in range(d):
					d = rot[i][1] - rot[i][0]
					if d > hr - th:
						res[i] += hr - th
						th = hr
						break
					else:
						res[i] += d
						th += d
			if th != hr:
				print('NO')
			else:
				print('YES')
				print(*res)

		def read():
			(d, r) = map(int, input().split())
			rut = list()
			for i in range(d):
				rut.append(list(map(int, input().split())))
			soln(d, r, rut)
		if __name__ == '__main__':
			read()
	except EOFError:
		break


(d, sumtime) = map(int, input().split())
(mintime, maxtime) = ([0] * d, [0] * d)
(suma, sumb) = (0, 0)
for i in range(d):
	(mintime[i], maxtime[i]) = map(int, input().split())
	suma += mintime[i]
	sumb += maxtime[i]
if suma <= sumtime <= sumb:
	print('YES')
	sumtime -= suma
	for i in range(d):
		m = min(sumtime, maxtime[i] - mintime[i])
		sumtime -= m
		print(mintime[i] + m, end=' ')
else:
	print('NO')


(d, sumTime) = map(int, input().split())
(minTime, maxTime) = ([], [])
for i_ in range(d):
	inp = tuple(map(int, input().split()))
	minTime.append(inp[0])
	maxTime.append(inp[1])
if sumTime < sum(minTime) or sumTime > sum(maxTime):
	print('NO')
	exit()
sсhedule = []
sT = sumTime
for i in range(d):
	sсhedule.append(minTime[i])
	sT -= minTime[i]
i = 0
while sT > 0:
	s = sсhedule[i]
	m = maxTime[i]
	while s < m and sT > 0:
		s += 1
		sT -= 1
	sсhedule[i] = s
	i += 1
print('YES')
print(*sсhedule)


(d, sumTime) = map(int, input().split())
minTime = []
maxTime = []
timeList = []
maxSum = 0
minSum = 0
for i in range(d):
	minTime.append(0)
	maxTime.append(0)
	(minTime[i], maxTime[i]) = map(int, input().split())
	maxSum += maxTime[i]
	minSum += minTime[i]
if maxSum >= sumTime >= minSum:
	timeList = minTime
	i = 0
	while minSum != sumTime:
		if minTime[i] != maxTime[i]:
			minSum += 1
			timeList[i] += 1
			if timeList[i] == maxTime[i]:
				i += 1
			else:
				continue
		else:
			i += 1
	print('YES')
	print(*timeList)
else:
	print('NO')


(n, s) = map(int, input().split())
k = []
x = []
(m, mi) = (0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	k.append([a, b])
	x.append(a)
	mi += a
	m += b
if mi <= s <= m:
	print('YES')
	y = s - sum(x)
	for i in range(n):
		if x[i] + y >= k[i][1]:
			y = x[i] + y - k[i][1]
			x[i] = k[i][1]
		else:
			x[i] = x[i] + y
			y = 0
			break
	print(*x)
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
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()
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(d, sumtime) = map(int, input().rstrip().split())
a = [0] * d
b = [0] * d
for i in range(d):
	(a[i], b[i]) = map(int, input().rstrip().split())
if sum(a) > sumtime or sumtime > sum(b):
	print('NO')
else:
	print('YES')
	ans = a[:]
	sumtime -= sum(a)
	i = 0
	while sumtime > 0:
		sumtime -= b[i] - a[i]
		if sumtime < 0:
			ans[i] += abs(sumtime)
			break
		ans[i] = b[i]
		i += 1
	print(*ans)


first_line = input().split()
d = int(first_line[0])
sumTime = int(first_line[1])
study_constraints = list()
minSum = 0
maxSum = 0
for i in range(d):
	line = input().split()
	minTime = int(line[0])
	maxTime = int(line[1])
	minSum += minTime
	maxSum += maxTime
	study_constraints.append((minTime, maxTime))
if sumTime < minSum or sumTime > maxSum:
	print('NO')
else:
	print('YES')
	diff = sumTime - minSum
	for day in study_constraints:
		poss_time = day[1] - day[0]
		t = min(poss_time, diff)
		print(day[0] + t, end=' ')
		diff -= t
	print()


(n, s) = map(int, input().split(' '))
times = []
for _ in range(n):
	times.append(tuple(map(int, input().split(' '))))
pos_times = [times[0]]
for i in range(1, n):
	pos_times.append(tuple(map(lambda x, y: x + y, times[i], pos_times[i - 1])))
if s < pos_times[-1][0] or s > pos_times[-1][1]:
	print('NO')
else:
	print('YES')
	counter = n - 1
	ans = []
	while counter > 0 and s - times[counter][1] >= pos_times[counter - 1][0]:
		ans.append(times[counter][1])
		s -= times[counter][1]
		counter -= 1
	if counter == 0:
		ans.append(s)
	else:
		ans.append(s - pos_times[counter - 1][0])
	counter -= 1
	while counter > -1:
		ans.append(times[counter][0])
		counter -= 1
	print(*ans[::-1])


def main():
	(d, sum_time) = tuple(map(int, input().split()))
	day_times = []
	sum_min = 0
	sum_max = 0
	for x in range(d):
		(min_x, max_x) = tuple(map(int, input().split()))
		sum_min += min_x
		sum_max += max_x
		day_times.append((min_x, max_x))
	if sum_time > sum_max:
		print('NO')
		return
	if sum_time - sum_min < 0:
		print('NO')
		return
	extra = sum_time - sum_min
	print('YES')
	for (min_x, max_x) in day_times:
		spent = min(extra, max_x - min_x)
		extra -= spent
		print(min_x + spent, end=' ')
main()


def read_ints():
	return map(int, input().split())
(d, time) = read_ints()
minTime = [0] * d
maxTime = [0] * d
for i in range(d):
	(minTime[i], maxTime[i]) = read_ints()
if sum(minTime) <= time <= sum(maxTime):
	print('YES')
	solution = []
	dr = time - sum(minTime)
	for i in range(d):
		di = min(dr, maxTime[i] - minTime[i])
		dr -= di
		solution.append(str(minTime[i] + di))
	print(' '.join(solution))
else:
	print('NO')


(d, sum1) = map(int, input().split())
ans = []
min_lim = []
max_lim = []
for i in range(0, d):
	(c, l) = map(int, input().split())
	min_lim.append(c)
	max_lim.append(l)
	sum1 = sum1 - c
ans = min_lim.copy()
if sum1 < 0:
	print('NO')
else:
	idx = 0
	while idx < d and sum1 > 0:
		ans[idx] = min(ans[idx] + sum1, max_lim[idx])
		sum1 = sum1 - (ans[idx] - min_lim[idx])
		idx += 1
	if sum1 > 0:
		print('NO')
	else:
		print('YES')
		for i in ans:
			print(i, end=' ')


(d, time) = map(int, input().split())
limit = []
rou = []
for i in range(d):
	l = list(map(int, input().split()))
	limit.append(l)
for i in limit:
	time -= i[0]
	rou.append(i[0])
	if time < 0:
		print('NO')
		break
else:
	k = 0
	for i in limit:
		n = i[1] - i[0]
		time = time - n
		if time < 0:
			n = n + time
			rou[k] += n
			break
		rou[k] += n
		k += 1
	if time > 0:
		print('NO')
	else:
		print('YES')
		for j in rou:
			print(j, end=' ')


from functools import reduce

def study_table(days, hours, schedule):
	lowest = reduce(lambda x, y: x + y[0], schedule, 0)
	highest = reduce(lambda x, y: x + y[1], schedule, 0)
	if lowest > hours:
		return ('NO', None)
	if highest < hours:
		return ('NO', None)
	left = hours - lowest
	total = 0
	taken = []
	for i in schedule:
		if total < left:
			extra_val = min(i[1] - i[0], left - total)
			taken.append(extra_val + i[0])
			total += extra_val
		else:
			taken.append(i[0])
	return ('YES', taken)

def helper(l):
	if not l:
		return
	r = ''
	for i in l:
		r += str(i) + ' '
	return r[:-1]
line = input().split(' ')
(days, hours) = list(map(int, line))
schedule = []
for d in range(days):
	line2 = input().split(' ')
	(low, hi) = list(map(int, line2))
	schedule.append([low, hi])
(ans, sol) = study_table(days, hours, schedule)
print(ans)
if sol:
	print(helper(sol))


(d, sumTime) = map(int, input().split())
minTime = []
maxTime = []
new_sch = []
flag = 0
for _ in range(d):
	(temp1, temp2) = map(int, input().split())
	minTime.append(temp1)
	maxTime.append(temp2)
if sum(minTime) <= sumTime <= sum(maxTime):
	sumTime -= sum(minTime)
	print('YES')
	for i in range(len(minTime)):
		if maxTime[i] - minTime[i] <= sumTime:
			sumTime -= maxTime[i] - minTime[i]
			minTime[i] = maxTime[i]
		else:
			minTime[i] += sumTime
			sumTime = 0
		print(minTime[i], end=' ')
else:
	print('NO')


(d, stime) = map(int, input().split())
mint = [0] * d
maxt = [0] * d
for i in range(d):
	(mint[i], maxt[i]) = map(int, input().split())
summint = sum(mint)
if sum(mint) <= stime <= sum(maxt):
	print('YES')
	for i in range(d):
		if stime - summint + mint[i] - maxt[i] >= 0:
			print(maxt[i], end=' ')
			stime -= maxt[i]
			summint -= mint[i]
		elif stime == summint:
			print(mint[i], end=' ')
		else:
			print(mint[i] + stime - summint, end=' ')
			stime = summint
else:
	print('NO')


(d, sumTime) = map(int, input().split())
time = []
for i in range(d):
	time.append(tuple(map(int, input().split())))
s = [i[0] for i in time]
if sumTime > sum([i[1] for i in time]):
	print('NO')
	exit(0)
while sum(s) <= sumTime:
	for i in range(d):
		if time[i][0] <= s[i] < time[i][1]:
			s[i] += 1
		if sum(s) == sumTime:
			print('YES')
			print(*s)
			exit(0)
print('NO')


def myfunc(e):
	return e[0]
n = list(map(int, input().split()))
arr = []
mn = 0
mx = 0
for i in range(n[0]):
	l = list(map(int, input().split()))
	mn += l[0]
	mx += l[1]
	arr.append(l)
if n[1] < mn or n[1] > mx:
	print('NO')
else:
	print('YES')
	if n[1] == mx:
		for i in range(n[0]):
			print(arr[i][1], end=' ')
	elif n[1] == mn:
		for i in range(n[0]):
			print(arr[i][0], end=' ')
	else:
		dct = {}
		for i in range(len(arr)):
			if arr[i][0] in dct.keys():
				dct[arr[i][0]].append((arr[i][1], i))
			else:
				dct[arr[i][0]] = [(arr[i][1], i)]
		m = sorted(dct.keys())
		for i in dct.keys():
			dct[i].sort(key=myfunc)
		arr1 = []
		for i in m:
			for j in dct[i]:
				x = (i, j[0], j[1])
				arr1.append(x)
		dct2 = {}
		time = n[1]
		l = len(arr1)
		for i in range(l):
			if time - arr1[i][1] >= mn - arr1[i][0] and time - arr1[i][1] <= mx - arr1[i][1]:
				time = time - arr1[i][1]
				dct2[arr1[i][2]] = arr1[i][1]
				mn = mn - arr1[i][0]
				mx = mx - arr1[i][1]
			elif i == l - 1:
				dct2[arr1[i][2]] = time
			else:
				time = time - arr1[i][0]
				dct2[arr1[i][2]] = arr1[i][0]
				mn = mn - arr1[i][0]
				mx = mx - arr1[i][1]
		m = sorted(dct2.keys())
		for i in m:
			print(dct2[i], end=' ')


(d, sum_time) = map(int, input().split())
bounds = [tuple(map(int, input().split())) for _ in range(d)]
min_sum = sum((min_time for (min_time, max_time) in bounds))
max_sum = sum((max_time for (min_time, max_time) in bounds))
if min_sum <= sum_time <= max_sum:
	print('YES')
	for (min_time, max_time) in bounds:
		(min_sum, max_sum) = (min_sum - min_time, max_sum - max_time)
		t = min(sum_time - min_sum, max_time)
		sum_time -= t
		print(t, end=' ')
else:
	print('NO')


(d, sumTime) = map(int, input().split())
minTime = []
maxTime = []
for i in range(d):
	(curMinTime, curMaxTime) = map(int, input().split())
	minTime.append(curMinTime)
	maxTime.append(curMaxTime)
if sum(minTime) <= sumTime <= sum(maxTime):
	print('YES')
	needTime = sumTime
	leftMaxTime = sum(maxTime)
	spentEverday = []
	for i in range(d):
		leftMaxTime -= maxTime[i]
		if leftMaxTime >= needTime:
			spentEverday.append(minTime[i])
			needTime -= minTime[i]
		else:
			spentEverday.append(needTime - leftMaxTime)
			needTime = leftMaxTime
	print(' '.join(map(str, spentEverday)))
else:
	print('NO')


(d, st) = map(int, input().split())
l1 = [0] * d
l2 = [0] * d
sum = 0
for i in range(d):
	(a, b) = map(int, input().split())
	l1[i] = a
	l2[i] = b
	sum += a
ans = l1.copy()
if sum > st:
	print('NO')
else:
	for i in range(d):
		if sum == st:
			break
		if sum + l2[i] - l1[i] > st:
			ans[i] += st - sum
			sum = st
		else:
			sum += l2[i] - l1[i]
			ans[i] = l2[i]
	if sum == st:
		print('YES')
		print(*ans)
	else:
		print('NO')


(d, s) = map(int, input().split())
l1 = []
l2 = []
for i in range(d):
	(mi, ma) = map(int, input().split())
	l1.append(mi)
	l2.append(ma)
if sum(l1) <= s <= sum(l2):
	p = s - sum(l1)
	for i in range(d):
		r = l2[i] - l1[i]
		l1[i] += min(r, p)
		p -= min(p, r)
	print('YES')
	print(*l1, end='')
else:
	print('NO')


(n, sim) = map(int, input().split())
(capt, mi, mx) = ([], 0, 0)
for _ in range(n):
	(a, b) = map(int, input().split())
	mi += a
	mx += b
	intrim = []
	for x in range(a, b + 1):
		intrim.append(x)
	capt.append(intrim)
if sim < mi or sim > mx:
	print('NO')
elif n == 1:
	print('YES')
	print(sim)
elif sim == mi:
	print('YES')
	print(' '.join((str(i[0]) for i in capt)))
elif sim == mx:
	print('YES')
	print(' '.join((str(i[-1]) for i in capt)))
else:
	path = []
	for x in range(n - 1):
		flag = False
		mi -= capt[x][0]
		for j in capt[x]:
			diff = sim - j
			if diff == mi:
				path.append(j)
				sim -= j
				flag = True
				break
		if not flag:
			path.append(capt[x][-1])
			sim -= capt[x][-1]
	path.append(sim)
	print('YES')
	print(*path)


class A:

	def solve(self):
		n = int(input())
		other = n - 2
		if other > 0 and other % 2 == 0:
			print('YES')
		else:
			print('NO')

class B:

	def solve(self):
		[d, w] = [int(x) for x in input().split(' ')]
		times = []
		for i in range(d):
			times.append(tuple([int(x) for x in input().split(' ')]))
		sum_l = sum([t[0] for t in times])
		sum_h = sum([t[1] for t in times])
		if not sum_l <= w <= sum_h:
			print('NO')
			return
		print('YES')
		for (l, h) in times:
			lb = l
			sum_l -= l
			sum_h -= h
			while lb <= h:
				if sum_l <= w - lb <= sum_h:
					break
				else:
					lb += 1
			print('{} '.format(lb), end='')
			w -= lb
B().solve()


(d, sumTime) = map(int, input().split())
mi = []
ma = []
for i in range(d):
	(a, b) = map(int, input().split())
	mi.append(a)
	ma.append(b)
if sum(mi) <= sumTime <= sum(ma):
	print('YES')
	sumTime -= sum(mi)
	for i in range(d):
		print(mi[i] + min(sumTime, ma[i] - mi[i]))
		sumTime = max(0, sumTime - ma[i] + mi[i])
else:
	print('NO')


(totalNum, totalNumOfH) = (int(i) for i in input().split())
countOfDays = [list(map(int, input().split())) for _ in range(totalNum)]
ziped = list(zip(*countOfDays))
minOfH = sum(ziped[0])
maxOfH = sum(ziped[1])
if minOfH <= totalNumOfH <= maxOfH:
	print('YES')
	diff = totalNumOfH - minOfH
	for (n, x) in countOfDays:
		cur = min(x - n, diff)
		diff -= cur
		print(n + max(0, cur), end=' ')
else:
	print('NO')


(d, st) = map(int, input().split())
(a, b) = ([0] * d, [0] * d)
c = [0] * d
suma = 0
sumb = 0
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
	c[i] = a[i]
	suma += a[i]
	sumb += b[i]
if st > sumb or st < suma:
	print('NO')
else:
	print('YES')
	st -= suma
	k = 0
	while st > 0:
		if st - (b[k] - a[k]) >= 0:
			c[k] += b[k] - a[k]
			st -= b[k] - a[k]
		else:
			c[k] += st
			st = 0
		k += 1
	for j in range(d):
		print(c[j], end=' ')


times = [[], []]
timesSums = [0, 0]
lst = input().split(' ')
d = int(lst[0])
sumTime = int(lst[1])
for i in range(d):
	a = input().split(' ')
	for i in range(len(a)):
		a[i] = int(a[i])
		timesSums[i] += a[i]
		times[i].append(a[i])
if sumTime >= timesSums[0] and sumTime <= timesSums[1]:
	resList = times[0]
	sumTime -= timesSums[0]
	i = 0
	while sumTime > 0:
		diff = times[1][i] - resList[i]
		if sumTime >= diff:
			resList[i] += diff
			sumTime -= diff
		else:
			resList[i] += sumTime
			sumTime = 0
		i += 1
	print('YES')
	print(' '.join(list(map(str, resList))))
else:
	print('NO')


(d, st) = map(int, input().split())
(s1, s2) = ([], [])
(p, q) = (0, 0)
for i in range(d):
	(mnt, mxt) = map(int, input().split())
	p += mnt
	q += mxt
	s1.append(mnt)
	s2.append(mxt)
if st >= p and st <= q:
	print('YES')
	x = st - p
	for i in range(d):
		if x == 0:
			print(s1[i], end=' ')
		elif s1[i] + x >= s2[i]:
			x -= s2[i] - s1[i]
			print(s2[i], end=' ')
		elif x > 0:
			print(s1[i] + x, end=' ')
			x = 0
	print()
else:
	print('NO')


(d, sums) = list(map(int, input().split()))
minSum = 0
maxSum = 0
minarr = []
maxarr = []
ans = []
for i in range(d):
	(mini, maxi) = list(map(int, input().split()))
	minSum += mini
	minarr.append(mini)
	maxSum += maxi
	maxarr.append(maxi)
if sums < minSum or sums > maxSum:
	print('NO')
else:
	extra = sums - minSum
	for i in range(d):
		if extra >= 0:
			temp = min(maxarr[i] - minarr[i], extra)
			ans.append(minarr[i] + temp)
			extra -= temp
		else:
			ans.append(minarr[i])
	print('YES')
	print(*ans)


(d, sumTime) = map(int, input().split())
(sumMin, sumMax) = (0, 0)
s = 0
a = [0] * d
b = [0] * d
for i in range(d):
	(a[i], b[i]) = map(int, input().split())
sumMin = sum(a)
sumMax = sum(b)
ans = list(a)
if sumTime >= sumMin and sumTime <= sumMax:
	print('YES')
	while sum(ans) != sumTime:
		for i in range(d):
			if ans[i] < b[i]:
				ans[i] += 1
				break
	for i in range(d):
		print(ans[i], end=' ')
else:
	print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
mins = []
maxes = []
s_big = s_small = 0
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	mins.append(a)
	maxes.append(b)
	s_big += b
	s_small += a
if s_small <= m <= s_big:
	print('YES')
	m -= s_small
	for j in range(n):
		q = mins[j] + min(max(m, 0), maxes[j] - mins[j])
		print(q, ' ', end='')
		m -= q - mins[j]
else:
	print('NO')


import sys
(d, sumTime) = map(int, input().split())
A = []
B = []
sumA = 0
sumB = 0
for i in range(d):
	(m, n) = map(int, input().split())
	A.append(m)
	B.append(n)
	sumA += m
	sumB += n
if sumA > sumTime or sumB < sumTime:
	print('NO')
	sys.exit()
sumTime -= sumA
print('YES')
for i in range(d):
	add = min(sumTime, B[i] - A[i])
	A[i] += add
	sumTime -= add
	print(A[i], end=' ')


(d, s) = [int(x) for x in input().split()]
lmin = []
lmax = []
for i in range(d):
	(c, e) = [int(x) for x in input().split()]
	lmin.append(c)
	lmax.append(e)
c = sum(lmin)
e = sum(lmax)
if s < c or s > e:
	print('NO')
else:
	print('YES')
	x = s - c
	for i in range(d):
		q = min(lmax[i] - lmin[i], x)
		lmin[i] += min(lmax[i] - lmin[i], x)
		x = x - q
		if x == 0:
			break
	for i in range(d):
		lmin[i] = str(lmin[i])
	print(' '.join(lmin))


r = lambda : list(map(int, input().split()))
(d, t) = r()
l = [r() for _ in range(d)]
(t_min, t_max) = (sum((x[0] for x in l)), sum((x[1] for x in l)))
if t < t_min or t > t_max:
	print('NO')
else:
	res = []
	add = t - t_min
	for (low, high) in l:
		offset = min(add, high - low)
		add -= offset
		res.append(str(low + offset))
	print('YES')
	print(' '.join(res))


from sys import stdin
(d, s) = (int(i) for i in stdin.readline().split())
ans = []
max_times = []
for day in range(d):
	(mi, ma) = (int(i) for i in stdin.readline().split())
	ans.append(mi)
	max_times.append(ma - mi)
if sum(ans) > s or sum(max_times) + sum(ans) < s:
	print('NO')
else:
	print('YES')
	s -= sum(ans)
	for (i, ma) in enumerate(max_times):
		if s > ma:
			s -= ma
			ans[i] += ma
		else:
			ans[i] += s
			break
	print(*ans, sep=' ')


from sys import stdin, stdout
from heapq import *

def solve():
	(days, target) = [int(x) for x in stdin.readline().rstrip().split()]
	heap = []
	schedule = [0] * days
	for i in range(days):
		(i1, i2) = [int(x) for x in stdin.readline().rstrip().split()]
		target = target - i1
		i2 = i2 - i1
		heappush(heap, (i2, i))
		schedule[i] = i1
	if target < 0:
		stdout.write('NO\n')
		return
	while heap and target > 0:
		curr = heappop(heap)
		toSub = target if target < curr[0] else curr[0]
		target = target - toSub
		schedule[curr[1]] = schedule[curr[1]] + toSub
	if target != 0:
		stdout.write('NO\n')
		return
	stdout.write('YES\n')
	for i in schedule:
		stdout.write(format('%d ' % i))
solve()
stdout.flush()


ele = list(map(int, input().rstrip().split()))
summin = 0
summax = 0
mins = []
maxs = []
j = 0
for i in range(ele[0]):
	tlimit = list(map(int, input().rstrip().split()))
	mins.append(tlimit[0])
	maxs.append(tlimit[1])
	summin = summin + tlimit[0]
	summax = summax + tlimit[1]
if summin <= ele[1] and summax >= ele[1]:
	print('YES')
	c = ele[1]
	c = c - summin
	i = 0
	while i <= ele[0] and c != 0:
		if c <= maxs[i] - mins[i]:
			print(c + mins[i], end=' ')
			c = 0
		else:
			print(maxs[i], end=' ')
			c = c - (maxs[i] - mins[i])
		i = i + 1
	for k in range(i, ele[0]):
		print(mins[k], end=' ')
else:
	print('NO')


(d, sumTime) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(d)]
dp = [[False for _ in range(sumTime + 1)] for _ in range(d + 1)]
dp[0][0] = True
for day in range(1, d + 1):
	(minTime, maxTime) = a[day - 1]
	for time in range(sumTime + 1):
		for today in range(minTime, maxTime + 1):
			if time - today >= 0:
				dp[day][time] |= dp[day - 1][time - today]
can = dp[d][sumTime]
if not can:
	print('NO')
else:
	print('YES')
	ret = []
	for day in range(d, 0, -1):
		(minTime, maxTime) = a[day - 1]
		for today in range(minTime, maxTime + 1):
			if sumTime - today >= 0 and dp[day - 1][sumTime - today]:
				ret.append(today)
				sumTime -= today
				break
		else:
			raise Exception('Cannot find answer')
	print(' '.join(map(str, ret[::-1])))


[d, sum_time] = [int(x) for x in input().split()]
limit = []
study = []
(minimum, maximum) = (0, 0)
for i in range(d):
	line = [int(x) for x in input().split()]
	limit.append(line)
	minimum += line[0]
	maximum += line[1]
	study.append(line[0])
if minimum <= sum_time <= maximum:
	print('YES')
	j = 0
	while j < d:
		if sum_time - minimum + study[j] > limit[j][1]:
			sum_time -= limit[j][1] - study[j]
			study[j] = limit[j][1]
		else:
			study[j] += sum_time - minimum
			break
		j += 1
	study = list(map(str, study))
	print(' '.join(study))
else:
	print('NO')


r = lambda : list(map(int, input().split()))
(d, t) = r()
lim = [[0 for i in range(2)] for j in range(d)]
for i in range(d):
	(lim[i][0], lim[i][1]) = r()
	lim[i][1] = lim[i][1] - lim[i][0]
	t -= lim[i][0]
if t < 0:
	print('NO')
else:
	str1 = ''
	for i in range(d):
		if t < 0:
			str1 += str(lim[i][0]) + ' '
		else:
			t -= lim[i][1]
			if t < 0:
				str1 += str(t + lim[i][1] + lim[i][0]) + ' '
			else:
				str1 += str(lim[i][1] + lim[i][0]) + ' '
	if t <= 0:
		print('YES')
		print(str1)
	else:
		print('NO')


(d, n) = map(int, input().split())
c = []
for i in range(d):
	a = list(map(int, input().split()))
	c.append(a)
l = 0
r = 0
z = n
for i in range(len(c)):
	l += c[i][0]
	r += c[i][1]
k = []
if l <= n <= r:
	print('YES')
	n -= l
	if n == 0:
		for j in range(len(c)):
			k.append(c[j][0])
		print(*k)
	else:
		for j in range(len(c)):
			k.append(c[j][0])
		m = sum(k)
		for j in range(len(c)):
			k[j] = c[j][1]
			if z - sum(k) < 0:
				k[j] = z - m + c[j][0]
				break
			else:
				m = sum(k)
		print(*k)
else:
	print('NO')


def res(d, sumtime, mini, maxi):
	if sumtime < sum(mini) or sumtime > sum(maxi):
		print('NO')
	else:
		ans = mini[:]
		for i in range(d):
			while sum(ans) != sumtime and ans[i] < maxi[i]:
				ans[i] += 1
		print('YES')
		print(*ans)
mini = []
maxi = []
(d, sumtime) = [int(x) for x in input().split()]
for i in range(d):
	(a, b) = [int(x) for x in input().split()]
	mini.append(a)
	maxi.append(b)
res(d, sumtime, mini, maxi)


(d, ans) = [int(i) for i in input().split()]
mn = []
mx = []
for i in range(d):
	(x, y) = [int(i) for i in input().split()]
	mn.append(x)
	mx.append(y)
if sum(mx) >= ans and sum(mn) <= ans:
	print('YES')
	ans -= sum(mn)
	for i in range(d):
		j = min(ans, mx[i] - mn[i])
		ans -= j
		print(mn[i] + j, end=' ')
	print()
else:
	print('NO')


(d, sum_time) = map(int, input().split())
dif_time = []
max_time = []
time = []
summa = 0
rurur = 0
for i in range(d):
	(minimal, maximal) = map(int, input().split())
	time.append(minimal)
	dif_time.append(maximal - minimal)
	max_time.append(maximal)
	summa += minimal
dif_time1 = sum_time - summa
if dif_time1 < 0:
	print('NO')
else:
	for i in range(d):
		differ = min(dif_time1, dif_time[i])
		time[i] += differ
		dif_time1 -= differ
	if dif_time1 > 0:
		print('NO')
	else:
		print('YES')
		print(*time)


import sys
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(d, sumTime) = sp()
mat = list()
for i in range(d):
	mat.append(l())
answer = list()
for i in range(d):
	answer.append(mat[i][0])
while sum(answer) != sumTime:
	change = 0
	for i in range(d):
		if mat[i][1] > answer[i]:
			answer[i] += 1
			change = 1
		if sum(answer) == sumTime:
			break
	if not change:
		break
if sum(answer) == sumTime:
	out('YES\n')
	for i in range(d):
		out(str(answer[i]) + ' ')
	exit()
out('NO')


try:
	(days, stTime) = map(int, input().split())
	minarr = [0] * days
	maxarr = [0] * days
	for i in range(days):
		(minarr[i], maxarr[i]) = map(int, input().split())
	sa = sum(minarr)
	sb = sum(maxarr)
	r = stTime - sa
	if sa <= stTime <= sb:
		for i in range(days):
			r2 = maxarr[i] - minarr[i]
			minarr[i] += min(r2, r)
			r -= min(r2, r)
		print('YES')
		print(*minarr)
	else:
		print('NO')
except:
	pass


(d, sumTime) = map(int, input().split())
instructions = []
for i in range(d):
	instructions.append(tuple(map(int, input().split())))
(mini, maxi) = map(sum, zip(*instructions))
if not mini <= sumTime <= maxi:
	print('NO')
else:
	schedule = []
	for (i, (mn, mx)) in enumerate(instructions):
		(mini, maxi) = map(sum, zip(*instructions[i:]))
		try:
			alpha = (sumTime - mini) / (maxi - mini)
		except ZeroDivisionError:
			alpha = 1
		sol = round(mn + alpha * (mx - mn))
		schedule.append(sol)
		sumTime -= sol
	print('YES')
	print(*schedule)


(d, SUM) = map(int, input().split())
arr = []
Sum_X = 0
Sum_Y = 0
arr1 = []
for i in range(0, d):
	(x, y) = map(int, input().split())
	Sum_X = Sum_X + x
	Sum_Y = Sum_Y + y
	p = (x, y)
	arr.append(p)
if SUM < Sum_X or SUM > Sum_Y:
	print('NO')
	exit()
else:
	print('YES')
	for i in range(0, d):
		arr1.append(arr[i][0])
	p = SUM - Sum_X
	for j in range(0, d):
		if p <= 0:
			break
		if p <= arr[j][1] - arr[j][0]:
			arr1[j] = arr1[j] + p
			p = 0
		else:
			arr1[j] = arr1[j] + (arr[j][1] - arr[j][0])
			p = p - (arr[j][1] - arr[j][0])
for i in range(0, d - 1):
	print(arr1[i], end=' ')
print(arr1[d - 1])


temp = input().strip().split(' ')
d = int(temp[0])
sm = int(temp[1])
arr = []
op = []
for i in range(d):
	r = list(map(int, input().strip().split(' ')))
	op.append(r[0])
	arr.append(r)
	sm -= r[0]
if sm < 0:
	print('NO')
else:
	i = 0
	while i < d and sm != 0:
		if sm > arr[i][1] - arr[i][0]:
			op[i] = arr[i][1]
			sm -= arr[i][1] - arr[i][0]
		else:
			op[i] += sm
			sm = 0
		i += 1
	if sm == 0:
		print('YES')
		for i in op:
			print('{} '.format(i), end='')
	else:
		print('NO')


(d, sumTime) = map(int, input().split())
minTime = [0 for i in range(d)]
maxTime = [0 for i in range(d)]
schedule = []
for i in range(d):
	(minTime[i], maxTime[i]) = map(int, input().split())
schedule = minTime
scSum = sum(schedule)
i = 0
while scSum < sumTime and i != d:
	scSum += maxTime[i] - minTime[i]
	schedule[i] = maxTime[i]
	while scSum > sumTime:
		scSum -= 1
		schedule[i] -= 1
	i += 1
if scSum != sumTime:
	print('NO')
else:
	print('YES')
	for day in schedule:
		print(day, end=' ')


temp = input().strip().split(' ')
d = int(temp[0])
sumTime = int(temp[1])
minTime = []
maxTime = []
for i in range(d):
	temp = input().strip().split(' ')
	minTime.append(int(temp[0]))
	maxTime.append(int(temp[1]))
if sum(minTime) > sumTime or sumTime > sum(maxTime):
	print('NO')
elif sum(minTime) == sumTime:
	print('YES')
	print(' '.join([str(j) for j in minTime]))
elif sum(maxTime) == sumTime:
	print('YES')
	print(' '.join([str(j) for j in maxTime]))
else:
	k = sumTime - sum(minTime)
	i = 0
	while k != 0:
		if i < d - 1:
			i += 1
		else:
			i = 0
		if minTime[i] == maxTime[i]:
			continue
		if minTime[i] < maxTime[i]:
			minTime[i] += 1
			k -= 1
	print('YES')
	print(' '.join([str(j) for j in minTime]))


(days, sumTime) = map(int, input().split())
if 1 > days > 30 and 1 > sumTime > 240:
	print('NO')
else:
	(mins, maxs) = ([], [])
	for i in range(days):
		(a, b) = [int(x) for x in input().split(' ')]
		mins += [a]
		maxs += [b]
	smin = sum(mins)
	smax = sum(maxs)
	if smin <= sumTime <= smax:
		print('YES')
		diff = sumTime - smin
		for i in range(days):
			extra = min(maxs[i] - mins[i], diff)
			print(mins[i] + extra, end=' ')
			diff -= extra
	else:
		print('NO')


(d, st) = [int(x) for x in input().split()]
hour = []
(ms, Ms) = (0, 0)
for i in range(d):
	r = [int(x) for x in input().split()]
	hour.append(r)
	ms += r[0]
	Ms += r[1]
if ms <= st <= Ms:
	print('YES')
	t = ms
	for i in range(d):
		if t + hour[i][1] - hour[i][0] >= st:
			for j in range(i):
				print(hour[j][1], end=' ')
			print(hour[i][0] + st - t, end=' ')
			for j in range(i + 1, d):
				print(hour[j][0], end=' ')
			break
		else:
			t += hour[i][1] - hour[i][0]
else:
	print('NO')


import math
(d, sum_time) = [int(x) for x in input().split()]

class Range:

	def __init__(self, minimum, maximum):
		self.min = minimum
		self.max = maximum
ranges = []
for i in range(d):
	(minimum, maximum) = [int(x) for x in input().split()]
	ranges.append(Range(minimum, maximum))
min_sum = 0
max_sum = 0
for r in ranges:
	min_sum += r.min
	max_sum += r.max
if sum_time >= min_sum and sum_time <= max_sum:
	print('YES')
	results = []
	sum_left = sum_time
	for r in ranges:
		results.append(r.min)
		sum_time -= r.min
	for (i, r) in enumerate(ranges):
		left = r.max - r.min
		removing = min(left, sum_time)
		sum_time -= removing
		results[i] += removing
	print(' '.join([str(x) for x in results]))
else:
	print('NO')


(n, total) = map(int, input().split(' '))
pairs = []
ordered = []
diff = []
sum = 0
minsum = 0
for i in range(n):
	pair = [int(k) for k in input().split(' ')]
	pairs.append(pair)
	ordered.append(pair[0])
	sum += pair[1]
	minsum += pair[0]
	diff.append(pair[1] - pair[0])
if total > sum or total < minsum:
	print('NO')
	quit()
extra = 0
req = total - minsum
for i in range(n):
	dif = diff[i]
	if req == 0:
		break
	elif req >= dif:
		req -= dif
		ordered[i] += dif
	else:
		ordered[i] += req
		req = 0
if req == 0:
	print('YES')
	print(' '.join((str(k) for k in ordered)))
else:
	print('NO')


(days, hours) = list(map(int, input().split()))
list1 = []
inputList = []
minList = []
maxList = []
for day in range(days):
	inputList = list(map(int, input().split()))
	list1.append(inputList)
	minList.append(inputList[0])
	maxList.append(inputList[1])
if sum(maxList) >= hours >= sum(minList):
	print('YES')
	resultList = []
	if sum(minList) == hours:
		resultList = list(minList)
	elif sum(maxList) == hours:
		resultList = list(maxList)
	else:
		resultList = list(minList)
		remainingHours = hours - sum(resultList)
		while remainingHours:
			for i in range(days):
				if maxList[i] - minList[i] <= remainingHours:
					resultList[i] = maxList[i]
					remainingHours -= maxList[i] - minList[i]
				else:
					resultList[i] += remainingHours
					remainingHours = 0
	if sum(resultList) == hours:
		print(' '.join((str(x) for x in resultList)))
else:
	print('NO')


(d, sumTime) = [int(a) for a in input().split()]
(minMax, minT, maxT) = ([], 0, 0)
for dd in range(d):
	(a, b) = input().split()
	minMax.append((int(a), int(b)))
	minT += int(a)
	maxT += int(b)
if minT > sumTime or sumTime > maxT:
	print('NO')
	exit()
sumTime -= minT
ans = []
for (index, (mi, ma)) in enumerate(minMax):
	add = min(sumTime, ma - mi)
	ans.append(mi + add)
	sumTime -= add
print('YES')
print(' '.join([str(a) for a in ans]))


day_houres = input().split()
houres = []
score = []
all_houers = 0
yes_no = 0
yes_no_2 = 0
answer = ''
for i in range(int(day_houres[0])):
	x = input().split()
	x[0] = int(x[0])
	x[1] = int(x[1])
	k = x[1]
	yes_no += x[0]
	yes_no_2 += x[1]
	for y in x:
		number = int(y) + 1
		if not number in x and number <= int(k):
			x.append(number)
			x.sort()
	houres.append(x)
if yes_no > int(day_houres[1]) or yes_no_2 < int(day_houres[1]):
	print('NO')
else:
	for j in houres:
		w = j[0]
		score.append(w)
		all_houers += w
	while all_houers != int(day_houres[1]):
		for m in range(len(score)):
			if all_houers < int(day_houres[1]):
				n = houres[m]
				if score[m] + 1 in n:
					score[m] += 1
					all_houers += 1
	for p in score:
		answer += str(p) + ' '
	print('YES')
	print(answer)


info = list(map(int, input().split(' ')))
days = info[0]
allHours = info[1]
data = []
for i in range(days):
	info = list(map(int, input().split(' ')))
	data.append(info)
sumMin = 0
sumMax = 0
for minmax in data:
	sumMin += minmax[0]
	sumMax += minmax[1]
diff = allHours - sumMin
if allHours >= sumMin and allHours <= sumMax:
	print('YES')
	for minmax in data:
		tDiff = minmax[1] - minmax[0]
		if diff >= tDiff:
			print(minmax[0] + tDiff, end=' ')
			diff -= tDiff
		else:
			print(minmax[0] + diff, end=' ')
			diff = 0
else:
	print('NO')


(d, st) = map(int, input().split())
vals = []
tot = 0
mini = 0
ans = []
for _ in range(d):
	(f, v) = map(int, input().split())
	tot += v
	mini += f
	vals.append([f, v])
if tot < st or mini > st:
	print('NO')
elif tot == st:
	for i in range(d):
		ans.append(str(vals[i][1]))
	print('YES')
	print(' '.join(ans))
else:
	d -= 1
	ok = True
	while d >= 0 and tot > st:
		if vals[d][1] > vals[d][0]:
			tot -= 1
			vals[d][1] -= 1
			if tot == st:
				ans.append(str(vals[d][1]))
				d -= 1
		elif vals[d][1] == vals[d][0]:
			ans.append(str(vals[d][1]))
			d -= 1
		if d < 0 and tot > st:
			ok = False
	if ok:
		for i in range(d, -1, -1):
			ans.append(str(vals[i][1]))
		print('YES')
		print(' '.join(ans[::-1]))
	else:
		print('NO')


(a, b) = map(int, input().split())
min_overall = 0
max_overall = 0
sp = []
flag = 1
final = [0] * a
for i in range(a):
	(minn, maxx) = map(int, input().split())
	max_overall += maxx
	min_overall += minn
	app = (minn, maxx, i)
	sp.append(app)
if b < min_overall or b > max_overall:
	print('NO')
else:
	sp.sort(key=lambda x: -x[0])
	for i in range(a):
		if flag:
			min_overall += sp[i][1] - sp[i][0]
		if min_overall < b and flag:
			final[sp[i][2]] = sp[i][1]
		elif min_overall >= b and flag:
			now = min_overall - (sp[i][1] - sp[i][0]) - sp[i][0]
			final[sp[i][2]] = b - now
			flag = 0
		else:
			final[sp[i][2]] = sp[i][0]
	print('YES')
	print(*final)


def inp(n):
	if n == 1:
		return map(int, stdin.readline().split())
	elif n == 2:
		return map(float, stdin.readline().split())
	else:
		return map(str, stdin.readline().split())

def get_col(arr, i):
	return [row[i] for row in arr]
from sys import *
(days, sum, flag) = ([], 0, 0)
(d, sum_time) = inp(1)
for i in range(d):
	days.append(list(inp(1)))
	sum += days[i][0]
if sum > sum_time:
	exit(print('NO'))
for i in range(d):
	ext = days[i][1] - days[i][0]
	if sum == sum_time:
		flag = 1
		break
	elif sum + ext >= sum_time:
		flag = 1
		days[i][0] += sum_time - sum
		break
	else:
		sum += ext
		days[i][0] += ext
if flag:
	print('YES')
	print(*get_col(days, 0))
else:
	print('NO')


(d, sumTime) = [int(i) for i in input().split()]
maxs = []
mins = []
for i in range(d):
	(x, y) = [int(i) for i in input().split()]
	mins.append(x)
	maxs.append(y)
minTime = sum(mins)
maxTime = sum(maxs)
if sumTime < minTime or sumTime > maxTime:
	print('NO')
	exit(0)
i = 0
while minTime != sumTime:
	while mins[i] == maxs[i]:
		i += 1
	mins[i] += 1
	minTime += 1
print('YES')
print(*mins)


(d, sumTime) = map(int, input().split())
C = []
for i in range(d):
	(minTime, maxTime) = map(int, input().split())
	C.append([minTime, maxTime])
if sum([c[1] for c in C]) < sumTime or sum([c[0] for c in C]) > sumTime:
	print('NO')
elif d > 1:
	s = sum([c[0] for c in C])
	L = []
	for i in range(len(C)):
		L.append(C[i][0])
	for c in C:
		c.append(c[1] - c[0])
	if s == sumTime:
		for i in range(len(L)):
			L[i] = str(L[i])
		print('YES')
		ch = ' '.join(L)
		print(ch)
	elif s < sumTime:
		i = 0
		while i < d and s < sumTime:
			if C[i][2] > 0:
				x = s
				s += min([sumTime - s, C[i][2]])
				L[i] += min([sumTime - x, C[i][2]])
			i += 1
		print('YES')
		for i in range(len(L)):
			L[i] = str(L[i])
		ch = ' '.join(L)
		print(ch)
else:
	print('YES')
	print(sumTime)


(d, st) = input().split()
d = int(d)
st = int(st)
time = 0
days = []
maxdays = []
for i in range(d):
	(mint, maxt) = input().split()
	time += int(mint)
	days.append(int(mint))
	maxdays.append(int(maxt))
if time > st:
	print('NO')
else:
	diff = st - time
	for i in range(d):
		if diff > maxdays[i] - days[i]:
			diff -= maxdays[i] - days[i]
			days[i] += maxdays[i] - days[i]
		else:
			days[i] += diff
			break
	if sum(days) != st:
		print('NO')
	else:
		print('YES')
		w = ''
		w = ' '.join(map(str, days))
		print(w)


(d, n) = list(map(int, input().split()))
a_min = []
a_max = []
for i in range(d):
	(x, y) = list(map(int, input().split()))
	a_min.append(x)
	a_max.append(y)
cum_min = [0]
for i in range(1, d + 1):
	cum_min.append(cum_min[i - 1] + a_min[i - 1])
cum_max = [0]
for i in range(1, d + 1):
	cum_max.append(cum_max[i - 1] + a_max[i - 1])
if not cum_min[d] <= n <= cum_max[d]:
	print('NO')
else:
	print('YES')
	rep = list(range(d + 1))
	rep[d] = n
	for i in range(d, 0, -1):
		rep[i - 1] = min(cum_max[i - 1], rep[i] - a_min[i - 1])
	for i in range(d):
		print(rep[i + 1] - rep[i], end=' ')


s = input()
a = s.split(' ')
(d, ST) = (int(a[0]), int(a[1]))
Sdl = []
maxT = []
while d > 0:
	d -= 1
	s = input()
	a = s.split(' ')
	(T1, T2) = (int(a[0]), int(a[1]))
	Sdl.append(T1)
	maxT.append(T2)
S1 = sum(Sdl)
S2 = sum(maxT)
if ST >= S1 and ST <= S2:
	s = ''
	ds = ST - S1
	L = len(Sdl)
	for i in range(L):
		t = ds + Sdl[i]
		P = min(t, maxT[i])
		ds = t - P
		if i == L - 1:
			s += str(max(P, Sdl[i]))
		else:
			s += str(max(P, Sdl[i])) + ' '
	print('YES')
	print(s)
else:
	print('NO')


import sys
(d, sum_time) = sys.stdin.readline().strip().split()
lines = []
d = int(d)
sum_time = int(sum_time)
for i in range(0, d):
	lines.append(sys.stdin.readline().strip())
if d * 8 < sum_time:
	print('NO')
else:
	count_min = 0
	count_max = 0
	working_hours = []
	for day in lines:
		(min_time, max_time) = day.split()
		min_time = int(min_time)
		max_time = int(max_time)
		count_min += min_time
		count_max += max_time
		working_hours.append(min_time)
	if sum_time < count_min or sum_time > count_max:
		print('NO')
	else:
		print('YES')
		diff = sum_time - count_min
		for (i, index) in enumerate(lines):
			(min_time, max_time) = index.split()
			min_time = int(min_time)
			max_time = int(max_time)
			if max_time - min_time < diff:
				working_hours[i] = max_time
				diff = diff - (max_time - min_time)
			else:
				working_hours[i] = min_time + diff
				break
		numbers = ''
		for hour in working_hours:
			numbers = numbers + str(hour) + ' '
		print(numbers[:-1])


d = input().split(' ')
suma = int(d[1])
ListaMin = []
ListaMax = []
for i in range(int(d[0])):
	s = input().split(' ')
	Min = int(s[0])
	Max = int(s[1])
	ListaMin.append(Min)
	ListaMax.append(Max)
SumMin = sum(ListaMin)
SumMax = sum(ListaMax)
if suma < SumMin or suma > SumMax:
	print('NO')
else:
	print('YES')
	for i in range(int(d[0])):
		while SumMin < suma:
			if ListaMin[i] < ListaMax[i]:
				ListaMin[i] = ListaMin[i] + 1
				suma = suma - 1
			else:
				break
	for i in ListaMin:
		print(i, end=' ')


(days, time) = input().split()
days = int(days)
time = int(time)
min_time = []
max_time = []
sum = 0
result = []
for i in range(days):
	(a, b) = input().split()
	min_time.append(int(a))
	max_time.append(int(b))
	sum += min_time[i]
	result.append(min_time[i])
if sum == time:
	print('YES' + '\n')
	print(' '.join((str(s) for s in result)))
	quit()
elif sum > time:
	print('NO')
	quit()
for (i, data) in enumerate(min_time):
	diff = time - sum
	if data + diff > max_time[i]:
		result[i] = max_time[i]
		sum += result[i] - min_time[i]
	else:
		result[i] += diff
		sum += diff
if sum == time:
	print('YES')
	print(' '.join((str(s) for s in result)))
else:
	print('NO')


(d, sumTime) = map(int, input().split())
timeTable = []
(sumMin, sumMax) = (0, 0)
for _ in range(d):
	(minTime, maxTime) = map(int, input().split())
	sumMax += maxTime
	sumMin += minTime
	timeTable.append((minTime, maxTime))
if sumTime > sumMax or sumTime < sumMin:
	print('NO')
	exit(0)
finalTime = []
for i in timeTable:
	finalTime.append(i[0])
remTime = sumTime - sumMin
while remTime != 0:
	for i in range(d):
		if finalTime[i] + 1 <= timeTable[i][1]:
			finalTime[i] += 1
			remTime -= 1
		if remTime == 0:
			break
	if remTime == 0:
		break
print('YES')
for item in finalTime:
	print(item, end=' ')


(d, t) = map(int, input().split())
a = []
tl = 0
tr = 0
ans = []
for i in range(d):
	(x, y) = map(int, input().split())
	a.append([x, y])
	ans.append(x)
	tl += x
	tr += y
if tl > t or tr < t:
	print('NO')
else:
	print('YES')
	b = sum(ans)
	dd = t - b
	if b == t:
		print(*ans)
	else:
		for i in range(d):
			if a[i][1] - a[i][0] < dd:
				ans[i] -= a[i][0]
				ans[i] += a[i][1]
				dd = t - sum(ans)
			elif a[i][1] - a[i][0] >= dd:
				ans[i] += dd
				print(*ans)
				break


(d, ts) = map(int, input().split())
t = ts + 0
times = [0] * d
till = d
ai = [0] * d
bi = [0] * d
for i in range(d):
	(a, b) = map(int, input().split())
	ai[i] = a
	bi[i] = b
	if a == 0:
		times[i] = bi[i]
	else:
		t = b - a + 1
		times[i] = t
ais = sum(ai)
bis = sum(bi)
cp = times.copy()
c = 0
if ts >= ais and ts <= bis:
	for i in range(d):
		times[i] = ai[i]
		ts -= ai[i]
	if ts > 0:
		for i in range(d):
			if times[i] < bi[i]:
				temp = bi[i] - times[i]
				if temp > 0 and temp < ts:
					times[i] += temp
					ts -= temp
				elif temp > 0:
					times[i] += ts
					ts = 0
					break
		print('YES')
		for i in times:
			print(i, end=' ')
	else:
		print('YES')
		for i in times:
			print(i, end=' ')
else:
	print('NO')


inps = input().split()
days = int(inps[0])
total = int(inps[1])
studies = []
every = []
lsum = 0
msum = 0
current = 0
for d in range(days):
	details = input().split()
	least = int(details[0])
	most = int(details[1])
	lsum += least
	msum += most
	current += least
	every.append((least, most))
	studies.append(least)
if msum < total or lsum > total:
	print('NO')
elif lsum == total:
	print('YES')
	print(' '.join((str(x) for x in studies)))
elif msum == total:
	print('YES')
	print(' '.join((str(d[1]) for d in every)))
else:
	diff = total - current
	changed = True
	while diff != 0 and changed:
		changed = False
		for d in range(days):
			m = every[d][1]
			if studies[d] < m:
				studies[d] = min(studies[d] + 1, m)
				diff -= 1
				changed = True
				if diff == 0:
					break
	if diff == 0:
		print('YES')
		print(' '.join((str(x) for x in studies)))
	else:
		print('NO')


(n, d) = input().split()
(n, d) = (int(n), int(d))
minarr = []
maxarr = []
for i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	minarr.append(a)
	maxarr.append(b)
if d <= sum(maxarr) and d >= sum(minarr):
	print('YES')
	arr = []
	temp = d - sum(minarr)
	for i in range(n):
		add1 = min(temp, maxarr[i] - minarr[i])
		arr.append(minarr[i] + add1)
		temp -= add1
	print(*arr, sep=' ')
else:
	print('NO')


from typing import List, Tuple

def before_an_exam(days: int, total_time: int, reqs: List[Tuple[int, int]]) -> Tuple[str, str]:
	prospect = [i[1] for i in reqs]
	curr_sum = sum(prospect)
	curr_i = len(prospect) - 1
	while curr_sum > total_time and curr_i >= 0:
		sum_diff = curr_sum - total_time
		necessary = reqs[curr_i][1] - sum_diff
		if necessary >= reqs[curr_i][0] and necessary <= reqs[curr_i][1]:
			prospect[curr_i] = necessary
			curr_sum += necessary
			curr_sum -= reqs[curr_i][1]
		else:
			prospect[curr_i] = reqs[curr_i][0]
			curr_sum += reqs[curr_i][0]
			curr_sum -= reqs[curr_i][1]
		curr_i -= 1
	if sum(prospect) != total_time:
		return ['NO', '']
	return ['YES', ' '.join([str(i) for i in prospect])]
(d, sumTime) = map(int, input().split())
requirements = []
for _ in range(d):
	(mi, ma) = map(int, input().split())
	requirements.append((mi, ma))
res = before_an_exam(d, sumTime, requirements)
print(res[0])
if res[1] != '':
	print(res[1])


(d, t) = map(int, input().split())
a = []
zmin = zmax = m3 = 0
for i in range(d):
	(m1, m2) = map(int, input().split())
	zmin += m1
	zmax += m2
	m3 += m2 - m1
	a.append((m1, m2, m3))
if t not in range(zmin, zmax + 1):
	print('NO')
	exit()
print('YES')
delta = t - zmin
i = 0
m3 = a[i][2]
while m3 < delta:
	i += 1
	m3 = a[i][2]
ans = []
if i > 0:
	for k in range(i):
		ans.append(a[k][1])
ans.append(a[i][1] - a[i][2] + delta)
if i + 1 <= d - 1:
	for k in range(i + 1, d):
		ans.append(a[k][0])
print(*ans, sep=' ')


(d, t) = map(int, input().split())
(a, b) = ([], [])
tt = t
an = []
for i in range(d):
	(aa, bb) = map(int, input().split())
	t -= aa
	an.append(aa)
	a.append(aa)
	b.append(bb)
if t < 0:
	print('NO')
if t > 0:
	for i in range(d):
		if t == 0:
			break
		if t - (b[i] - a[i]) >= 0:
			t -= b[i] - a[i]
			an[i] = b[i]
		else:
			an[i] += t
			t = 0
	if t:
		print('NO')
if t == 0:
	print('YES')
	print(*an)


read = lambda : tuple(map(int, input().split()))
(d, sm) = read()
l = [read() for i in range(d)]
v1 = sum([v[0] for v in l])
v2 = sum([v[1] for v in l])
if v1 > sm or v2 < sm:
	print('NO')
else:
	print('YES')
	c = 0
	ans = [0] * d
	need = sm - v1
	for v in l:
		cv = min(need, v[1] - v[0])
		need -= cv
		print(v[0] + cv, end=' ')


(days, suma_total) = map(int, input().split())
(minimos, maximos) = ([], [])
for _ in range(days):
	(a, b) = map(int, input().split())
	minimos.append(a)
	maximos.append(b)
a = sum(minimos)
if a <= suma_total <= sum(maximos):
	print('YES')
	suma_total -= a
	res = []
	for (a, b) in zip(minimos, maximos):
		if b > suma_total + a:
			b = suma_total + a
		suma_total -= b - a
		res.append(str(b))
	print(' '.join(res))
else:
	print('NO')


n = 0
t = 0
a = [[]]

def main():
	global n, t, a
	b = []
	b = input().split()
	n = int(b[0])
	t = int(b[1])
	for i in range(0, n + 1):
		a.append([])
	for i in range(1, n + 1):
		b = input().split()
		a[i].append(int(b[0]))
		a[i].append(int(b[1]))
	sumMin = 0
	sumMax = 0
	for i in range(1, n + 1):
		sumMin += a[i][0]
		sumMax += a[i][1]
	if t < sumMin or t > sumMax:
		print('NO')
		return
	print('YES')
	for i in range(1, n + 1):
		for j in range(a[i][0], a[i][1] + 1):
			if t - j >= sumMin - a[i][0] and t - j <= sumMax - a[i][1]:
				t -= j
				sumMin -= a[i][0]
				sumMax -= a[i][1]
				(print(j),)
				break
main()


(d, sumTime) = input().split(' ')
d = int(d)
sumTime = int(sumTime)
sim = 0
Lmin = []
minimum = 0
maximum = 0
Lmax = []
for i in range(d):
	(minTime, maxTime) = input().split(' ')
	minTime = int(minTime)
	maxTime = int(maxTime)
	minimum += minTime
	maximum += maxTime
	Lmin.append(minTime)
	Lmax.append(maxTime)
diff = abs(sumTime - minimum)
if minimum <= sumTime <= maximum:
	print('YES')
	for i in range(d):
		if diff > Lmax[i] - Lmin[i]:
			diff -= Lmax[i] - Lmin[i]
			Lmin[i] = Lmax[i]
		else:
			Lmin[i] += diff
			diff = 0
			break
	for x in Lmin:
		print(x, end=' ')
else:
	print('NO')


def f():
	return list(map(int, input().split()))
(dt, tm) = f()
a = [f() for _ in range(dt)]
b = list(zip(*a))
zn = sum(b[0])
zx = sum(b[1])
if zn <= tm <= zx:
	print('YES')
	delta = tm - zn
	for (m1, m2) in a:
		today = min(m2 - m1, delta)
		delta -= today
		print(m1 + max(0, today), end=' ')
else:
	print('NO')


(d, sumall) = map(int, input().split())
minsum = 0
maxsum = 0
L = []
Ans = []
sumal = sumall
for i in range(d):
	(a, b) = map(int, input().split())
	minsum += a
	maxsum += b
	sumal -= a
	L.append(b - a)
	Ans.append(a)
if sumall >= minsum and sumall <= maxsum:
	print('YES')
	while sumal > 0:
		co = True
		index = 0
		for i in range(d):
			if L[i] > 0 and co:
				L[i] -= 1
				Ans[i] += 1
				co = False
				sumal -= 1
	for i in range(d):
		print(Ans[i], end=' ')
else:
	print('NO')


(d, h) = map(int, input().split())
day = [list(map(int, input().split(' '))) for line in range(d)]
min1 = 0
max1 = 0
rz = []
itog = []
for i in range(len(day)):
	min1 = int(min1 + int(day[i][0]))
	max1 = int(max1 + int(day[i][1]))
	rz.append(day[i][1] - day[i][0])
	itog.append(day[i][0])
if max1 < h or min1 > h:
	print('NO')
else:
	while h - min1 != 0 and d != 0:
		if h - min1 > 0:
			if h - min1 - rz[d - 1] >= 0:
				itog[d - 1] = day[d - 1][1]
				min1 = min1 + rz[d - 1]
			else:
				tmp_rz = rz[d - 1]
				while h - min1 - tmp_rz != 0 or tmp_rz < 0:
					tmp_rz = tmp_rz - 1
				if tmp_rz > 0:
					min1 = min1 + tmp_rz
					itog[d - 1] = itog[d - 1] + tmp_rz
			d = d - 1
	print('YES')
	for i in range(len(itog)):
		print(itog[i], end=' ')


(d, total) = map(int, input().split(' '))
(lowsum, highsum) = (0, 0)
(arl, arh) = ([], [])
for i in range(d):
	(low, high) = map(int, input().split(' '))
	lowsum += low
	arl.append(low)
	highsum += high
	arh.append(high)
if total >= lowsum and total <= highsum:
	print('YES')
	calc = total - lowsum
	for j in range(d):
		print(arl[j] + min(arh[j] - arl[j], calc), end=' ')
		calc -= min(arh[j] - arl[j], calc)
else:
	print('NO')


(d, s) = [int(i) for i in input().split()]
mm = [[int(j) for j in input().split()] for i in range(d)]
if sum((i[1] for i in mm)) >= s >= sum((i[0] for i in mm)):
	print('YES')
	s -= sum((i[0] for i in mm))
	for i in mm:
		if s > i[1] - i[0]:
			print(i[1], end=' ')
			s -= i[1] - i[0]
		else:
			print(i[0] + s, end=' ')
			s = 0
else:
	print('NO')


from sys import stdin, stdout

def main():
	(d, sumTime) = map(int, input().split(' '))
	l = []
	minnSum = 0
	maxxSum = 0
	a = []
	b = []
	for i in range(d):
		(minn, maxx) = map(int, input().split(' '))
		minnSum += minn
		maxxSum += maxx
		a.append(minn)
		b.append(maxx)
	if sumTime <= maxxSum and sumTime >= minnSum:
		stdout.write('YES\n')
		cur = sumTime
		out = []
		curSum = 0
		for i in range(d):
			x = a[i]
			curSum += x
			out.append(x)
		for i in range(d):
			if curSum >= sumTime:
				break
			if out[i] < b[i]:
				x = min(sumTime - curSum, b[i] - out[i])
				out[i] += x
				curSum += x
		stdout.write(' '.join(list(map(str, out))))
		stdout.write('\n')
	else:
		stdout.write('NO\n')
main()


inp = input().split()
days = int(inp[0])
total = int(inp[1])
currSum = 0

class Range:
	start = 0
	end = 0
arr = []
l = []
for i in range(days):
	inp = input().split()
	s1 = int(inp[0])
	s2 = int(inp[1])
	r = Range()
	r.start = s1
	r.end = s2
	arr.append(r)
i = 0
for x in arr:
	currSum += x.start
	l.append(str(x.start))
	if currSum > total:
		print('NO')
		exit()
	i += 1
i = 0
if currSum < total:
	for x in arr:
		tempTotal = currSum + x.end - x.start
		if tempTotal > total:
			val = total - currSum
			l[i] = str(val + x.start)
			currSum += val
			break
		elif tempTotal <= total:
			l[i] = str(x.end)
			currSum = tempTotal
		else:
			break
		i += 1
if currSum == total:
	print('YES')
	str1 = ' '.join(l)
	print(str1)
else:
	print('NO')


(days, th) = tuple(map(int, input().split()))
pd = list()
filler = list()
tc = 0
for i in range(days):
	pd.append(list(map(int, input().split())))
	filler.append(pd[i][0])
	tc += filler[i]
if tc > th:
	print('NO')
else:
	while True:
		checker = tc
		for (i, j) in enumerate(pd):
			if tc == th:
				print('YES')
				print(*filler)
				quit()
			if filler[i] < j[1]:
				tc += 1
				filler[i] += 1
		if checker == tc:
			print('NO')
			break


(d, sumTime) = map(int, input().split())
minTimel = []
maxTimel = []
for i in range(d):
	(minTime, maxTime) = map(int, input().split())
	minTimel.append(minTime)
	maxTimel.append(maxTime)
if d < 1 or d > 30 or sumTime < 0 or (sumTime > 240) or (sum(maxTimel) < sumTime) or (minTime > sumTime) or (sum(minTimel) > sumTime):
	print('NO')
else:
	print('YES')
	for i in range(d):
		time = min(minTimel[i] + sumTime - sum(minTimel), maxTimel[i])
		sumTime -= time - minTimel[i]
		print(str(time), end=' ')


(gun, saat) = input().split()
(gun, saat) = (int(gun), int(saat))
i = 0
min = 0
max = 0
minlist = list(range(40))
maxlist = list(range(40))
liste = list
boo = 0
printlist = list(range(gun))
while i < gun:
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	min += a
	max += b
	minlist[i] = a
	maxlist[i] = b
	i += 1
i = 0
if max < saat or min > saat:
	print('NO')
else:
	print('YES')
	boo = saat - min
	while i < gun:
		if boo >= maxlist[i] - minlist[i]:
			boo -= maxlist[i] - minlist[i]
			minlist[i] = maxlist[i]
		else:
			minlist[i] += boo
			boo = 0
		i += 1
	m = 0
	while m < gun:
		printlist[m] = minlist[m]
		m += 1
	print(*printlist)


import sys
input = sys.stdin.readline

def inlt():
	return list(map(int, input().split()))
pairs = []
doable = False

def is_doable(pairs, totalHours):
	maxHours = 0
	minHours = 0
	for pair in pairs:
		maxHours += pair[1]
		minHours += pair[0]
	return maxHours >= totalHours and minHours <= totalHours

def scheduler(pairs, totalHours):
	schedsum = sum([int(day) for day in schedule])
	i = 0
	while schedsum < totalHours:
		while schedule[i] < pairs[i][1] and schedsum < totalHours:
			schedule[i] += 1
			schedsum += 1
		i += 1
	return ' '.join([str(day) for day in schedule])
(days, totalHours) = inlt()
for day in range(days):
	pairs.append(inlt())
schedule = [pair[0] for pair in pairs]
doable = is_doable(pairs, totalHours)
answer = scheduler(pairs, totalHours) if doable else ''
print('YES\n' + answer if doable else 'NO')


import sys
(d, sum_time) = [int(x) for x in input().split(' ')]
max_min_time = []
for i in range(d):
	(min_time, max_time) = [int(x) for x in input().split(' ')]
	max_min_time.append({'min_time': min_time, 'max_time': max_time, 'difference': max_time - min_time})
sum_of_max_time = sum([x['max_time'] for x in max_min_time])
sum_of_min_time = sum([x['min_time'] for x in max_min_time])
if sum_of_max_time < sum_time or sum_of_min_time > sum_time:
	print('NO')
else:
	print('YES')
	remain_time = sum_time - sum_of_min_time
	time_series = []
	for i in range(d):
		if remain_time <= max_min_time[i]['difference']:
			time_series.append(str(max_min_time[i]['min_time'] + remain_time))
			remain_time = 0
		else:
			time_series.append(str(max_min_time[i]['max_time']))
			remain_time -= max_min_time[i]['difference']
	print(' '.join(time_series))


import sys
mins = []
maxs = []
info = []
first = True
for line in sys.stdin.readlines():
	if first == True:
		info.append(int(line.strip().split()[0]))
		info.append(int(line.strip().split()[1]))
		first = False
	else:
		mins.append(int(line.strip().split()[0]))
		maxs.append(int(line.strip().split()[1]))
while sum(mins) < int(info[1]):
	for i in range(len(mins)):
		if sum(mins) < int(info[1]) and mins[i] < maxs[i]:
			mins[i] += 1
	if sum(mins) == sum(maxs):
		break
if sum(mins) == int(info[1]):
	print('YES')
	print(' '.join(list(map(str, mins))))
else:
	print('NO')


def main():
	m = list(map(int, input().split()))
	(d, sum_time) = (m[0], m[1])
	(max_time, min_time) = (0, 0)
	(min_m, max_m) = ([], [])
	for i in range(d):
		m = list(map(int, input().split()))
		min_time += m[0]
		max_time += m[1]
		min_m.append(m[0])
		max_m.append(m[1])
	if min_time <= sum_time <= max_time:
		print('YES')
		i = 0
		while min_time < sum_time:
			if min_m[i] < max_m[i]:
				min_m[i] += 1
				min_time += 1
			else:
				i += 1
		for i in range(d):
			print(min_m[i], end=' ')
	else:
		print('NO')
main()


(d, sumTime) = map(int, input().split())
minTime = []
maxTime = []
for i in range(d):
	(a, b) = map(int, input().split())
	minTime += [a]
	maxTime += [b]
if sum(minTime) <= sumTime <= sum(maxTime):
	print('YES')
	sumTime -= sum(minTime)
	for i in range(d):
		print(minTime[i] + min(sumTime, maxTime[i] - minTime[i]))
		sumTime = max(0, sumTime - maxTime[i] + minTime[i])
else:
	print('NO')


(days, hours) = map(int, input().split())
total_hrs = []
left_hours = 0
min_time = []
max_time = []
for i in range(days):
	time = list(map(int, input().split()))
	total_hrs.append(time)
	min_time.append(total_hrs[i][0])
	max_time.append(total_hrs[i][1])
lflst = []
if sum(min_time) <= hours <= sum(max_time):
	print('YES')
	lf = hours - sum(min_time)
	lflst.append(lf)
	for i in range(days):
		if min_time[i] == max_time[i]:
			lflst.append(lf)
			continue
		elif max_time[i] - min_time[i] <= lf:
			lf -= max_time[i] - min_time[i]
			min_time[i] = max_time[i]
			lflst.append(lf)
		elif max_time[i] - min_time[i] > lf:
			min_time[i] += lf
			lf -= lf
		if lf == 0:
			break
	print(' '.join(map(str, min_time)))
else:
	print('NO')


(q, num) = map(int, input().split())
(a, b) = ([], [])
for _ in range(q):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
(min_time, max_time) = (sum(a), sum(b))
if num < min_time or num > max_time:
	print('NO')
else:
	print('YES')
	l = b.copy()
	tot = max_time
	i = len(b) - 1
	x = b[i]
	diff = max_time - num
	while diff != 0:
		if x == a[i]:
			i -= 1
			x = b[i]
		else:
			diff -= 1
			x -= 1
			l[i] -= 1
	print(*l)


def vivod(fin_list):
	for elem in fin_list:
		print(elem[0], end=' ')

def Fin_viv(sum_min, sumTime, all_h):
	for q in all_h:
		if sum_min == sumTime:
			print('YES')
			vivod(all_h)
			return
		while q[0] < q[1]:
			q[0] += 1
			sum_min += 1
			if sum_min == sumTime:
				print('YES')
				vivod(all_h)
				return
(d, sumTime) = input().split()
(d, sumTime) = (int(d), int(sumTime))
if sumTime / d >= 24:
	print('NO')
else:
	deviation = 0
	sum_min = 0
	all_h = []
	temp_list = []
	for i in range(d):
		(minTime, maxTime) = input().split()
		temp_list.append(int(minTime))
		temp_list.append(int(maxTime))
		deviation += temp_list[1] - temp_list[0]
		sum_min += temp_list[0]
		all_h.append([int(j) for j in temp_list])
		temp_list.clear()
	if sumTime < sum_min or sumTime > sum_min + deviation:
		print('NO')
	Fin_viv(sum_min, sumTime, all_h)


(n, s) = map(int, input().split())
v = []
for ii in range(n):
	x = list(map(int, input().split()))
	v.append(x)
ans = 0
q = []
for t in v:
	q.append(t[0])
sx = sum(q)
if sx > s:
	print('NO')
elif sx == s:
	print('YES')
	print(*q)
else:
	s -= sx
	for t in range(n):
		if s == 0:
			break
		z = v[t][1] - v[t][0]
		if z <= s:
			s -= z
			q[t] += z
		else:
			y = z - s
			q[t] += y
			s = 0
			break
	if s == 0:
		print('YES')
		print(*q)
	else:
		print('NO')


import sys

def main():
	(d, t) = [int(i) for i in sys.stdin.readline().split()]
	mm = [[int(i) for i in sys.stdin.readline().split()] for i in range(d)]
	r = [mi[0] for mi in mm]
	t -= sum(r)
	if t < 0:
		print('NO')
		return
	for (i, mi) in enumerate(mm):
		p = min(t, mi[1] - mi[0])
		r[i] += p
		t -= p
	if t > 0:
		print('NO')
		return
	print('YES')
	print(' '.join((str(i) for i in r)))
main()


(d, sumTime) = [int(x) for x in input().split()]
s = 0
s_1 = 0
sums = 0
limit = [[int(x) for x in input().split()] for x in range(d)]
for x in limit:
	s += x[1]
	s_1 += x[0]
if s >= sumTime and s_1 <= sumTime:
	hours = [x[0] for x in limit]
	sums = s_1
	if s_1 == sumTime:
		print('YES')
		print(*hours, sep=' ')
	elif s == sumTime:
		hours = [x[1] for x in limit]
		print('YES')
		print(*hours, sep=' ')
	else:
		for x in range(len(limit)):
			hours[x] += limit[x][1] - limit[x][0]
			sums += limit[x][1] - limit[x][0]
			if sums > sumTime:
				hours[x] = hours[x] - (sums - sumTime)
				print('YES')
				print(*hours, sep=' ')
				break
			if sums == sumTime:
				print('YES')
				print(*hours, sep=' ')
				break
else:
	print('NO')


def printarray(array):
	for i in range(len(array)):
		print(array[i], end=' ')

def con4probB():
	(d, sumtime) = map(int, input().split())
	minTime = []
	maxTime = []
	minSum = 0
	maxSum = 0
	sol = []
	for i in range(d):
		(num1, num2) = map(int, input().split())
		minTime.append(num1)
		maxTime.append(num2)
		minSum += num1
		maxSum += num2
	sol = minTime.copy()
	solsum = sum(minTime)
	if minSum > sumtime:
		print('NO')
		return
	elif maxSum < sumtime:
		print('NO')
		return
	else:
		print('YES')
		for i in range(d):
			if solsum + (maxTime[i] - minTime[i]) < sumtime:
				sol[i] = maxTime[i]
				solsum += maxTime[i] - minTime[i]
			elif solsum + (maxTime[i] - minTime[i]) == sumtime:
				sol[i] = minTime[i] + (maxTime[i] - minTime[i])
				printarray(sol)
				return
			else:
				x = sumtime - solsum
				sol[i] = minTime[i] + x
				printarray(sol)
				return
con4probB()


(d, sumTime) = map(int, input().split())
ma = 0
mi = 0
maxs = [0] * d
mins = [0] * d
for i in range(d):
	(mins[i], maxs[i]) = map(int, input().split())
	ma += maxs[i]
	mi += mins[i]
if ma < sumTime:
	print('NO')
elif mi > sumTime:
	print('NO')
else:
	print('YES')
	sumTime -= mi
	for i in range(d):
		print(min(maxs[i], mins[i] + sumTime), end=' ')
		sumTime -= min(maxs[i] - mins[i], sumTime)


(d, s) = map(int, input().split())
maxi = []
mini = []
for i in range(d):
	(a, b) = map(int, input().split())
	mini.append(a)
	maxi.append(b)
if s < sum(mini) or s > sum(maxi):
	print('NO')
else:
	print('YES')
	a = 0
	while sum(mini) < s:
		if a == d:
			a = 0
		if mini[a] + 1 <= maxi[a]:
			mini[a] += 1
		a += 1
	for i in mini:
		print(i, end=' ')


(d, sumTime) = map(int, input().split())
ans = [0] * d
arr = []
for i in range(d):
	(x, y) = map(int, input().split())
	arr.append([x, y])
c = 0
xx = sumTime
if sumTime == 0:
	print('YES')
	for i in range(d):
		print(0, end=' ')
	exit()
f = 1
ans = [0] * d
for i in range(d):
	if xx <= 0 and i != d - 1:
		f = 0
		break
	if arr[i][0] > xx:
		f = 0
		break
	else:
		xx -= arr[i][0]
		ans[i] = arr[i][0]
g = 0
while xx > 0:
	c = 0
	for i in range(d):
		if ans[i] < arr[i][1]:
			ans[i] += 1
			c += 1
		if xx == c:
			g = 1
			break
	if c == 0:
		break
	if g == 1:
		break
	xx -= c
s = sum(ans)
if s < sumTime:
	f = 0
if f == 0:
	print('NO')
else:
	print('YES')
	for i in ans:
		print(i, end=' ')
	print()


def beforeExam(d, sumTime, minTime, maxTime):
	if sumTime < sum(minTime) or sumTime > sum(maxTime):
		print('NO')
	else:
		print('YES')
		li = []
		for i in range(d):
			li.append(minTime[i])
		sumTime = sumTime - sum(minTime)
		j = 0
		while sumTime != 0:
			if sumTime >= maxTime[j] - minTime[j]:
				li[j] = maxTime[j]
				sumTime = sumTime - (maxTime[j] - minTime[j])
			else:
				li[j] = li[j] + sumTime
				sumTime = 0
			j += 1
		print(*li)
(d, sumTime) = [int(x) for x in input().split()]
minTime = []
maxTime = []
for i in range(d):
	minMax = input().split()
	minTime.append(int(minMax[0]))
	maxTime.append(int(minMax[1]))
beforeExam(d, sumTime, minTime, maxTime)


sum_minimum = 0
sum_maximum = 0
actual_sum = 0

def get_user_input(minimum, maximum):
	global actual_sum
	global sum_maximum
	global sum_minimum
	interval_info = input('').split()
	d = int(interval_info[0])
	actual_sum = int(interval_info[1])
	for i in range(0, d):
		minimum_maximum = input('').split()
		x_minimum = int(minimum_maximum[0])
		sum_minimum += x_minimum
		minimum.append(x_minimum)
		x_maximum = int(minimum_maximum[1])
		sum_maximum += x_maximum
		maximum.append(x_maximum)
	return d

def is_sum_valid():
	if sum_minimum <= actual_sum <= sum_maximum:
		return True
	return False

def interval_schedule(minimum, maximum):
	interval = []
	left_over = actual_sum - sum_minimum
	left = 0
	for i in range(0, len(maximum)):
		if left_over > 0:
			interval.append(min(minimum[i] + left_over, maximum[i]))
		else:
			break
		left_over -= maximum[i] - minimum[i]
		left += 1
	for i in range(left, len(minimum)):
		interval.append(minimum[i])
	return interval
minimum = []
maximum = []
d = get_user_input(minimum, maximum)
if is_sum_valid():
	print('YES')
	print(*interval_schedule(minimum, maximum))
else:
	print('NO')


__author__ = 'Rajan'
(d, sumtime) = map(int, input().split())
l = []
lsum = 0
for i in range(d):
	l.append(list(map(int, input().split())))
ans = []
for i in range(d):
	lsum += l[i][0]
	ans.append(l[i][0])
if lsum <= sumtime:
	j = 0
	while j < d and lsum <= sumtime:
		toAdd = min(l[j][1] - l[j][0], sumtime - lsum)
		ans[j] += toAdd
		lsum += toAdd
		j += 1
	if lsum < sumtime:
		print('NO')
	else:
		print('YES')
		res = ''
		for i in range(d):
			res += str(ans[i]) + ' '
		print(res)
else:
	print('NO')


(d, sumtime) = map(int, input().split())
mi_time = []
ma_time = []
for _ in range(d):
	(mintime, maxtime) = map(int, input().split())
	mi_time.append(mintime)
	ma_time.append(maxtime)
a = sum(mi_time)
b = sum(ma_time)
if a <= sumtime and sumtime <= b:
	print('YES')
	for i in range(d):
		t = min(mi_time[i] + sumtime - a, ma_time[i])
		print(t, end=' ')
		sumtime -= t - mi_time[i]
else:
	print('NO')


(d, time) = map(int, input().split())
test1 = []
test2 = []
for i in range(0, d):
	(time1, time2) = map(int, input().split())
	test1.append(time1)
	test2.append(time2)
sum1 = sum(test1)
sum2 = sum(test2)
if sum1 > time or sum2 < time:
	print('NO')
else:
	time -= sum1
	i = 0
	while time > 0:
		time += test1[i] - test2[i]
		test1[i] = test2[i]
		i += 1
	test1[i - 1] += time
	print('YES')
	for value in test1:
		print(value, end=' ')


(d, SumTime) = map(int, input().split())
minTime = [0] * d
maxTime = [0] * d
for i in range(d):
	(minTime[i], maxTime[i]) = map(int, input().split())
if sum(minTime) <= SumTime <= sum(maxTime):
	print('YES')
	Time = minTime[:]
	k = SumTime - sum(minTime)
	for i in range(d):
		dTime = min(maxTime[i] - minTime[i], k)
		k -= dTime
		Time[i] += dTime
	print(' '.join(map(str, Time)))
else:
	print('NO')


(n, s) = map(int, input().split())
l = []
ll = []
for _ in range(n):
	(mi, ma) = map(int, input().split())
	l += [ma]
	ll += [mi]
if sum(ll) > s:
	print('NO')
else:
	ss = s - sum(ll)
	i = 0
	while sum(ll) < s and ll != l:
		if ll[i] == l[i]:
			i += 1
			continue
		t = min(ss, l[i] - ll[i])
		ss -= t
		ll[i] += t
	if sum(ll) != s:
		print('NO')
	else:
		print('YES')
		print(' '.join(map(str, ll)))


(n, s) = map(int, input().split())
max_list = []
min_list = []
for i in range(n):
	(m1, m2) = map(int, input().split())
	max_list.append(m2)
	min_list.append(m1)
if s < sum(min_list) or s > sum(max_list):
	print('NO')
else:
	s = s - sum(min_list)
	for i in range(n):
		if s - (max_list[i] - min_list[i]) <= 0:
			min_list[i] = min_list[i] + s
			break
		s = s - (max_list[i] - min_list[i])
		min_list[i] = max_list[i]
	print('YES')
	ans = str(min_list[0])
	for i in range(1, n):
		ans = ans + ' ' + str(min_list[i])
	print(ans)


(n, s) = map(int, input().split())
M = [list(map(int, input().split())) for i in range(n)]
l = []
S = 0
for i in range(n):
	S = S + M[i][0]
	l.append(M[i][0])
if s - S < 0:
	print('NO')
	exit()
else:
	s = s - S
for i in range(n):
	v = M[i][1] - M[i][0]
	c = 1
	if s - v == 0:
		l[i] = M[i][1]
		s = 0
		break
	if s - v < 0:
		l[i] = l[i] - s + v
		s = s - v
		break
	if s - v > 0:
		l[i] = M[i][1]
		s = s - v
t = 0
if s <= 0:
	print('YES')
	print(*l)
else:
	print('NO')


def main():
	(d, sumTime) = map(int, input().split())
	(mi, ma) = ([], [])
	for _ in range(d):
		(a, b) = map(int, input().split())
		mi.append(a)
		ma.append(b)
	a = sum(mi)
	if a <= sumTime <= sum(ma):
		print('YES')
		sumTime -= a
		res = []
		for (a, b) in zip(mi, ma):
			if b > sumTime + a:
				b = sumTime + a
			sumTime -= b - a
			res.append(str(b))
		print(' '.join(res))
	else:
		print('NO')
main()


v = [int(x) for x in input().split()]
max_t = list()
min_t = list()
for vals in range(v[0]):
	(a, b) = map(int, input().split())
	max_t.append(b)
	min_t.append(a)
if v[1] > sum(max_t) or v[1] < sum(min_t):
	print('NO')
else:
	print('YES')
	need = v[1] - sum(min_t)
	for i in range(v[0]):
		possible_time = max_t[i] - min_t[i]
		t = min(possible_time, need)
		print(min_t[i] + t, end=' ')
		need -= t


import copy
(totalDays, sumTime) = [int(w) for w in input().split()]
minTimes = []
maxTimes = []
for d in range(totalDays):
	(minTime, maxTime) = [int(w) for w in input().split()]
	minTimes.append(minTime)
	maxTimes.append(maxTime)
if sumTime < sum(minTimes) or sumTime > sum(maxTimes):
	print('NO')
else:
	print('YES')
	result = copy.deepcopy(minTimes)
	sumTime -= sum(minTimes)
	i = 0
	while sumTime > 0:
		if sumTime < maxTimes[i] - minTimes[i]:
			result[i] += sumTime
			sumTime = 0
		else:
			result[i] = maxTimes[i]
			sumTime -= maxTimes[i] - minTimes[i]
		i += 1
	for assignment in result[:-1]:
		print(assignment, end=' ')
	print(result[-1])


(d, noh) = map(int, input().split())
dys = []
mis = 0
mxs = 0
for _ in range(d):
	(m, x) = map(int, input().split())
	dys.append([m, x])
	mis += m
	mxs += x
if noh < mis or noh > mxs:
	print('NO')
else:
	print('YES')
	ft = []
	noh -= mis
	for i in dys:
		if noh == 0:
			break
		else:
			mii = min(i[1] - i[0], noh)
			i[0] += mii
			noh -= mii
	for i in dys:
		print(i[0], end=' ')


(d, smtime) = map(int, input().split())
smin = 0
smax = 0
lst = []
for i in range(d):
	(mn, mx) = map(int, input().split())
	smin += mn
	smax += mx
	lst.append([mn, mx])
if smin > smtime or smax < smtime:
	print('NO')
else:
	smtime -= smin
	i = 0
	while smtime != 0:
		if i == len(lst):
			i = 0
		if lst[i][0] != lst[i][1]:
			lst[i][0] += 1
			smtime -= 1
		i += 1
	print('YES')
	for i in range(len(lst)):
		print(lst[i][0], end=' ')


import sys
inp = input().split(' ')
amtDays = int(inp[0])
sumTime = int(inp[1])
days = []
dayAmt = []
totalMin = 0
totalMax = 0
while amtDays > 0:
	inp = input().split(' ')
	days.append((int(inp[0]), int(inp[1])))
	dayAmt.append(0)
	amtDays = amtDays - 1
	totalMin += int(inp[0])
	totalMax += int(inp[1])
if sumTime > totalMax or sumTime < totalMin:
	print('NO')
	sys.exit()
else:
	for i in range(len(days)):
		dayAmt[i] += days[i][0]
		sumTime -= days[i][0]
	curDay = 0
	while sumTime > 0:
		if dayAmt[curDay] < days[curDay][1]:
			dayAmt[curDay] += 1
			sumTime -= 1
		curDay += 1
		if curDay >= len(days):
			curDay = 0
	print('YES')
	for d in dayAmt:
		print(d, end=' ')
	sys.exit()


from sys import stdin
line = list(map(int, input().split()))
days = line[0]
sum = line[1]
upper = []
lower = []
max = 0
min = 0
for i in range(days):
	times = list(map(int, input().split()))
	min += times[0]
	max += times[1]
	lower.append(times[0])
	upper.append(times[1])
if max < sum or min > sum:
	print('NO')
else:
	print('YES')
	need = sum - min
	for i in range(days):
		if need == 0:
			print(lower[i], end=' ')
		else:
			curr = upper[i] - lower[i]
			if need > curr:
				print(upper[i], end=' ')
				need -= curr
			else:
				print(lower[i] + need, end=' ')
				need = 0


(d, sumTime) = tuple(map(int, input().split()))
(minT, maxT) = ([0] * d, [0] * d)
for i in range(d):
	(minT[i], maxT[i]) = tuple(map(int, input().split()))
(sumMinT, sumMaxT) = (sum(minT), sum(maxT))
if sumMinT > sumTime:
	print('NO')
elif sumMaxT < sumTime:
	print('NO')
else:
	print('YES')
	result = []
	extraT = sumTime - sumMinT
	for i in range(d):
		if extraT > 0:
			curMaxExtra = maxT[i] - minT[i]
			curExtra = curMaxExtra if curMaxExtra < extraT else extraT
			result.append(str(minT[i] + curExtra))
			extraT -= curExtra
		else:
			result.append(str(minT[i]))
	print(' '.join(result))


(d, st) = [int(i) for i in input().split()]
t = [0] * d
(smax, smin) = (0, 0)
for i in range(d):
	t[i] = [int(i) for i in input().split()]
	smax += t[i][1]
	smin += t[i][0]
if st < smin or st > smax:
	print('NO')
	exit()
i = d - 1
while smax > st:
	if t[i][1] - 1 >= t[i][0]:
		t[i][1] -= 1
		smax -= 1
	else:
		i -= 1
print('YES')
print(' '.join((str(i[1]) for i in t)))


def mi():
	return map(int, input().split())
(d, t) = mi()
a = [0] * d
q = a.copy()
w = a.copy()
for i in range(d):
	(q[i], w[i]) = mi()
	a[i] = q[i]
if sum(q) > t or sum(w) < t:
	print('NO')
	exit(0)
diff = t - sum(q)
for i in range(len(a)):
	if diff == 0:
		break
	if a[i] < w[i]:
		new = min(w[i], a[i] + diff)
		old = a[i]
		a[i] = new
		diff -= new - old
if diff == 0:
	print('YES')
	print(*a)
else:
	print('NO')


import sys
import math
(d, sumTime) = [int(x) for x in sys.stdin.readline().split()]
a1 = [0] * d
a2 = [0] * d
vsum = 0
for i in range(d):
	(x, y) = [int(x) for x in sys.stdin.readline().split()]
	a2[i] = y - x
	a1[i] = x
	vsum += x
k = sumTime - vsum
if k < 0:
	print('NO')
	exit()
for i in range(d):
	if k > a2[i]:
		a1[i] += a2[i]
		k -= a2[i]
	else:
		a1[i] += k
		k = 0
		break
if k > 0:
	print('NO')
else:
	print('YES')
	print(' '.join((str(x) for x in a1)))


def getints(str):
	return list(map(int, str.split(' ')))
(d, sumTime) = getints(input())
minTime = [0 for x in range(d)]
maxTime = [0 for x in range(d)]
for i in range(d):
	(minTime[i], maxTime[i]) = getints(input())
minsum = sum(minTime)
maxsum = sum(maxTime)
if minsum <= sumTime <= maxsum:
	print('YES')
	extraTime = sumTime - minsum
	for i in range(d):
		if maxTime[i] - minTime[i] > extraTime:
			print(minTime[i] + extraTime, end=' ')
			extraTime = 0
		else:
			print(maxTime[i], end=' ')
			extraTime -= maxTime[i] - minTime[i]
else:
	print('NO')


(d, sumS) = map(int, input().split())
(minS, maxS) = (0, 0)
i = 0
days = []
ans = []
while i < d:
	days.append(list(map(int, input().split())))
	i += 1
for i in days:
	minS += i[0]
	maxS += i[1]
if sumS not in range(minS, maxS + 1):
	print('NO')
else:
	less = maxS - sumS
	i = 0
	while i < d:
		if less >= days[i][1] - days[i][0]:
			ans.append(str(days[i][0]))
			less -= days[i][1] - days[i][0]
		else:
			ans.append(str(days[i][1] - less))
			less = 0
		i += 1
	print('YES')
	print(' '.join(ans))


t = input()
temp = t.split()
d = int(temp[0])
sumTime = int(temp[1])
minTime = []
maxTime = []
for i in range(d):
	s = input()
	temp = s.split()
	minTime.append(int(temp[0]))
	maxTime.append(int(temp[1]))
minSum = sum(minTime)
maxSum = sum(maxTime)
if minSum > sumTime or sumTime > maxSum:
	print('NO')
else:
	print('YES')
	neededTime = sumTime - minSum
	for i in range(d - 1):
		if maxTime[i] - minTime[i] < neededTime:
			print(maxTime[i], end=' ')
			neededTime = neededTime - (maxTime[i] - minTime[i])
		else:
			print(minTime[i] + neededTime)
			neededTime = 0
	print(minTime[d - 1] + neededTime)


(n, total) = map(int, input().split())
list1 = []
for _ in range(n):
	a = tuple(map(int, input().split()))
	list1.append(a)
ans = [a for (a, b) in list1]
s = sum(ans)
i = 0
while s < total and i < n:
	if s < total:
		ans[i] = list1[i][1]
		s = s - list1[i][0] + list1[i][1]
		temp = list1[i][1]
	if s > total:
		how_much = s - total
		temp1 = ans[i]
		ans[i] = temp - how_much
		s = s - temp1 + ans[i]
	i += 1
if s == total:
	print('YES')
	for i in ans:
		print(i, end=' ')
else:
	print('NO')


(n, sumtime) = map(int, input().split())
(mintime, maxtime) = ([0] * n, [0] * n)
for i in range(n):
	(mintime[i], maxtime[i]) = map(int, input().split())
if sumtime < sum(mintime) or sumtime > sum(maxtime):
	print('NO')
else:
	diff = sumtime - sum(mintime)
	i = 0
	while diff > 0 and i < n:
		curr = mintime[i]
		mintime[i] += min(diff, maxtime[i] - mintime[i])
		diff -= mintime[i] - curr
		i += 1
	print('YES')
	for i in mintime:
		print(i, end=' ')


(d, s) = [int(i) for i in input().split()]
minTime = []
maxTime = []
for i in range(d):
	(m, n) = [int(i) for i in input().split()]
	minTime.append(m)
	maxTime.append(n)
if sum(minTime) <= s and s <= sum(maxTime):
	print('YES')
	t = s - sum(minTime)
	i = d - 1
	j = 0
	while t > 0:
		t = t - (maxTime[i] - minTime[i])
		i = i - 1
		j = j + 1
	if j > 0:
		i = i + 1
		a = maxTime[i] + t
	else:
		a = minTime[i]
	T = []
	if i > 0:
		for j in minTime[:i]:
			T.append(j)
	T.append(a)
	if i + 1 < d:
		for j in maxTime[i + 1:]:
			T.append(j)
	T_text = str(T[0])
	for x in T[1:]:
		T_text = T_text + ' ' + str(x)
	print(T_text)
else:
	print('NO')


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(d, s) = iia()
num = []
low = high = 0
for _ in range(d):
	(a, b) = iia()
	num.append([a, b])
	low += a
	high += b
if s < low or s > high:
	print('NO')
else:
	print('YES')
	extra = (s - low) // d
	remain = (s - low) % d
	ans = []
	for i in num:
		if i[0] + extra <= i[1]:
			ans.append(i[0] + extra)
		else:
			remain += i[0] + extra - i[1]
			ans.append(i[1])
		if remain > 0:
			if ans[-1] + remain <= i[1]:
				ans[-1] += remain
				remain = 0
			else:
				remain = remain - (i[1] - ans[-1])
				ans[-1] = i[1]
	if remain > 0:
		for i in range(len(ans)):
			if ans[i] + remain <= num[i][1]:
				ans[i] += remain
				break
			else:
				remain = remain - (num[i][1] - ans[i])
				ans[i] = num[i][1]
	print(*ans)


def print_(x):
	for i in x:
		print(i, end=' ')
	print()

def main():
	test = 0
	(d, sumTime) = input().split()
	(d, sumTime) = (int(d), int(sumTime))
	req = sumTime
	ret = 0
	(minSum, maxSum) = ([], [])
	for days in range(d):
		(minTime, maxTime) = input().split()
		(minTime, maxTime) = (int(minTime), int(maxTime))
		minSum += [minTime]
		maxSum += [maxTime]
	MAX = sum(maxSum)
	MIN = sum(minSum)
	if MAX >= sumTime and MIN <= sumTime:
		print('YES')
		for i in range(d):
			n = min(maxSum[i], minSum[i] + sumTime - MIN)
			if i + 1 < d:
				print(n, end=' ')
			else:
				print(n)
			sumTime -= n - minSum[i]
	else:
		print('NO')
main()


(d, sumTime) = map(int, input().split())
maxtList = []
mintList = []
total = 0
for x in range(d):
	(mint, maxt) = map(int, input().split())
	total += mint
	mintList.append(mint)
	maxtList.append(maxt)
if total > sumTime:
	print('NO')
else:
	i = 0
	while i <= d - 1 and sumTime != total:
		consumed = maxtList[i] - mintList[i]
		if consumed > sumTime - total:
			consumed = sumTime - total
		total += consumed
		mintList[i] += consumed
		i += 1
	if sumTime == total:
		print('YES')
		print(' '.join([str(x) for x in mintList]))
	else:
		print('NO')


from collections import deque
(d, sumTime) = map(int, input().split())
minmax = []
smin = 0
smax = 0
for i in range(d):
	(mi, ma) = map(int, input().split())
	minmax.append((mi, ma, i))
	smin += mi
	smax += ma
if smin <= sumTime <= smax:
	h = list()
	need_more = True
	print('YES')
	for i in range(d - 1, -1, -1):
		smin -= minmax[i][0]
		smax -= minmax[i][1]
		if minmax[i][0] <= sumTime - smin <= minmax[i][1]:
			h.append(sumTime - smin)
			smin = sumTime
			break
		elif minmax[i][0] <= sumTime - smax <= minmax[i][1]:
			h.append(sumTime - smax)
			smax = sumTime
			break
		else:
			h.append(minmax[i][1])
			smin += minmax[i][1]
			smax += minmax[i][1]
	if smin == sumTime:
		for i in range(0, d - len(h)):
			print(minmax[i][0], end=' ')
	else:
		for i in range(0, d - len(h)):
			print(minmax[i][1], end=' ')
	for i in range(len(h) - 1, 0, -1):
		print(h[i], end=' ')
	print(h[0])
else:
	print('NO')


import sys
import math
import bisect
import re

def solve(A, m):
	n = len(A)
	B = [0] * n
	for i in range(n):
		B[i] = A[i][0]
	for i in range(n):
		while sum(B) < m and B[i] < A[i][1]:
			B[i] += 1
	if sum(B) != m:
		return None
	return B

def main():
	(n, m) = map(int, input().split())
	A = []
	for i in range(n):
		A.append(list(map(int, input().split())))
	ans = solve(A, m)
	if ans:
		print('YES')
		print(' '.join(list((str(a) for a in ans))))
	else:
		print('NO')
main()


inp = list(map(int, input().split()))
d = inp[0]
sumT = inp[1]
minT = [0] * d
maxT = [0] * d
ans = [0] * d
for i in range(d):
	inp = list(map(int, input().split()))
	minT[i] = inp[0]
	maxT[i] = inp[1]
	ans[i] += minT[i]
	sumT -= minT[i]
	maxT[i] -= minT[i]
if sumT < 0:
	print('NO')
else:
	for i in range(d):
		if maxT[i] <= sumT:
			ans[i] += maxT[i]
			sumT -= maxT[i]
		else:
			ans[i] += sumT
			sumT = 0
			break
	if sumT != 0:
		print('NO')
	else:
		print('YES')
		print(*ans)


import math
import random
from collections import defaultdict
mod = 1000000007
r1 = lambda : int(input())
rm = lambda : map(int, input().split())
rms = lambda : map(str, input().split())
rls = lambda : list(rm())

def solve():
	(n, total) = rm()
	s1 = 0
	s2 = 0
	ls = []
	ans = []
	for i in range(n):
		ls.append(rls())
		x = min(ls[i])
		ans.append(x)
		s1 += max(ls[i])
		s2 += x
	if total >= s2 and total <= s1:
		for i in range(n):
			if s2 + max(ls[i]) <= total:
				s2 = s2 + max(ls[i]) - min(ls[i])
				ans[i] = max(ls[i])
			elif s2 == total:
				break
			elif ans[i] + total - s2 > max(ls[i]):
				continue
			else:
				ans[i] += total - s2
				break
		print('YES')
		print(*ans)
	else:
		print('NO')

def def_value():
	return 'nan'
solve()


(d, s) = map(int, input().split())
durations = []
misum = 0
masum = 0
for i in range(d):
	(mi, ma) = map(int, input().split())
	durations.append((mi, ma))
	misum += mi
	masum += ma
if s >= misum and s <= masum:
	print('YES')
	i = 0
	ans = []
	while s > misum and i < d:
		if s - durations[i][1] >= misum - durations[i][0]:
			s -= durations[i][1]
			misum -= durations[i][0]
			ans.append(durations[i][1])
			i += 1
		elif s - durations[i][0] > misum - durations[i][0]:
			ans.append(durations[i][1] - s + misum)
			s -= durations[i][1] - s + misum
			misum -= durations[i][0]
			i += 1
			break
		else:
			break
	while i < d:
		ans.append(durations[i][0])
		s -= durations[i][0]
		i += 1
	for i in range(len(ans)):
		print(ans[i], end=' ')
else:
	print('NO')


(d, sumtime) = map(int, input().split())
check = sumtime
schadule = [0 for i in range(d)]
newdays = []
for i in range(d):
	days = list(map(int, input().split()))
	newdays.append(days)
	if sumtime - days[0] >= 0:
		sumtime -= days[0]
		schadule[i] += days[0]
if sum(schadule) != check:
	j = 0
	for el in newdays:
		while el[1] >= el[0]:
			if sumtime + el[0] - el[1] >= 0:
				sumtime += el[0]
				sumtime -= el[1]
				schadule[j] = el[1]
				j += 1
				break
			else:
				el[1] -= 1
if sum(schadule) == check:
	print('YES')
	for el in schadule:
		print(el, end=' ')
else:
	print('NO')


def solve_exam_prep(time_studied, more_time_to_study, time_remaining):
	if time_remaining < 0:
		print('NO')
		return
	index = 0
	while time_remaining and index < len(time_studied):
		more_studying = min(more_time_to_study[index], time_remaining)
		time_studied[index] += more_studying
		more_time_to_study[index] -= more_studying
		time_remaining -= more_studying
		index += 1
	if time_remaining:
		print('NO')
	else:
		print('YES')
		print(' '.join([str(val) for val in time_studied]))
input_line = map(lambda x: int(x), input().split())
days = next(input_line)
sum_time = next(input_line)
min_time_to_study = []
time_left = []
for _ in range(days):
	input_line = map(lambda x: int(x), input().split())
	min_time = next(input_line)
	max_time = next(input_line)
	sum_time -= min_time
	min_time_to_study.append(min_time)
	time_left.append(max_time - min_time)
solve_exam_prep(min_time_to_study, time_left, sum_time)


(d, sumtime) = map(int, input().split())
mintime = []
maxtime = []
for i in range(d):
	(min_val, max_val) = input().split()
	mintime.append(int(min_val))
	maxtime.append(int(max_val))
minsum = sum(mintime)
maxsum = sum(maxtime)
if minsum <= sumtime and sumtime <= maxsum:
	print('YES')
	result = []
	for i in range(d):
		t = min(mintime[i] + sumtime - minsum, maxtime[i])
		result.append(str(t))
		sumtime -= t - mintime[i]
	print(' '.join(result))
else:
	print('NO')


(n, s) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
(m, M) = map(sum, zip(*l))
if m <= s <= M:
	print('YES')
	s = s - m
	for i in range(n):
		(a, b) = (l[i][0], l[i][1])
		print(a + min(s, b - a), end=' ')
		s = max(0, s - (b - a))
else:
	print('NO')


(d, s) = [int(i) for i in input().split()]
y = 0
z = 0
l = []
m = []
for i in range(d):
	(a, b) = [int(i) for i in input().split()]
	y = a + y
	z = b + z
	l.append(str(a))
	m.append(str(b))
if y <= s and z >= s:
	print('YES')
	while y < s:
		for i in range(d):
			a = int(l[i])
			if a < int(m[i]):
				a = a + 1
				y = y + 1
				l[i] = str(a)
				if y == s:
					break
			else:
				continue
	print(' '.join(l))
elif z < s or y > s:
	print('NO')


import sys

def find_time(days, sum_time):
	res = [None] * len(days)
	for i in range(len(days)):
		sum_time -= days[i][0]
		res[i] = days[i][0]
		days[i][1] -= days[i][0]
	if sum_time < 0:
		return None
	for i in range(len(days)):
		if days[i][1] > 0:
			rem = min(sum_time, days[i][1])
			res[i] += rem
			sum_time -= rem
		if sum_time == 0:
			return res
	return None
(d, sum_time) = [int(x) for x in sys.stdin.readline().strip().split(' ')]
days = [None] * d
for i in range(d):
	days[i] = [int(x) for x in sys.stdin.readline().strip().split(' ')]
times = find_time(days, sum_time)
if times is not None:
	_output = ' '.join([str(x) for x in times])
	output = f'YES\n{_output}'
else:
	output = 'NO'
print(output)


s = input()
(d, sumTime) = [int(x) for x in s.split()]
a = [[0] * 2 for i in range(d)]
Mins = 0
Maxs = 0
for i in range(d):
	s = input()
	(a[i][0], a[i][1]) = [int(x) for x in s.split()]
	Mins = Mins + a[i][0]
	Maxs = Maxs + a[i][1]
if sumTime < Mins or sumTime > Maxs:
	print('NO')
else:
	for i in range(d):
		if Mins + (a[i][1] - a[i][0]) < sumTime:
			Mins = Mins + (a[i][1] - a[i][0])
			a[i][0] = a[i][1]
		else:
			a[i][0] = a[i][0] + sumTime - Mins
			print('YES')
			for i in range(d):
				print(a[i][0], end=' ')
			break


import sys
(d, sumTime) = [int(x) for x in sys.stdin.readline().split()]
timeSpent = [0] * d
extraTime = [0] * d
maxPossible = 0
for i in range(d):
	(a, b) = [int(x) for x in sys.stdin.readline().split()]
	sumTime -= a
	timeSpent[i] = a
	maxPossible += b - a
	extraTime[i] = b - a
if sumTime < 0:
	print('NO')
elif sumTime > maxPossible:
	print('NO')
else:
	print('YES')
	for i in range(d):
		timeLeft = extraTime[i]
		if sumTime == 0:
			print(timeSpent[i], end=' ')
		elif sumTime < timeLeft:
			print(timeSpent[i] + sumTime, end=' ')
			sumTime = 0
		else:
			print(timeSpent[i] + extraTime[i], end=' ')
			sumTime -= extraTime[i]
	print()


(n, z) = map(int, input().split())
a = [0] * n
b = [0] * n
x = 0
y = 0
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
	x = x + a[i]
	y = y + b[i]
if x <= z and y >= z:
	print('YES')
	for i in range(n):
		if z - b[i] > x - a[i]:
			print(b[i], end=' ')
			z -= b[i]
			x -= a[i]
		else:
			if z == x:
				print(a[i], end=' ')
				z -= a[i]
				x -= a[i]
			if z > x:
				print(a[i] + z - x, end=' ')
				z = x
else:
	print('NO')


(d, t) = map(int, input().split())
s = 0
s1 = 0
b = []
c = []
for i in range(d):
	(mi, ma) = map(int, input().split())
	b.append(mi)
	c.append(ma)
	s += mi
	s1 += ma - mi
if s + s1 < t:
	print('NO')
elif s > t:
	print('NO')
elif s == t:
	print('YES')
	print(*b)
elif s + s1 == t:
	print('YES')
	print(*c)
else:
	print('YES')
	e = t - s
	for i in range(len(b)):
		f = min(c[i] - b[i], e)
		b[i] += f
		e -= f
		if e == 0:
			break
	print(*b)


(d, n) = map(int, input().split())
a = []
b = []
res = []
t_min = 0
t_max = 0
for i in range(d):
	a.append(list(map(int, input().split())))
	res.append(a[i][0])
	t_min += a[i][0]
	t_max += a[i][1]
	b.append(a[i][1] - a[i][0])
if t_max < n or t_min > n:
	print('NO')
else:
	idx = 0
	while t_min < n:
		if b[idx] < n - t_min:
			res[idx] += b[idx]
			t_min += b[idx]
		else:
			res[idx] += n - t_min
			break
		idx += 1
	print('YES')
	print(' '.join((str(i) for i in res)))


(n, tot) = map(int, input().split())
arr = []
for i in range(n):
	(mint, maxt) = map(int, input().split())
	arr.append([mint, maxt])
minsum = 0
maxsum = 0
for i in range(n):
	minsum += arr[i][0]
	maxsum += arr[i][1]
ans = []
if tot > maxsum or tot < minsum:
	print('NO')
else:
	for i in range(n):
		ans.append(arr[i][0])
		tot -= arr[i][0]
	i = 0
	while tot > 0 and i < n:
		t = ans[i]
		ans[i] += min(tot, arr[i][1] - t)
		tot -= min(tot, arr[i][1] - t)
		i += 1
	print('YES')
	print(*ans)


(d, sumTime) = map(int, input().split())
(minimos, maximos) = ([], [])
for i in range(d):
	(a, b) = map(int, input().split())
	minimos.append(a)
	maximos.append(b)
smin = sum(minimos)
smax = sum(maximos)
if smin <= sumTime <= smax:
	res = sumTime - smin
	print('YES')
	for i in range(d):
		dif = maximos[i] - minimos[i]
		minimos[i] += min(res, dif)
		res -= min(dif, res)
	print(*minimos)
else:
	print('NO')


(d, sumTime) = map(int, input().split())
(minTime, maxTime) = (0, 0)
abc = []
for i in range(d):
	(a, b) = map(int, input().split())
	abc.append([a, b])
	minTime += a
	maxTime += b
if minTime > sumTime or maxTime < sumTime:
	print('NO')
	exit()
ans = []
for k in range(d):
	if minTime == sumTime:
		ans.append(abc[k][0])
	elif abc[k][1] - abc[k][0] < sumTime - minTime:
		ans.append(abc[k][1])
		minTime += abc[k][1] - abc[k][0]
	else:
		ans.append(abc[k][0] + sumTime - minTime)
		minTime = sumTime
print('YES')
print(*ans)


(d, sum) = input().split()
d = int(d)
sum = int(sum)
sumin = 0
sumax = 0
arrmin = [0 for i in range(d)]
arrmax = [0 for i in range(d)]
sumins = [0 for i in range(d)]
for i in range(d):
	(min, max) = input().split()
	min = int(min)
	max = int(max)
	arrmin[i] = min
	arrmax[i] = max
	sumin += min
	sumax += max
for i in range(d):
	for j in range(i + 1, d):
		sumins[i] += arrmin[j]
if sum < sumin or sum > sumax:
	print('NO')
else:
	print('YES')
	for i in range(d):
		if sum - arrmax[i] >= sumins[i]:
			sum -= arrmax[i]
			print(arrmax[i], end=' ')
		else:
			hasil = sum - sumins[i]
			print(hasil, end='')
			sum -= hasil
			if i < d - 1:
				print(end=' ')


(d, s) = (int(i) for i in input().split())
(a, b) = ([], [])
for i in range(d):
	(x, y) = (int(j) for j in input().split())
	a.append(x)
	b.append(y)
z = sum(a)
if z <= s <= sum(b):
	print('YES')
	while z != s:
		for i in range(d):
			if z < s:
				if a[i] < b[i]:
					a[i] += 1
					z += 1
			else:
				break
	print(' '.join((str(i) for i in a)))
else:
	print('NO')


(d, st) = list(map(int, input().split()))
t_min = t_max = 0
a = []
res = []
for _ in range(d):
	(mi, ma) = list(map(int, input().split()))
	a.append((mi, ma))
	res.append(mi)
	t_min += mi
	t_max += ma
if t_min <= st <= t_max:
	print('YES')
	for (idx, value) in enumerate(a):
		if value[1] - value[0] < st - sum(res):
			res[idx] = value[1]
		else:
			res[idx] += st - sum(res)
			break
	print(*res)
else:
	print('NO')


def print_solution(d, sum_time, min_h, max_h):
	if sum_time > sum(max_h) or sum_time < sum(min_h):
		print('NO')
		return
	schedule = min_h[:]
	extra_time = sum_time - sum(min_h)
	for i in range(d):
		if max_h[i] - min_h[i] > extra_time:
			schedule[i] += extra_time
			break
		schedule[i] = max_h[i]
		extra_time -= max_h[i] - min_h[i]
	print('YES')
	print(*schedule, sep=' ')
(d, sum_time) = [int(x) for x in input().split()]
(min_h, max_h) = ([], [])
for _ in range(d):
	(min_d, max_d) = [int(x) for x in input().split()]
	min_h.append(min_d)
	max_h.append(max_d)
print_solution(d, sum_time, min_h, max_h)


(d, t) = map(int, input().split())
x = 0
y = 0
Mi = []
Ma = []
for i in range(d):
	(mi, ma) = map(int, input().split())
	x += mi
	y += ma
	Mi.append(mi)
	Ma.append(ma)
if t > y or t < x:
	print('NO')
else:
	print('YES')
	t -= x
	for i in range(d):
		a = min(t, Ma[i] - Mi[i])
		Mi[i] += a
		t -= a
	print(*Mi)


R = lambda : list(map(int, input().split(' ')))
(d, summ) = R()
minn = []
maxx = []
for i in range(d):
	minn.append(0)
	maxx.append(0)
	(minn[-1], maxx[-1]) = R()
if summ < sum(minn) or summ > sum(maxx):
	print('NO')
else:
	summ -= sum(minn)
	ans = ''
	for i in range(d):
		if summ == 0:
			ans += str(minn[i]) + ' '
		elif summ < maxx[i] - minn[i]:
			ans += str(minn[i] + summ) + ' '
			summ = 0
		else:
			summ -= maxx[i] - minn[i]
			ans += str(maxx[i]) + ' '
	print('YES')
	print(ans)


(d, total) = map(lambda x: int(x), input().split(' '))
minMax = []
minSum = 0
maxSum = 0
for _ in range(d):
	(minHours, maxHours) = map(lambda x: int(x), input().split(' '))
	minSum += minHours
	maxSum += maxHours
	minMax.append((minHours, maxHours))
ans = 'YES' if minSum <= total <= maxSum else 'NO'
if ans == 'NO':
	print(ans)
else:
	schedule = []
	remain = total - minSum
	for i in range(d):
		if remain > minMax[i][1] - minMax[i][0]:
			schedule.append(minMax[i][1])
			remain -= minMax[i][1] - minMax[i][0]
		else:
			schedule.append(minMax[i][0] + remain)
			remain = 0
		i += 1
	print(ans)
	print(' '.join([str(hours) for hours in schedule]))


minTime = []
maxTime = []
hours = []
(d, sumTime) = input('').split()
d = int(d)
sumTime = int(sumTime)
summinTime = 0
summaxTime = 0
for i in range(d):
	(minT, maxT) = input('').split()
	minT = int(minT)
	maxT = int(maxT)
	minTime.append(minT)
	maxTime.append(maxT)
	summinTime += minT
	summaxTime += maxT
if sumTime > summaxTime or sumTime < summinTime:
	print('NO')
else:
	subTime = sumTime - summinTime
	pos = 0
	while subTime:
		width = maxTime[pos] - minTime[pos]
		if subTime >= width:
			subTime -= width
			hours.append(maxTime[pos])
		else:
			hours.append(minTime[pos] + subTime)
			subTime = 0
		pos += 1
	for i in range(pos, d, 1):
		hours.append(minTime[i])
	print('YES')
	for i in range(d):
		if i == 0:
			print('%d' % hours[i], end='')
		else:
			print(' %d' % hours[i], end='')
	print('\n')


(d, sum) = map(int, input().split())
mn_list = []
sn = 0
mx_list = []
sx = 0
for i in range(d):
	(mn, mx) = map(int, input().split())
	mn_list.append(mn)
	sn += mn
	mx_list.append(mx)
	sx += mx
if sn <= sum <= sx:
	print('YES')
	new_sum = sum - sn
	for i in range(d):
		dif = mx_list[i] - mn_list[i]
		if new_sum > 0 and new_sum >= dif:
			new_sum -= dif
			print(mx_list[i])
		elif new_sum > 0:
			print(mn_list[i] + new_sum)
			new_sum = 0
		else:
			print(mn_list[i])
else:
	print('NO')


(d, sumtime) = map(int, input().split())
l = [0] * d
m = 0
ma = [0] * d
for i in range(d):
	(mintime, maxtime) = map(int, input().split())
	l[i] = mintime
	m += mintime
	ma[i] = maxtime
if m > sumtime:
	print('NO')
else:
	rest = sumtime - m
	for i in range(d):
		t = min(rest, ma[i] - l[i])
		l[i] += t
		rest -= t
		if rest == 0:
			break
	if rest:
		print('NO')
	else:
		print('YES')
		print(*l)


(d, s) = map(int, input().split())
sum1 = 0
sum2 = 0
yo = []
for i in range(d):
	(n, m) = map(int, input().split())
	sum2 += m
	sum1 += n
	yo.append([n, m])
flag = 0
if sum1 <= s <= sum2:
	flag = 1
else:
	flag = 0
if flag == 1:
	print('YES')
	ans = []
	s -= sum1
	for i in range(d):
		m = min(s, yo[i][1] - yo[i][0])
		s -= m
		ans.append(yo[i][0] + m)
	print(*ans)
else:
	print('NO')


import sys

def prepare_schedule(hours, days, sum_min, day_mins, day_maxes):
	result = []
	spare_hours = hours - sum_min
	for day in range(days):
		to_spend = min(spare_hours, day_maxes[day] - day_mins[day])
		spare_hours -= to_spend
		result.append(day_mins[day] + to_spend)
	return result

def get_schedule(raw_schedule, hours, days):
	day_mins = raw_schedule[0::2]
	day_maxes = raw_schedule[1::2]
	sum_min = sum(day_mins)
	sum_max = sum(day_maxes)
	if hours < sum_min or hours > sum_max:
		return []
	return prepare_schedule(hours, days, sum_min, day_mins, day_maxes)

def main(sinp=sys.stdin, sout=sys.stdout):
	(days, hours) = map(int, sinp.readline().split())
	raw_schedule = list(map(int, sinp.read().split()))
	schedule = get_schedule(raw_schedule, hours, days)
	if not schedule:
		sout.write('NO')
	else:
		sout.write('YES\n')
		sout.write(' '.join(map(str, schedule)))
main()


(d, st) = [int(j) for j in input().split()]
t = [[int(j) for j in input().split()] for j in range(d)]
p = [sum(x) for x in zip(*t)]
if st < p[0] or st > p[1]:
	print('NO')
else:
	print('YES')
	diff = st - p[0]
	for i in t:
		v = min(i[1], max(i[0] + diff, 0))
		diff -= v - i[0]
		print(v, end=' ')


from sys import stdin, stdout
import bisect
import math
from collections import deque, Counter
mod = 10 ** 9 + 7

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

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

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

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

def DFS(dictionary, vertex, visited):
	visited[vertex] = True
	stack = [vertex]
	print(vertex)
	while stack:
		a = stack.pop()
		for i in dictionary[a]:
			if not visited[i]:
				print(i)
				visited[i] = True
				stack.append(i)

def BFS(dictionary, vertex, visited):
	visited[vertex] = True
	q = deque()
	q.append(vertex)
	while q:
		a = q.popleft()
		for i in dictionary[a]:
			if not visited[i]:
				visited[i] = True
				q.append(i)
				print(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, k) = mp()
	s = 0
	x = []
	c = 0
	y = []
	for i in range(n):
		(a, b) = mp()
		x.append([a, b])
		y.append(a)
		c += a
		s += b
	if k > s or k < c:
		pr('NO')
	else:
		pr('YES')
		for i in range(n):
			if c == k:
				break
			a = x[i][0]
			b = x[i][1]
			c -= a
			if c + b <= k:
				y[i] = b
				c += b
			elif c + b > k:
				y[i] = b - (c + b - k)
				c = k
		print(*y)
for _ in range(1):
	solve()


(d, s) = map(int, input().split())
d1 = []
for i in range(d):
	(m1, m2) = map(int, input().split())
	d1.append([m1, m2])
c = 1
d2 = []
for i in range(d):
	if s < d1[i][0]:
		c = 0
		break
	else:
		s -= d1[i][0]
		d2.append(d1[i][0])
if c == 0:
	print('NO')
elif s == 0:
	print('YES')
	for j in d2:
		print(j, end=' ')
else:
	for j in range(d):
		a = d1[j][1] - d1[j][0]
		if s >= a:
			s -= a
			d2[j] += a
		else:
			d2[j] += s
			s = 0
			break
		if s == 0:
			break
	if s == 0:
		print('YES')
		for j in d2:
			print(j, end=' ')
	else:
		print('NO')


(d, sumTime) = map(int, input().split(' '))
Min = []
Max = []
for _ in range(d):
	(min_, max_) = map(int, input().split(' '))
	Min.append(min_)
	Max.append(max_)
min_sum = sum(Min)
max_sum = sum(Max)
if min_sum <= sumTime <= max_sum:
	print('YES')
	for i in range(d):
		if sumTime == sum(Min):
			break
		else:
			if Max[i] - Min[i] >= sumTime - sum(Min):
				Min[i] = Min[i] + (sumTime - sum(Min))
			if 0 < Max[i] - Min[i] < sumTime - sum(Min):
				Min[i] = Min[i] + Max[i] - Min[i]
	print(' '.join((str(v) for v in Min)))
else:
	print('NO')


(d, s) = map(int, input().split())
a = []
arr = []
t_min = 0
t_max = 0
for i in range(d):
	(x, y) = map(int, input().split())
	arr.append([x, y])
	t_min += x
	t_max += y
	a.append([t_min, t_max])
if s < a[-1][0] or s > a[-1][1]:
	print('NO')
	exit()
for i in range(d):
	a[i][0] = t_min - a[i][0]
	a[i][1] = t_max - a[i][1]
ans = []
for i in range(d - 1):
	if arr[i][0] <= s - a[i][0] <= arr[i][1]:
		ans.append(s - a[i][0])
		s = a[i][0]
	elif arr[i][0] <= s - a[i][1] <= arr[i][1]:
		ans.append(s - a[i][1])
		s = a[i][1]
	else:
		ans.append((arr[i][0] + arr[i][1]) // 2)
		s -= (arr[i][0] + arr[i][1]) // 2
if arr[-1][0] <= s <= arr[-1][1]:
	ans.append(s - a[-1][0])
	print('YES')
	print(*ans)
else:
	print('NO')


(days, hours) = tuple(map(int, input().split()))
schedule = [0] * days
hours_schedule = [0] * days
for day in range(days):
	(min_hours, max_hours) = tuple(map(int, input().split()))
	schedule[day] = min_hours
	hours_schedule[day] = max_hours - min_hours
if sum(schedule) == hours:
	print('YES\n%s' % ' '.join(map(str, schedule)))
else:
	hours_required = hours - sum(schedule)
	if hours_required < 0:
		print('NO')
	else:
		for (day, h) in enumerate(hours_schedule):
			schedule[day] += hours_schedule[day] if hours_schedule[day] <= hours_required else hours_required
			hours_required -= hours_schedule[day] if hours_schedule[day] <= hours_required else hours_required
			if hours_required == 0:
				print('YES\n%s' % ' '.join(map(str, schedule)))
				break
		else:
			print('NO')


read = lambda : map(int, input().split())
(d, Sum) = read()
mn = [0] * d
mx = [0] * d
for i in range(d):
	(mn[i], mx[i]) = read()
if not sum(mn) <= Sum <= sum(mx):
	print('NO')
	exit()
ans = [i for i in mn]
c = [mx[i] - mn[i] for i in range(d)]
Sum -= sum(mn)
for i in range(d):
	if Sum == 0:
		break
	cur = min(Sum, c[i])
	ans[i] += cur
	Sum -= cur
print('YES')
print(*ans)


(num_d, total_h) = (int(i) for i in input().split())
days = [list(map(int, input().split())) for _ in range(num_d)]
t = list(zip(*days))
min_h = sum(t[0])
max_h = sum(t[1])
if min_h <= total_h <= max_h:
	print('YES')
	delta = total_h - min_h
	for (n, x) in days:
		today = min(x - n, delta)
		delta -= today
		print(n + max(0, today), end=' ')
else:
	print('NO')


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input().split()))
(d, sum1) = I()
min1 = [0] * d
max1 = [0] * d
for i in range(d):
	(min1[i], max1[i]) = I()
if sum(min1) <= sum1 <= sum(max1):
	print('YES')
	ans = min1
	sum1 = sum1 - sum(min1)
	i = 0
	while sum1 > 0:
		if sum1 - (max1[i] - min1[i]) >= 0:
			sum1 = sum1 - (max1[i] - min1[i])
			ans[i] = max1[i]
		else:
			ans[i] = min1[i] + sum1
			sum1 = 0
		i = i + 1
	print(*ans)
else:
	print('NO')


import sys
(n, d) = map(int, input().strip().split(' '))
li = []
for j in range(n):
	li.append(list(map(int, input().strip().split(' '))))
predict = [0] * n
total = 0
flg = 0
for i in range(n):
	total += li[i][0]
	if total > d:
		flg = 1
		break
	predict[i] = li[i][0]
if flg == 1:
	print('NO')
	sys.exit()
diff = d - total
for i in range(n):
	posbl = li[i][1] - li[i][0]
	if posbl < diff:
		predict[i] += posbl
		diff -= posbl
	else:
		predict[i] += diff
		flg = 1
		break
if flg != 1:
	print('NO')
	sys.exit()
print('YES')
print(*predict)


def main():
	from sys import stdin, stdout
	(n, sumtime) = map(int, stdin.readline().split())
	(a, b) = ([], [])
	for i in range(n):
		(x, y) = map(int, stdin.readline().split())
		a.append(x)
		b.append(y)
	if sum(b) < sumtime or sum(a) > sumtime:
		stdout.write('NO')
	else:
		stdout.write('YES\n')
		diff = sumtime - sum(a)
		for i in range(n):
			if diff:
				k = b[i] - a[i]
				minim = min(k, diff)
				a[i] += minim
				diff -= minim
		for i in a:
			stdout.write(str(i) + ' ')
main()


from sys import stdin, stdout
(d, target) = [int(x) for x in stdin.readline().split()]

def get_tuple(x):
	return (int(x[0]), int(x[1]))
days_arr = []
res = []
for day in range(d):
	tup = get_tuple(stdin.readline().split())
	days_arr.append(tup)
	res.append(tup[0])
days_tup = [(x[1][1] - x[1][0], (x[0], x[1])) for x in enumerate(days_arr)]
days_tup = sorted(days_tup, key=lambda x: x[0])
min_sum = 0
max_sum = 0
for i in range(d):
	min_sum += days_arr[i][0]
	max_sum += days_arr[i][1]

def is_valid(target, min_sum, max_sum):
	return min_sum <= target and target <= max_sum
if not is_valid(target, min_sum, max_sum):
	print('NO')
else:
	left_over = target - min_sum
	i = 0
	while left_over > 0:
		original_pos = days_tup[i][1][0]
		upper = days_tup[i][1][1][1]
		lower = days_tup[i][1][1][0]
		interval_len = upper - lower
		if left_over >= interval_len:
			res[original_pos] = upper
			left_over -= interval_len
		else:
			res[original_pos] = lower + left_over
			left_over = 0
		i += 1
	print('YES')
	print(*res)


(d, sumTime) = [int(s) for s in input().split()]
minTime = 0
maxTime = 0
uppTime = 0
schedule = [0] * 2 * d
for i in range(0, d * 2, 2):
	(schedule[i], schedule[i + 1]) = [int(s) for s in input().split()]
	minTime += schedule[i]
	maxTime += schedule[i + 1]
if maxTime < sumTime or minTime > sumTime:
	print('NO')
else:
	print('YES')
	uppTime = sumTime - minTime
	for i in range(0, d * 2, 2):
		if uppTime == 0:
			print(schedule[i])
		elif uppTime - (schedule[i + 1] - schedule[i]) > 0:
			print(schedule[i + 1])
			uppTime -= schedule[i + 1] - schedule[i]
		else:
			print(schedule[i] + uppTime)
			uppTime = 0


def main():
	(d, sumTime) = map(int, input().split())
	times = []
	maxPossible = 0
	sol = []
	for i in range(d):
		(minTime, maxTime) = map(int, input().split())
		times.append((minTime, maxTime))
		maxPossible += maxTime
		sol.append(minTime)
	if maxPossible < sumTime:
		print('NO')
		return
	total = sum(sol)
	if sumTime < total:
		print('NO')
		return
	print('YES')
	i = 0
	while total != sumTime:
		if sumTime - total <= times[i][1] - times[i][0]:
			sol[i] += sumTime - total
			break
		else:
			sol[i] = times[i][1]
			total += times[i][1] - times[i][0]
		i += 1
	for i in sol:
		print(i, end=' ')
main()


(n, sum1) = input().split()
(n, sum1) = [int(n), int(sum1)]
mi = 0
ma = 0
a = []
ans = []
for i in range(0, n):
	(min, max) = input().split()
	(min, max) = [int(min), int(max)]
	a.append([min, max])
	mi += min
	ma += max
	ans.append(min)
if sum1 < mi or sum1 > ma:
	print('NO')
elif sum1 == mi:
	print('YES')
	print(*ans, sep=' ')
elif sum1 == ma:
	print('YES')
	for j in range(0, len(a)):
		print(a[j][1], end=' ')
else:
	ss = sum1 - sum(ans)
	for i in range(0, len(a)):
		if ss >= a[i][1] - a[i][0]:
			ans[i] += a[i][1] - a[i][0]
			ss -= a[i][1] - a[i][0]
		else:
			ans[i] += ss
			ss = 0
		if ss == 0:
			break
	print('YES')
	print(*ans, sep=' ')


(d, t) = map(int, input().split())
min = []
max = []
for i in range(d):
	(a, b) = map(int, input().split())
	min.append(a)
	max.append(b)
if sum(min) > t or sum(max) < t:
	print('NO')
	quit()
print('YES')
gap = t - sum(min)
for i in range(d):
	if gap >= max[i] - min[i]:
		print(max[i], end='')
		gap -= max[i] - min[i]
	elif gap > 0 and gap < max[i] - min[i]:
		print(gap + min[i], end='')
		gap = 0
	elif gap == 0:
		print(min[i], end='')
	if i != d - 1:
		print('', end=' ')
	else:
		print()


from sys import stdin
(d, s) = tuple(map(int, input().split()))
times = [tuple(map(int, line.split())) for line in stdin.readlines()]
dp = [[(0, -1) for j in range(d + 1)] for i in range(s + 1)]
dp[0][0] = (1, -1)
for j in range(d):
	(mn, mx) = times[j]
	for i in range(s + 1):
		(ox, _) = dp[i][j]
		if ox:
			for k in range(mn, min(mx + 1, s + 1 - i)):
				dp[i + k][j + 1] = (1, k)
flag = dp[s][d][0] == 1
print('YES' if flag else 'NO')
if flag:
	ans = list()
	last = s
	for j in range(d, 0, -1):
		k = dp[last][j][1]
		ans = [k] + ans
		last = last - k
	print(*ans)


(d, s) = map(int, input().split())
limitMinSum = 0
limitMaxSum = 0
limitMinList = []
limitMaxList = []
for i in range(d):
	(limitMin, limitMax) = map(int, input().split())
	limitMinList.append(limitMin)
	limitMaxList.append(limitMax)
	limitMinSum += limitMin
	limitMaxSum += limitMax
if s >= limitMinSum and s <= limitMaxSum:
	print('YES')
	s -= limitMinSum
	for i in range(d):
		aux = min(max(0, s), limitMaxList[i] - limitMinList[i])
		s = s - (limitMaxList[i] - limitMinList[i])
		print(limitMinList[i] + aux, end=' ')
else:
	print('NO')


(d, s) = map(int, input().split())
start = []
end = []
for i in range(d):
	(x, y) = map(int, input().split())
	start.append(x)
	end.append(y)
ma = 0
mi = 0
for i in range(d):
	mi += start[i]
	ma += end[i]
li = []
p = s
if s > ma or s < mi:
	print('NO')
else:
	for i in range(d):
		li.append(start[i])
		p = p - start[i]
	l = 0
	while p != 0:
		if li[l % d] == end[l % d]:
			l += 1
			continue
		li[l % d] += 1
		p -= 1
		l += 1
	print('YES')
	print(*li, sep=' ')


i = input().split()
d = int(i[0])
sumTime = int(i[1])
time_constraints = list()
for i in range(d):
	i = input().split()
	time_constraints.append((int(i[0]), int(i[1])))
sum_max = 0
sum_min = 0
for i in time_constraints:
	sum_min += i[0]
	sum_max += i[1]
if sum_max < sumTime or sum_min > sumTime:
	print('NO')
	exit()
results = [i[1] for i in time_constraints]
while sum(results) > sumTime:
	for i in range(len(results)):
		if results[i] > time_constraints[i][0]:
			results[i] -= 1
			break
str_results = [str(r) for r in results]
print('YES')
print(' '.join(str_results))


from functools import reduce
from operator import add
(d, sum_time) = [int(x) for x in input().split()]
(min_times, max_times) = (list(), list())
for i in range(d):
	(min_time, max_time) = [int(x) for x in input().split()]
	min_times.append(min_time)
	max_times.append(max_time)
total_time = 0
times = list()
min_time_sum = reduce(add, min_times, 0)
max_time_sum = reduce(add, max_times, 0)
if min_time_sum <= sum_time <= max_time_sum:
	print('YES')
	for i in range(d):
		cur_time = min(min_times[i] + sum_time - min_time_sum, max_times[i])
		print(cur_time, end=' ')
		sum_time -= cur_time - min_times[i]
else:
	print('NO')


(d, sumTime) = [int(x) for x in input().split()]
q = []
s = []
suma = 0
sumb = 0
temptime = sumTime
for _ in range(d):
	(a, b) = [int(x) for x in input().split()]
	q.append((a, b))
	sumTime -= a
	s.append(a)
	suma += a
	sumb += b
if temptime < suma or temptime > sumb:
	print('NO')
else:
	for i in range(len(s)):
		temp = q[i][1] - q[i][0]
		if temp > sumTime:
			temp = sumTime
		s[i] += temp
		sumTime -= temp
		if not sumTime:
			break
	print('YES')
	for x in s:
		print(x, end=' ')
	print()


lt = list(input().split())
(n, k) = (int(lt[0]), int(lt[1]))
mn = mx = 0
ml = []
for i in range(n):
	lt = list(input().split())
	(lt[0], lt[1]) = (int(lt[0]), int(lt[1]))
	mn += lt[0]
	mx += lt[1]
	ml.append(lt)
if k >= mn and k <= mx:
	print('YES')
	gt = []
	sm = 0
	for i in range(n):
		gt.append(ml[i][0])
		sm += ml[i][0]
	i = 0
	while sm != k:
		if gt[i] < ml[i][1]:
			gt[i] += 1
			sm += 1
		else:
			i += 1
	for i in gt:
		print(i, end=' ')
else:
	print('NO')


l = lambda : map(int, input().split())
(d, s) = l()
lis = [tuple(l()) for _ in range(d)]
(m, n) = map(sum, zip(*lis))
if m <= s <= n:
	print('YES')
	ans = []
	s -= m
	for (a, b) in lis:
		ans.append(a + min(s, b - a))
		s = max(0, s - b + a)
	print(' '.join(map(str, ans)))
else:
	print('NO')


(d, sum_time) = list(map(int, input().split()))
t = [list(map(int, input().split())) for i in range(d)]
schedule = [0 for i in range(d)]
s = 0
for i in range(d):
	s += t[i][0]
	schedule[i] = t[i][0]
	t[i][0] = t[i][1] - t[i][0]
if s > sum_time:
	print('NO')
else:
	for i in range(d):
		while s != sum_time and t[i][0] > 0:
			schedule[i] += 1
			s += 1
			t[i][0] -= 1
	if s == sum_time:
		print('YES')
		print(*schedule)
	else:
		print('NO')


import sys
(d, sumtime) = map(int, input().split())
minn = 0
maxx = 0
times = []
for i in range(d):
	(t1, t2) = map(int, input().split())
	times.append((t1, t2))
if sum((item[1] for item in times)) < sumtime or sum((item[0] for item in times)) > sumtime:
	print('NO')
	sys.exit()
print('YES')
tres = [item[0] for item in times]
counter = 0
while sum(tres) < sumtime:
	canadd = times[counter][1] - tres[counter]
	willadd = min(canadd, sumtime - sum(tres))
	tres[counter] += willadd
	counter += 1
print(' '.join([str(item) for item in tres]))


(d, suma_czasu) = map(int, input().split())
minimum = 0
maksimum = 0
tab = []
for i in range(d):
	(a, b) = map(int, input().split())
	minimum += a
	maksimum += b
	tab.append((a, b))
wynik = []
if minimum <= suma_czasu <= maksimum:
	print('YES')
	trzeba_odjac = maksimum - suma_czasu
	for i in tab:
		roznica = i[1] - i[0]
		if roznica <= trzeba_odjac:
			trzeba_odjac -= roznica
			wynik.append(i[0])
		else:
			wynik.append(i[1] - trzeba_odjac)
			trzeba_odjac = 0
	print(*wynik)
else:
	print('NO')


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
(x, y) = ml()
mn = 0
mx = 0
lol = []
yo = []
for _ in range(x):
	(a, b) = ml()
	mn += a
	mx += b
	yo.append(b)
	lol.append(a)
if sum(lol) <= y and sum(yo) >= y:
	print('YES')
	y -= sum(lol)
	for i in range(len(lol)):
		if y >= 0:
			k = min(y, yo[i] - lol[i])
			lol[i] += k
			y -= k
		print(lol[i], end=' ')
else:
	print('NO')


(d, sum_time) = map(int, input().split())
min_time = []
max_time = []
for i in range(d):
	a = input().split()
	min_time.append(int(a[0]))
	max_time.append(int(a[1]))
if sum_time < sum(min_time) or sum_time > sum(max_time):
	print('NO')
else:
	print('YES')
	b = sum_time - sum(min_time)
	for i in range(d):
		print(min_time[i] + min(max_time[i] - min_time[i], b), end=' ')
		b -= min(max_time[i] - min_time[i], b)


first = input().split(' ')
d = int(first[0])
hours = int(first[1])
mins = []
maxs = []
schedule = []
for x in range(d):
	line = input().split(' ')
	mins.append(int(line[0]))
	maxs.append(int(line[1]))
for i in range(d):
	if hours >= maxs[i]:
		schedule.append(maxs[i])
		hours -= maxs[i]
	elif hours > 0:
		schedule.append(hours)
		hours = 0
	else:
		schedule.append(0)
for i in range(d):
	if schedule[i] < mins[i]:
		need = mins[i] - schedule[i]
		for j in range(i):
			possible = schedule[j] - mins[j]
			move = min(possible, need)
			schedule[i] = schedule[i] + move
			schedule[j] = schedule[j] - move
			need -= move
			if need == 0:
				break
success = hours == 0
for i in range(d):
	if mins[i] > schedule[i] or schedule[i] > maxs[i]:
		success = False
if success:
	print('YES')
	for x in schedule:
		print(x, end=' ')
	print()
else:
	print('NO')


n = input().split()
sum = int(n[1])
n = int(n[0])
min = 0
max = 0
d = []
for i in range(n):
	a = input().split()
	b = int(a[1])
	a = int(a[0])
	min += a
	max += b
	d.append([a, b - a])
if min <= sum <= max:
	print('YES')
	ost = sum - min
	for i in d:
		if i[1] < ost:
			i[0] = i[0] + i[1]
			ost -= i[1]
		else:
			i[0] = i[0] + ost
			ost = 0
	ans = ''
	for i in range(n):
		ans += str(d[i][0]) + ' '
	if len(ans) > 0:
		ans = ans[:-1]
	print(ans)
else:
	print('NO')


(d, s) = map(int, input().split())
m = [tuple(map(int, input().split())) for _ in range(d)]
flag = 0
for i in m:
	s -= i[0]
if s < 0:
	flag = 1
elif s == 0:
	p = [i[0] for i in m]
	flag = 2
if flag == 0:
	p = [i[0] for i in m]
	for i in range(d):
		if s == 0:
			break
		if m[i][1] - m[i][0] > s:
			p[i] += s
			s = 0
			break
		else:
			p[i] = m[i][1]
			s -= m[i][1] - m[i][0]
	if s == 0:
		flag = 2
	else:
		flag = 1
if flag == 2:
	print('YES')
	print(' '.join(map(str, p)))
else:
	print('NO')


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(n, k) = invr()
	a = list()
	min_total = 0
	max_total = 0
	for _ in range(n):
		(x, y) = invr()
		a.append((x, y))
		min_total += x
		max_total += y
	if k < min_total or k > max_total:
		print('NO')
	else:
		print('YES')
		diff = k - min_total
		ans = list()
		for i in range(n):
			ans.append(a[i][0] + min(a[i][1] - a[i][0], diff))
			diff -= min(a[i][1] - a[i][0], diff)
		print(' '.join(map(str, ans)))


vals = [int(x) for x in input().split()]
d = vals[0]
sumTime = vals[1]
minMaxTimePerDay = []
minSumTime = 0
maxSumTime = 0
for _ in range(d):
	timesPerDay = [int(x) for x in input().split()]
	minMaxTimePerDay.append(timesPerDay)
	minSumTime += timesPerDay[0]
	maxSumTime += timesPerDay[1]
if sumTime < minSumTime or sumTime > maxSumTime:
	print('NO')
else:
	print('YES')
	timePerDay = []
	remainingTime = sumTime
	for i in range(d):
		timePerDay.append(minMaxTimePerDay[i][0])
		remainingTime -= timePerDay[i]
	i = 0
	while remainingTime > 0:
		addedTime = min(remainingTime, minMaxTimePerDay[i][1] - minMaxTimePerDay[i][0])
		timePerDay[i] += addedTime
		remainingTime -= addedTime
		i += 1
	print(' '.join([str(time) for time in timePerDay]))


__author__ = 'Darren'

def solve():
	import sys
	stdin = sys.stdin if True else open('data')
	(d, sum_time) = map(int, next(stdin).split())
	(min_times, max_times) = ([], [])
	for line in stdin:
		(min_time, max_time) = map(int, line.split())
		min_times.append(min_time)
		max_times.append(max_time)
	(min_total, max_total) = (sum(min_times), sum(max_times))
	if min_total <= sum_time <= max_total:
		print('YES')
		extra = sum_time - min_total
		for (min_time, max_time) in zip(min_times, max_times):
			if extra >= max_time - min_time:
				print(max_time, end=' ')
				extra -= max_time - min_time
			elif extra == 0:
				print(min_time, end=' ')
			else:
				print(min_time + extra, end=' ')
				extra = 0
	else:
		print('NO')
solve()


(d, sumtime) = map(int, input().split())
smin = smax = 0
l = []
for i in range(d):
	(mint, maxt) = map(int, input().split())
	l.append([mint, maxt])
	smin += mint
	smax += maxt
if sumtime > smax or sumtime < smin:
	print('NO')
else:
	print('YES')
	diff = smax - sumtime
	for i in range(d):
		temp = min(l[i][1] - l[i][0], diff)
		diff -= temp
		print(l[i][1] - temp, end=' ')


(day, sumTime) = map(int, input().split())
(minList, maxList) = ([], [])
(minTotal, maxTotal) = (0, 0)
for i in range(day):
	(mn, mx) = map(int, input().split())
	minList.append(mn)
	maxList.append(mx)
	minTotal += mn
	maxTotal += mx
if sumTime < minTotal or sumTime > maxTotal:
	print('NO')
else:
	print('YES')
	remain = sumTime - minTotal
	for i in range(day):
		diff = maxList[i] - minList[i]
		if diff <= remain:
			remain -= diff
			minList[i] = maxList[i]
		else:
			minList[i] += remain
			break
	for ele in minList:
		print(ele, end=' \n'[ele == minList[-1]])


from functools import reduce

def solve(t, l):
	(sum_min, sum_max) = reduce(lambda a, b: [a[0] + b[0], a[1] + b[1]], l)
	if t < sum_min or t > sum_max:
		print('NO')
		return
	print('YES')
	t -= sum_min
	for i in range(len(l)):
		(lo, hi) = l[i]
		extra = min(t, hi - lo) if t > 0 else 0
		print(lo + extra, end=' ')
		t -= extra
f = lambda : list(map(int, input().split()))
(d, t) = f()
solve(t, [f() for _ in range(d)])


(d, time) = [int(x) for x in input().split(' ')]
(available, schedule) = ([], [])
(total_min, total_max) = (0, 0)
for _ in range(d):
	(min_time, max_time) = [int(x) for x in input().split(' ')]
	total_min += min_time
	total_max += max_time
	available.append((min_time, max_time))
if not (total_min <= time and time <= total_max):
	print('NO')
else:
	print('YES')
	for (min_time, max_time) in available:
		schedule.append(min_time)
		time -= min_time
	i = 0
	while time:
		(min_time, max_time) = available[i]
		difference = max_time - min_time
		if difference <= time:
			schedule[i] += difference
			time -= difference
		else:
			schedule[i] += time
			time = 0
		i += 1
	print(' '.join([str(x) for x in schedule]))


(d, sumTime) = map(int, input().split())
cur_time = 0
times = []
ans = []
for _ in range(d):
	(minTime, maxTime) = map(int, input().split())
	times.append((minTime, maxTime))
	ans.append(minTime)
	cur_time += minTime
if cur_time > sumTime:
	print('NO')
	exit()
i = 0
while cur_time < sumTime and i < d:
	delta = min(times[i][1] - times[i][0], sumTime - cur_time)
	cur_time += delta
	ans[i] += delta
	i += 1
if cur_time == sumTime:
	print('YES')
	print(*ans)
else:
	print('NO')


study = list(map(int, input().split()))
days = study[0]
hours = study[1]
minTimes = []
maxTimes = []
schedule = []
for i in range(days):
	Time = list(map(int, input().split()))
	minTimes.append(Time[0])
	maxTimes.append(Time[1])
if sum(minTimes) <= hours <= sum(maxTimes):
	for i in range(days):
		maxTimes[i] -= minTimes[i]
	hours -= sum(minTimes)
	for i in range(days):
		if maxTimes[i] <= hours:
			schedule.append(str(minTimes[i] + maxTimes[i]))
			hours -= maxTimes[i]
		else:
			schedule.append(str(minTimes[i] + hours))
			hours = 0
	print('YES')
	print(' '.join(schedule))
else:
	print('NO')


(n, k) = map(int, input().split())
list1 = []
list2 = []
for _ in range(0, n):
	(a, b) = map(int, input().split())
	list1.append(a)
	list2.append(b)
if sum(list1) > k or sum(list2) < k:
	print('NO')
else:
	list3 = list1 + []
	print('YES')
	k = k - sum(list1)
	for i in range(0, len(list1)):
		if k > list2[i] - list1[i]:
			list3[i] += list2[i] - list1[i]
			k -= list2[i] - list1[i]
		else:
			list3[i] += k
			k = 0
	print(*list3)


(d, sum_time) = map(int, input().split())
min_max_array = []
min_arr = []
max_arr = []
for i in range(d):
	(min_time, max_time) = map(int, input().split())
	min_arr.append(min_time)
	max_arr.append(max_time)
min_sum = sum(min_arr)
max_sum = sum(max_arr)
if min_sum > sum_time or max_sum < sum_time:
	print('NO')
elif min_sum == sum_time:
	print('YES')
	for i in min_arr:
		print(i, end=' ')
else:
	delta = 0
	sum_need = sum_time - min_sum
	i = 0
	while i < len(min_arr) + 1:
		if sum_need == 0:
			print('YES')
			for j in min_arr:
				print(j, end=' ')
			break
		elif sum_need < 0:
			print('NO')
			break
		delta = min(sum_need, max_arr[i] - min_arr[i])
		min_arr[i] += delta
		max_arr[i] -= delta
		sum_need -= delta
		i += 1


import math
import sys
(n, m) = map(int, input().split())
inf = []
sup = []
for i in range(n):
	(a, b) = map(int, input().split())
	inf.append(a)
	sup.append(b)
r = sum(inf)
if r <= m <= sum(sup):
	print('YES')
	for i in range(n):
		if r + sup[i] - inf[i] <= m:
			r += sup[i] - inf[i]
			inf[i] = sup[i]
		else:
			inf[i] += m - r
			break
	[print(i, end=' ') for i in inf]
else:
	print('NO')


def test(d, suntime, time_info):
	d_list = []
	time_min = 0
	time_max = 0
	for (i, j) in time_info:
		time_min += i
		time_max += j
		d_list.append(i)
	if suntime > time_max:
		print('NO')
		return
	elif suntime < time_min:
		print('NO')
		return
	else:
		spread_time = time_min
		for (g, (i, j)) in enumerate(time_info):
			diff_time = j - i
			spread_time += diff_time
			if spread_time <= suntime:
				d_list[g] += diff_time
			else:
				t = suntime - (spread_time - diff_time)
				spread_time += t - diff_time
				if t < 0:
					t = 0
				d_list[g] += t
		print('YES')
		d_result = ''
		for d in d_list:
			d_result += str(d) + ' '
		print(d_result)
		return
time_info = []
(d, suntime) = input().split()
(d, suntime) = (int(d), int(suntime))
for _ in range(d):
	(minTime, maxTime) = input().split()
	time_info.append((int(minTime), int(maxTime)))
test(d, suntime, time_info)


(d, s) = (int(x) for x in input().split())
s1 = []
e1 = []
min1 = 0
max1 = 0
for i in range(d):
	(s11, e11) = (int(x) for x in input().split())
	s1.append(s11)
	e1.append(e11)
	min1 = min1 + s1[i]
	max1 = max1 + e1[i]
if min1 > s or max1 < s:
	print('NO')
else:
	print('YES')
	res = []
	for i in range(d):
		res.append(s1[i])
		s = s - s1[i]
	for i in range(d):
		while res[i] != e1[i] and s != 0:
			res[i] = res[i] + 1
			s = s - 1
		if s == 0:
			break
	for i in range(d):
		print(res[i], end=' ')


(d, sum_time) = [int(x) for x in input().split()]
(min_list, max_list) = ([], [])
time_left = sum_time
for i in range(d):
	(min_time, max_time) = [int(x) for x in input().split()]
	min_list.append(min_time)
	max_list.append(max_time)
	time_left -= min_time
if sum(min_list) < sum_time:
	for ii in range(d):
		prev_min_time = min_list[ii]
		min_list[ii] = min(time_left + prev_min_time, max_list[ii])
		min_list[ii] = max(min_list[ii], prev_min_time)
		time_left = time_left + prev_min_time - min_list[ii]
if sum(min_list) == sum_time:
	print('YES')
	for item in min_list:
		print(item, end=' ')
else:
	print('NO')


(x, sums) = map(int, input().split())
mxs = []
mns = []
for i in range(x):
	(a, b) = map(int, input().split())
	mns += [a]
	mxs += [b]
if sum(mxs) < sums or sum(mns) > sums:
	print('NO')
else:
	l = []
	b = 0
	b += sums
	sums = 0
	for i in mns:
		l += [i]
		sums += i
	for i in range(x):
		sums -= l[i]
		l[i] = mxs[i]
		sums += mxs[i]
		if sums == b:
			break
		elif sums > b:
			l[i] -= sums - b
			break
	print('YES')
	print(*l)


(d, tot) = map(int, input().split())
mi = mx = 0
ans = [0] * d
m = [0] * d
for _ in range(d):
	(a, b) = map(int, input().split())
	mi += a
	ans[_] = a
	m[_] = b
	mx += b
if mi <= tot <= mx:
	print('YES')
	ext = tot - mi
	for i in range(d):
		lef = m[i] - ans[i]
		if ext > lef:
			ans[i] = m[i]
			ext -= lef
		else:
			ans[i] += ext
			break
	print(*ans)
else:
	print('NO')


(d, sum_t) = map(int, input().split())
mins = []
maxs = []
min_sum = max_sum = 0
for i in range(d):
	(min_t, max_t) = map(int, input().split())
	min_sum = min_sum + min_t
	max_sum = max_sum + max_t
	mins.append(min_t)
	maxs.append(max_t)
if min_sum <= sum_t <= max_sum:
	print('YES')
	for i in range(d):
		t = min(mins[i] + sum_t - min_sum, maxs[i])
		print(t, end=' ')
		sum_t = sum_t - (t - mins[i])
else:
	print('NO')


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')

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

def array():
	return [int(i) for i in input().split()]
(d, n) = value()
a = []
ans = []
for i in range(d):
	(s, e) = value()
	a.append((s, e))
	ans.append(s)
n -= sum(ans)
if n == 0:
	print('YES')
	print(*ans)
	exit()
elif n < 0:
	print('NO')
	exit()
else:
	k = 0
	f = 0
	for i in range(d):
		if a[i][1] - a[i][0] <= n:
			ans[i] = a[i][1]
			n -= a[i][1] - a[i][0]
		else:
			ans[i] += n
			n = 0
		if n == 0:
			f = 1
			break
	if f == 1:
		print('YES')
		print(*ans)
	else:
		print('NO')


(a, b) = map(int, input().split())
l = []
mn = []
mx = []
for i in range(a):
	(m, n) = map(int, input().split())
	mn.append(m)
	mx.append(n)
	l.append(n - m)
if sum(mn) > b:
	print('NO')
	exit()
elif sum(mx) < b:
	print('NO')
	exit()
else:
	b = b - sum(mn)
	for i in range(a):
		if l[i] >= b:
			mn[i] += b
			b = 0
			break
		else:
			b = b - l[i]
			mn[i] += l[i]
if b == 0:
	print('YES')
	ans = str(mn[0])
	for i in range(1, a):
		ans += ' ' + str(mn[i])
	print(ans)
else:
	print('NO')


__author__ = 'Hiep'
import sys
input = sys.stdin.readline().split(' ')
d = int(input[0])
sum_time = int(input[1])
schedule = []
sum_min = 0
sum_max = 0
for i in range(d):
	input = sys.stdin.readline().split(' ')
	min_time = int(input[0])
	max_time = int(input[1])
	schedule.append([min_time, max_time])
	sum_min += min_time
	sum_max += max_time
if sum_min > sum_time or sum_time > sum_max:
	print('NO')
else:
	print('YES')
	additional_time = sum_time - sum_min
	for i in range(d):
		daily_add_time = min(additional_time, schedule[i][1] - schedule[i][0])
		print(schedule[i][0] + daily_add_time, end=' ')
		additional_time -= daily_add_time


(d, tsum) = [int(x) for x in input().split()]
tmin = []
tmax = []
for i in range(d):
	(a, b) = [int(x) for x in input().split()]
	tmin.append(a)
	tmax.append(b)
s1 = sum(tmin)
s2 = sum(tmax)
if tsum < s1:
	print('NO')
elif tsum > s2:
	print('NO')
else:
	print('YES')
	if tsum == s1:
		for i in tmin:
			print(i, end=' ')
	else:
		v = [l for l in tmin]
		ext = tsum - s1
		for i in range(d):
			k = tmax[i] - tmin[i]
			if ext != 0:
				if k < ext:
					v[i] += k
					ext -= k
				else:
					v[i] += ext
					ext = 0
					break
		for i in v:
			print(i, end=' ')


(d, st) = map(int, input().split())
mns = []
mxs = []
for i in range(d):
	q = list(map(int, input().split()))
	mns.append(q[0])
	mxs.append(q[1])
if sum(mns) <= st <= sum(mxs):
	r = st - sum(mns)
	q = mns.copy()
	for i in range(d):
		q[i] += min(mxs[i] - mns[i], r)
		r -= min(mxs[i] - mns[i], r)
	print('YES')
	print(' '.join(map(str, q)))
else:
	print('NO')


def separate(ints):
	(pos, var_char, count) = ([], [], 0)
	ints.strip()
	for char in ints:
		count += 1
		if char != ' ':
			var_char.append(char)
		if char == ' ' or count == len(ints):
			num = int(''.join(var_char))
			pos.append(num)
			var_char = []
	return pos
temp = separate(input())
(days, thours) = (temp[0], temp[1])
(min_val, max_val) = ([], [])
for day in range(days):
	values = separate(input())
	min_val.append(values[0])
	max_val.append(values[1])
(min_sum, max_sum) = (sum(min_val), sum(max_val))
if min_sum <= thours and max_sum >= thours:
	(diff, result) = (thours - min_sum, [])
	for num in range(len(min_val)):
		(hmin, hmax) = (min_val[num], max_val[num])
		(var_diff, count) = (hmax - hmin, 0)
		while True:
			if diff - var_diff >= 0:
				diff -= var_diff
				result.append(hmax - count)
				break
			elif diff == 0:
				result.append(hmin)
				break
			else:
				var_diff -= 1
				count += 1
	print('YES')
	ans = []
	for res in result:
		ans.append(str(res))
	print(' '.join(ans))
else:
	print('NO')


import re
(days, sumTime) = [int(elem) for elem in re.match('(\\d+) (\\d+)', input()).groups()]
days = days - 1
scope = []
choice = []
total = 0
more = 0
less = 0
for i in range(days + 1):
	(minTime, maxTime) = [int(elem) for elem in re.match('(\\d+) (\\d+)', input()).groups()]
	scope.append((minTime, maxTime))
	init = (minTime + maxTime) // 2
	choice.append(init)
	total = total + init
	more = more + maxTime - init
	less = less + init - minTime
if total == sumTime:
	print('YES')
	print(*choice)
elif total > sumTime and total - sumTime <= less:
	leftTime = total - sumTime
	for i in range(days + 1):
		if leftTime > choice[i] - scope[i][0]:
			leftTime = leftTime - (choice[i] - scope[i][0])
			choice[i] = scope[i][0]
		else:
			choice[i] = choice[i] - leftTime
			print('YES')
			print(*choice)
			break
elif total < sumTime and sumTime - total <= more:
	leftTime = sumTime - total
	for i in range(days + 1):
		if leftTime > scope[i][1] - choice[i]:
			leftTime = leftTime - (scope[i][1] - choice[i])
			choice[i] = scope[i][1]
		else:
			choice[i] = choice[i] + leftTime
			print('YES')
			print(*choice)
			break
else:
	print('NO')


def main():
	(d, sumTime) = map(int, input().split())
	(minTime, maxTime) = (list(), list())
	for i in range(d):
		(a, b) = map(int, input().split())
		minTime.append(a)
		maxTime.append(b)
	res = [0] * d
	for i in range(d):
		res[i] = minTime[i]
	if sum(res) > sumTime:
		print('NO')
		return
	rest = sumTime - sum(res)
	for i in range(d):
		available = maxTime[i] - res[i]
		if available <= rest:
			res[i] = maxTime[i]
			rest -= available
		else:
			res[i] += rest
			rest = 0
		if rest == 0:
			break
	if rest != 0:
		print('NO')
	else:
		print('YES')
		for i in res:
			print(i, end=' ')
		print('')
main()


items = input().split()
d = int(items[0])
sumTime = int(items[1])
allowed_times = []
for i in range(d):
	items = input().split()
	allowed_times.append((int(items[0]), int(items[1])))
minTime = 0
maxTime = 0
for allowed_time in allowed_times:
	minTime += allowed_time[0]
	maxTime += allowed_time[1]
if sumTime < minTime or sumTime > maxTime:
	print('NO')
else:
	print('YES')
	min_remain = None
	max_remain = None
	remains = []
	for i in range(d - 1, -1, -1):
		minTime = allowed_times[i][0]
		maxTime = allowed_times[i][1]
		if min_remain is None:
			remains.insert(0, (0, 0))
			min_remain = minTime
			max_remain = maxTime
		else:
			remains.insert(0, (min_remain, max_remain))
			min_remain += minTime
			max_remain += maxTime
	time = sumTime
	act_times = []
	for i in range(d):
		minTime = allowed_times[i][0]
		maxTime = allowed_times[i][1]
		minRemain = remains[i][0]
		maxRemain = remains[i][1]
		t1 = time - minRemain
		t2 = time - maxRemain
		if t1 > maxTime:
			t = max(t2, minTime)
		else:
			t = min(t1, maxTime)
		act_times.append(str(t))
		time -= t
	print(' '.join(act_times))


(d, sumTime) = map(int, input().split())
sum2 = 0
sumlist = []
output = []
lisa = []
for i in range(d):
	(a, b) = map(int, input().split())
	lisa.append(a)
	sum2 += b
	sumlist.append((a, b))
	output.append(b)
if sum2 < sumTime:
	print('NO')
elif sum(lisa) > sumTime:
	print('NO')
else:
	print('YES')
	kamkarnahai = sum2 - sumTime
	length = len(sumlist)
	for i in range(length):
		if kamkarnahai == 0:
			break
		if kamkarnahai >= sumlist[i][1] - sumlist[i][0]:
			kamkarnahai -= sumlist[i][1] - sumlist[i][0]
			output[i] = sumlist[i][0]
		else:
			output[i] -= kamkarnahai
			break
	for i in output:
		print(i, end=' ')


(numDays, sumTime) = map(int, input().split())
min_max_list = []
min_sum = 0
max_sum = 0
for itr in range(numDays):
	(minStudy, maxStudy) = map(int, input().split())
	min_sum += minStudy
	max_sum += maxStudy
	min_max_list.append((minStudy, maxStudy))
if min_sum > sumTime or max_sum < sumTime:
	print('NO')
else:
	print('YES')
	sum_diff = sumTime - min_sum
	for x in range(numDays - 1):
		local_min = min_max_list[x][0]
		local_max = min_max_list[x][1]
		if local_max - local_min < sum_diff:
			print(local_max, end=' ')
			sum_diff -= local_max - local_min
		else:
			print(local_min + sum_diff, end=' ')
			sum_diff = 0
	print(min_max_list[numDays - 1][0] + sum_diff)


def bool_as_yes_no(boolean):
	return 'YES' if boolean else 'NO'

def read_integers():
	return list(map(int, input().split()))
(days, sumTime) = read_integers()
minTime = [0] * days
maxTime = [0] * days
for i in range(days):
	(minTime[i], maxTime[i]) = read_integers()
overallMin = sum(minTime)
overallMax = sum(maxTime)
ok = sumTime in range(overallMin, overallMax + 1)
print(bool_as_yes_no(ok))
if ok:
	i = 0
	while i < days and sumTime > overallMin:
		overallMin -= minTime[i]
		time = min(sumTime - overallMin, maxTime[i])
		print(time, end=' ')
		sumTime -= time
		i += 1
	while i < days:
		print(minTime[i], end=' ')
		i += 1


[d, sumTime] = list(map(int, input().split()))
listmn = []
listmx = []
mn = 0
mx = 0
for days in range(d):
	[a, b] = list(map(int, input().split()))
	mn += a
	mx += b
	listmn.append(a)
	listmx.append(b)
if sumTime > mx or sumTime < mn:
	print('NO')
else:
	print('YES')
	emn = sumTime - mn
	for i in range(d):
		st = 0
		if emn > 0:
			st = min(emn, listmx[i] - listmn[i])
			emn -= st
		print(listmn[i] + st, end=' ')


from array import *
data_min = array('i')
data_max = array('i')
data = array('i')
day = input()
s = day.split()
total = int(s[1])
day = int(s[0])
for i in range(day):
	s = input()
	s = s.split()
	data_min.insert(i, int(s[0]))
	data_max.insert(i, int(s[1]))
	s = ''
sum_min = 0
sum_max = 0
for i in range(day):
	sum_min = sum_min + data_min[i]
	sum_max = sum_max + data_max[i]
if sum_min > total:
	print('NO')
elif sum_max < total:
	print('NO')
else:
	print('YES\n')
	for i in range(day):
		data.insert(i, int(data_min[i]))
	for i in range(day):
		if sum_min == total:
			break
		while data[i] < data_max[i]:
			data[i] = data[i] + 1
			sum_min = sum_min + 1
			if sum_min == total:
				break
	for i in range(day):
		s = s + str(data[i]) + ' '
	print(s)


(d, s) = map(int, input().split())
slack = 0
res = []
Mx = []
for _ in range(d):
	(m, M) = map(int, input().split())
	s -= m
	slack += M - m
	res.append(m)
	Mx.append(M - m)
if s < 0 or s > slack:
	print('NO')
else:
	print('YES')
	for i in range(d):
		res[i] += min(Mx[i], max(s, 0))
		s -= Mx[i]
	print(' '.join(map(str, res)))


class Day:

	def __init__(self, min_time, max_time):
		self._min_time = min_time
		self._max_time = max_time
		self._all_time = 0

	@property
	def min_time(self):
		return self._min_time

	@property
	def max_time(self):
		return self._max_time

	@property
	def all_time(self):
		return self._all_time

	def set_all_time(self, value):
		self._all_time += value

	def __repr__(self):
		return f'{self._min_time}, {self._max_time}, {self._all_time}'

def main():
	(d, hours) = map(int, input().split())
	days = list()
	for _ in range(d):
		(min_time, max_time) = map(int, input().split())
		days.append(Day(min_time, max_time))
	hours = get_min_time(days, hours)
	if hours < 0:
		print('NO')
		return
	elif hours == 0:
		print('YES')
		for day in days:
			print(day.all_time, end=' ')
		print()
		return
	status = get_max_time(days, hours)
	if not status:
		print('NO')
		return
	print('YES')
	for day in days:
		print(day.all_time, end=' ')
	print()

def get_max_time(days, hours):
	for day in days:
		tail = day.max_time - day.min_time
		if hours >= tail:
			hours = hours - tail
			day.set_all_time(tail)
		else:
			day.set_all_time(hours)
			hours = 0
	if hours == 0:
		return True
	if hours > 0:
		return False

def get_min_time(days, hours):
	status = True
	for day in days:
		hours = hours - day.min_time
		day.set_all_time(day.min_time)
	return hours
main()


(a, b) = input().split()
a = int(a)
b = int(b)
s = []
r = []
for i in range(a):
	(j, k) = input().split()
	j = int(j)
	k = int(k)
	s.append(j)
	r.append(k)
if sum(r) < b or sum(s) > b:
	print('NO')
else:
	print('YES')
	u = 0
	k = [0] * a
	i = 0
	for i in range(a):
		k[i] += s[i]
		b = b - s[i]
	while b > 0:
		for i in range(a):
			if k[i] < r[i] and b > 0:
				k[i] += 1
				b = b - 1
			if b == 0:
				break
	k = list(map(str, k))
	print(' '.join(k))


(a, b) = [int(i) for i in input().split()]
l = []
g = []
for i in range(a):
	(c, d) = [int(i) for i in input().split()]
	l.append(c)
	g.append(d)
e = sum(l)
f = sum(g)
for i in range(0, len(l)):
	if c == b:
		break
	c = sum(l)
	if l[i] == g[i]:
		continue
	else:
		while l[i] < g[i]:
			l[i] = l[i] + 1
			c = c + 1
			if c == b:
				break
if b > f or b < e:
	print('NO')
else:
	print('YES')
	print(*l)


import sys
input = sys.stdin.readline
(d, s) = map(int, input().split())
mini = []
maxi = []
for i in range(d):
	(a, b) = map(int, input().split())
	mini.append(a)
	maxi.append(b)
smaxi = sum(maxi)
if sum(mini) > s or smaxi < s:
	print('NO')
else:
	a = smaxi - s
	lsm = []
	sm = 0
	for i in range(d):
		sm += mini[i]
		lsm.append(mini[i])
	if s > sm:
		a = sm - s
		for i in range(d):
			if maxi[i] - mini[i] > s - sm:
				lsm[i] = mini[i] + (s - sm)
				sm += s - sm
				break
			else:
				sm += maxi[i] - mini[i]
				lsm[i] = maxi[i]
	if sm == s:
		print('YES')
		print(*lsm)
	else:
		print('NO')


(n, Sum) = map(int, input().split())
Min = 0
Max = 0
A = [0] * n
B = [0] * n
for i in range(n):
	(A[i], B[i]) = map(int, input().split())
	Min += A[i]
	Max += B[i]
R = []
if Sum >= Min and Sum <= Max:
	print('YES')
	for i in range(n - 1, 0, -1):
		tmp = min(Sum + A[i] - Min, B[i])
		Sum -= tmp
		Min -= A[i]
		Max -= B[i]
		R.append(tmp)
	R.append(Sum)
	R = R[::-1]
	for i in R:
		print(i, end=' ')
	print()
else:
	print('NO')


(d, sumtime) = map(int, input().split())
summin = 0
summax = 0
mint = []
maxt = []
ans = 0
for i in range(d):
	(u, v) = map(int, input().split())
	summin += u
	summax += v
	mint.append(u)
	maxt.append(v)
if sumtime > summax or sumtime < summin:
	print('NO')
	exit()
req = sumtime - summin
bib = [0] * d
i = 0
while req > 0 and i < d:
	if maxt[i] - mint[i] > req:
		bib[i] += req
		req = 0
		break
	req -= maxt[i] - mint[i]
	bib[i] += maxt[i] - mint[i]
	i += 1
print('YES')
for i in range(d):
	print(mint[i] + bib[i], end=' ')


string = input().split(' ')
d = int(string[0])
sumTime = int(string[1])
mins = []
maxs = []
for i in range(d):
	string = input().split(' ')
	mins.append(int(string[0]))
	maxs.append(int(string[1]))
if not sum(mins) <= sumTime <= sum(maxs):
	print('NO')
else:
	days = maxs[:]
	currentSum = sum(maxs)
	for i in range(d):
		old = days[i]
		days[i] = max(days[i] - (currentSum - sumTime), mins[i])
		currentSum -= old - days[i]
		if currentSum == sumTime:
			break
	print('YES')
	print(' '.join((str(item) for item in days)))


(d, s_t) = list(map(int, input().split()))
t_s = 0
l_h = list()
l_t = list()
for i in range(d):
	l_h.append(list(map(int, input().split())))
	s_t -= l_h[i][0]
	t_s += l_h[i][1] - l_h[i][0]
if s_t < 0:
	print('NO')
elif s_t <= t_s:
	print('YES')
	for h in l_h:
		print(h[0] + min(s_t, h[1] - h[0]), end=' ')
		s_t -= min(s_t, h[1] - h[0])
else:
	print('NO')


initalData = input()
(daysLearned, sumTime) = initalData.split(' ')
(daysLearned, sumTime) = (int(daysLearned), int(sumTime))
minMaxList = []
DEBUG = False
for i in range(daysLearned):
	(minTime, maxTime) = input().split(' ')
	minMaxList.append([int(minTime), int(maxTime)])
high = sum((max(x) for x in minMaxList))
low = sum((min(x) for x in minMaxList))
if high < sumTime or low > sumTime:
	print('NO')
elif high == sumTime:
	print('YES')
	for x in minMaxList:
		print(max(x), end=' ')
elif high > sumTime:
	print('YES')
	newNums = list((max(x) for x in minMaxList))
	diff = high - sumTime
	count = 0
	while diff > 0:
		curDiff = minMaxList[count][1] - minMaxList[count][0]
		if DEBUG:
			print(diff, curDiff, count)
		if diff - curDiff < 0:
			if DEBUG:
				print('AAAAAA')
			newNums[count] = minMaxList[count][1] - diff
			diff = 0
		elif diff - curDiff == 0:
			if DEBUG:
				print('BBBB')
			newNums[count] = minMaxList[count][0]
			diff = 0
		else:
			if DEBUG:
				print('CCCC')
			newNums[count] = minMaxList[count][0]
			diff -= curDiff
		count += 1
	for x in newNums:
		print(x, end=' ')


import sys
is_first_line = True
hours_minmax = []
for line in sys.stdin:
	hours = tuple(map(int, line.split()))
	if is_first_line:
		(days_total, hours_total) = hours
		is_first_line = False
	else:
		hours_minmax.append(hours)
hours_min_sum = sum((h[0] for h in hours_minmax))
if hours_min_sum <= hours_total <= sum((h[1] for h in hours_minmax)):
	hours_left = hours_total - hours_min_sum
	result = []
	for day in range(days_total):
		(hours_min, hours_max) = hours_minmax[day]
		for hours_daily in range(hours_max - hours_min, -1, -1):
			if hours_daily <= hours_left:
				break
		result.append(hours_daily + hours_min)
		hours_left -= hours_daily
	print('YES')
	print(*result)
else:
	print('NO')


import sys
from array import array

def readline():
	return sys.stdin.buffer.readline().decode('utf-8')
(d, sumtime) = map(int, readline().split())
a = [tuple(map(int, readline().split())) for _ in range(d)]
res = [lb for (lb, _) in a]
sumtime -= sum(res)
if sumtime < 0:
	print('NO')
	exit()
for i in range(d):
	add = min(sumtime, a[i][1] - a[i][0])
	sumtime -= add
	res[i] += add
if sumtime == 0:
	print('YES')
	print(*res)
else:
	print('NO')


def main():
	(d, sumtime) = map(int, input().split())
	mi_time = []
	ma_time = []
	for _ in range(d):
		(mintime, maxtime) = map(int, input().split())
		mi_time.append(mintime)
		ma_time.append(maxtime)
	a = sum(mi_time)
	b = sum(ma_time)
	if a <= sumtime and sumtime <= b:
		print('YES')
		deficit = sumtime - a
		for i in range(d):
			if deficit > 0:
				extra = min(deficit, ma_time[i] - mi_time[i])
				deficit = deficit - extra
				print(mi_time[i] + extra, end=' ')
			else:
				print(mi_time[i], end=' ')
	else:
		print('NO')
main()


s = input().split()
d = int(s[0])
st = int(s[1])
mx1 = 0
mx2 = 0
cl = []
for i in range(d):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	mx1 += a
	mx2 += b
	cl.append((a, b))
if st >= mx1 and st <= mx2:
	res = ''
	sm = mx1
	i = 0
	while i < d:
		if sm < st:
			if sm + cl[i][1] - cl[i][0] < st:
				sm += cl[i][1] - cl[i][0]
				res += str(cl[i][1]) + ' '
			else:
				res += str(cl[i][0] + (st - sm)) + ' '
				sm = st
		else:
			res += str(cl[i][0]) + ' '
		i += 1
	print('YES')
	print(res)
else:
	print('NO')


(d, sumTime) = [int(s) for s in input().split()]
shedule = [0] * d
minT = [0] * d
maxT = [0] * d
delta = [0] * d
for i in range(d):
	(minT[i], maxT[i]) = [int(s) for s in input().split()]
	delta[i] = maxT[i] - minT[i]
if sum(minT) <= sumTime <= sum(maxT):
	print('YES')
	sumDelta = sumTime - sum(minT)
	for i in range(d):
		if sumDelta > 0:
			if delta[i] <= sumDelta:
				shedule[i] = minT[i] + delta[i]
				sumDelta -= delta[i]
			else:
				shedule[i] = minT[i] + sumDelta
				sumDelta = 0
		else:
			shedule[i] = minT[i]
	print(' '.join([str(s) for s in shedule]))
else:
	print('NO')


in1 = input().split(' ')
x = list(map(int, in1))
d = x[0]
ttime = x[1]
r = []
minsum = 0
maxsum = 0
for i in range(d):
	inpuut = input().split(' ')
	minsum += int(inpuut[0])
	maxsum += int(inpuut[1])
	r.append(list(map(int, inpuut)))
if minsum <= ttime and maxsum >= ttime:
	print('YES')
	extra = ttime - minsum
	z = 0
	while z < len(r):
		add = r[z][1] - r[z][0]
		if extra >= add:
			extra -= add
			print(r[z][1], end=' ')
		elif add > extra:
			print(int(r[z][0]) + extra, end=' ')
			extra = 0
		z += 1
else:
	print('NO')


def solve(d, sum_time, minimums, maximums):
	if sum_time < sum(minimums) or sum_time > sum(maximums):
		print('NO')
	else:
		answer = minimums[:]
		for i in range(d):
			while sum(answer) != sum_time and answer[i] < maximums[i]:
				answer[i] += 1
		print('YES')
		print(*answer)
	pass
minimums = []
maximums = []
(d, sum_time) = [int(x) for x in input().split()]
for i in range(d):
	(left, right) = [int(x) for x in input().split()]
	minimums.append(left)
	maximums.append(right)
solve(d, sum_time, minimums, maximums)


(d, s) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(d)]
mn = 0
mx = 0
for i in range(d):
	mn += arr[i][0]
	mx += arr[i][1]
if mn <= s <= mx:
	s -= mn
	print('YES')
	for i in range(d):
		if s == 0:
			print(arr[i][0], end=' ')
		elif s <= arr[i][1] - arr[i][0]:
			print(arr[i][0] + s, end=' ')
			s -= s
		else:
			print(arr[i][1], end=' ')
			s -= arr[i][1] - arr[i][0]
	print()
else:
	print('NO')


(d, s) = map(int, input().split())
l = []
li = []
for i in range(d):
	(a, b) = map(int, input().split())
	l.append(a)
	li.append(b)
if sum(l) <= s and sum(li) >= s:
	print('YES')
	if sum(l) < s:
		s -= sum(l)
		for i in range(d):
			c = li[i] - l[i]
			if c < s:
				s -= c
				l[i] += c
			elif c == s:
				l[i] += c
				break
			elif c > s:
				l[i] += s
				break
	for i in l:
		print(i, end=' ')
else:
	print('NO')


(n, s) = map(int, input().split())
done = 0
mintime = []
maxtime = []
ans = []
for _ in range(n):
	(a, b) = map(int, input().split())
	mintime.append(a)
	maxtime.append(b)
if sum(mintime) <= s and sum(maxtime) >= s:
	whole = sum(mintime)
	for i in range(n):
		temp = whole - mintime[i]
		whole -= mintime[i]
		temp = s - done - temp
		done += min(maxtime[i], temp)
		ans.append(min(maxtime[i], temp))
	print('YES')
	for i in ans:
		print(i, end=' ')
else:
	print('NO')


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for __ in range(t):
	(d, st) = map(int, input().split())
	x = []
	y = []
	for i in range(d):
		(xi, yi) = map(int, input().split())
		x.append(xi)
		y.append(yi)
	if st >= sum(x[:]) and st <= sum(y[:]):
		print('YES')
		ans = []
		for i in range(d - 1):
			for j in range(x[i], y[i] + 1):
				if st - j >= sum(x[i + 1:]) and st - j <= sum(y[i + 1:]):
					st -= j
					ans.append(j)
					break
		for j in range(x[-1], y[-1] + 1):
			if st - j == 0:
				ans.append(j)
				break
		for i in range(d):
			print(ans[i], end=' ')
		print()
	else:
		print('NO')


(d, h) = map(int, input().split())
arr = []
(lt, ht) = (int(0), int(0))
for _ in range(d):
	(a, b) = map(int, input().split())
	arr.append([a, b])
	lt += a
	ht += b
if lt <= h <= ht:
	print('YES')
	wtime = ht - h
	for [x, y] in arr:
		if wtime > 0:
			if y - x <= wtime:
				print(x, end=' ')
				wtime -= y - x
			else:
				print(y - wtime, end=' ')
				wtime = int(0)
		else:
			print(y, end=' ')
else:
	print('NO')


(d, sumTime) = [int(i) for i in input().split()]
(t0, t1) = (0, 0)
day = {}
for i in range(d):
	(minTime, maxTime) = [int(i) for i in input().split()]
	day[i] = [minTime, maxTime]
	t0 += minTime
	t1 += maxTime - minTime
if sumTime >= t0 and sumTime <= t0 + t1:
	print('YES')
	t = t0
	hours = []
	for i in range(d):
		if t == sumTime:
			hours.append(str(day[i][0]))
		else:
			extrahours = min(sumTime - t, day[i][1] - day[i][0])
			t += extrahours
			hours.append(str(day[i][0] + extrahours))
	print(' '.join(hours))
else:
	print('NO')


(d, sumTime) = input().strip().split(' ')
(d, sumTime) = [int(d), int(sumTime)]
mintime = []
maxtime = []
for i in range(d):
	(x, y) = input().strip().split(' ')
	mintime.append(int(x))
	maxtime.append(int(y))
mintimesum = sum(mintime)
maxtimesum = sum(maxtime)
if mintimesum <= sumTime and maxtimesum >= sumTime:
	print('YES')
	for i in range(d):
		temp = min(mintime[i] + sumTime - mintimesum, maxtime[i])
		if i + 1 < d:
			print(temp, '', end='')
		else:
			print(temp, ' \n', end='')
		sumTime -= temp - mintime[i]
else:
	print('NO')


def f(d, total, a):
	(minsum, maxsum) = (0, 0)
	for i in range(d):
		minsum += a[i][0]
		maxsum += a[i][1]
	if total < minsum or total > maxsum:
		return (False, [])
	else:
		ans = [a[i][0] for i in range(d)]
		left = total - minsum
		i = 0
		while i < d and left > 0:
			ans[i] += min(a[i][1] - a[i][0], left)
			left -= min(a[i][1] - a[i][0], left)
			i += 1
		return (True, ans)
(d, total) = map(int, input().split())
a = []
for i in range(d):
	(x, y) = map(int, input().split())
	a.append((x, y))
(possible, ans) = f(d, total, a)
if possible:
	print('YES')
	print(*ans)
else:
	print('NO')


import sys
firstLine = sys.stdin.readline().rstrip()
firstElems = firstLine.split(' ')
numDays = int(firstElems[0])
totalNumHours = int(firstElems[1])
minTimes = list()
maxTimes = list()
for i in range(0, numDays):
	line = sys.stdin.readline().rstrip()
	temp = line.split(' ')
	minTime = int(temp[0])
	maxTime = int(temp[1])
	minTimes.append(minTime)
	maxTimes.append(maxTime)
minimumTotalTime = sum(minTimes)
timeAchieved = minimumTotalTime
if timeAchieved >= totalNumHours:
	pass
else:
	for i in range(0, len(minTimes)):
		essketit = True
		while minTimes[i] < maxTimes[i] and essketit:
			timeAchieved += 1
			minTimes[i] += 1
			if timeAchieved == totalNumHours:
				essketit = False
		if not essketit:
			break
if timeAchieved == totalNumHours:
	print('YES')
	for n in minTimes:
		print(n, end=' ')
	print()
else:
	print('NO')


(d, s) = map(int, input().split())
minm = []
maxm = []
for i in range(d):
	(a, b) = map(int, input().split())
	minm.append(a)
	maxm.append(b)
x = sum(minm)
y = sum(maxm)
if x <= s and y >= s:
	print('YES')
	s = s - x
	i = 0
	while s > 0:
		p = min(maxm[i] - minm[i], s)
		minm[i] += p
		s -= p
		i += 1
	print(*minm)
else:
	print('NO')


(d, sumd) = [int(i) for i in input().split()]
days = []
min_ = 0
max_ = 0
for i in range(d):
	(mi, ma) = [int(r) for r in input().split()]
	min_ += mi
	max_ += ma
	days.append((mi, ma))
if max_ >= sumd >= min_:
	print('YES')
	ans = []
	summ = 0
	for i in range(d):
		ans.append(days[i][0])
		summ += days[i][0]
	k = 0
	while summ < sumd:
		delta = days[k][1] - ans[k]
		delta1 = sumd - summ
		if delta <= delta1:
			ans[k] = days[k][1]
			summ += delta
			k += 1
		else:
			ans[k] += delta1
			break
	print(*ans)
else:
	print('NO')


(d, sumTime) = map(int, input().strip().split())
arr = []
schedule = []
for i in range(d):
	arr.append(tuple(map(int, input().strip().split())))
	schedule.append(arr[i][0])
remaining = sumTime - sum(schedule)
i = 0
while remaining > 0 and i < d:
	extra = min(remaining, arr[i][1] - schedule[i])
	schedule[i] += extra
	remaining -= extra
	i += 1
if remaining == 0:
	print('YES')
	print(*schedule)
else:
	print('NO')


(d, sumTime) = [int(i) for i in input().split()]
(minTime, maxTime) = ([], [])
day_list = []
k = 0
while k < d:
	(minTi, maxTi) = [int(i) for i in input().split()]
	minTime.append(minTi)
	maxTime.append(maxTi)
	day_list.append((minTi, maxTi))
	k += 1
if sum(minTime) <= sumTime and sumTime <= sum(maxTime):
	schedule = []
	rest = sumTime - sum(minTime)
	for day in day_list:
		study = min(day[0] + rest, day[1])
		schedule.append(str(study))
		rest -= study - day[0]
	print('YES')
	print(' '.join(schedule))
else:
	print('NO')


(days, sum_time) = map(int, input().split(' '))
mx = []
mn = []
for i in range(days):
	temp = list(map(int, input().split(' ')))
	mn.append(temp[0])
	mx.append(temp[1])
if sum(mn) <= sum_time <= sum(mx):
	print('YES')
	sum_time -= sum(mn)
	for i in range(days):
		if sum_time != 0:
			if sum_time > mx[i] - mn[i]:
				sum_time -= mx[i] - mn[i]
				mn[i] = mx[i]
			else:
				mn[i] += sum_time
				break
		else:
			break
	[print(i, end=' ') for i in mn]
	print()
else:
	print('NO')


(d, s) = [int(i) for i in input().split()]
o = []
x = []
for i in range(d):
	(a, b) = [int(i) for i in input().split()]
	o.append(a)
	x.append(b)
if s < sum(o) or s > sum(x):
	print('NO')
else:
	print('YES')
	s = s - sum(o)
	if s > 0:
		for i in range(d):
			while o[i] < x[i] and s > 0:
				o[i] = o[i] + 1
				s -= 1
			if s == 0:
				break
	p = []
	for i in range(d):
		p.append(str(o[i]))
	print(' '.join(p))


(d, T) = list(map(int, input().split()))
Ans = d * [0]
Extra = d * [0]
for i in range(d):
	(Ans[i], Extra[i]) = list(map(int, input().split()))
	Extra[i] -= Ans[i]
	T -= Ans[i]
if T < 0:
	print('NO')
else:
	for i in range(d):
		Ans[i] += min(Extra[i], T)
		T -= min(Extra[i], T)
		if T == 0:
			break
	if T > 0:
		print('NO')
	else:
		print('YES\n' + ' '.join(map(str, Ans)))


(d, s) = map(int, input().split())
(mi, ma) = ([], [])
for i in range(d):
	(mi0, ma0) = map(int, input().split())
	s -= mi0
	if s < 0:
		print('NO')
		quit()
	mi += [mi0]
	ma += [ma0]
for i in range(d):
	s -= ma[i] - mi[i]
	if s <= 0:
		mi[i] += s + ma[i] - mi[i]
		print('YES')
		for j in range(i):
			print(str(ma[j]), end=' ')
		for j in range(i, d):
			print(str(mi[j]), end=' ')
		quit()
print('NO')


(d, sumT) = map(int, input().split(' '))
Min = [None] * d
Max = [None] * d
min = 0
max = 0
for i in range(d):
	(Min[i], Max[i]) = map(int, input().split(' '))
	min += Min[i]
	max += Max[i]
if sumT < min or sumT > max:
	print('NO')
else:
	studyT = [None] * d
	for i in range(d):
		studyT[i] = Min[i]
		sumT -= Min[i]
	for i in range(d):
		if Max[i] - Min[i] < sumT:
			studyT[i] = Max[i]
			sumT -= Max[i] - Min[i]
		else:
			studyT[i] += sumT
			break
	print('YES')
	print(*studyT)


import sys
import copy
inp = [int(x) for x in sys.stdin.readline().strip().split(' ')]
(days, goal) = (inp[0], inp[1])
sum_mins = 0
sum_maxs = 0
mins = []
maxs = []
for i in range(0, days):
	inp = [int(x) for x in sys.stdin.readline().strip().split(' ')]
	(mmin, mmax) = (inp[0], inp[1])
	sum_mins += mmin
	sum_maxs += mmax
	mins.append(mmin)
	maxs.append(mmax)
if not (goal >= sum_mins and goal <= sum_maxs):
	print('NO')
	sys.exit()
cursum = sum_mins
days_hours = copy.deepcopy(mins)
for j in range(0, 9):
	for i in range(0, days):
		if cursum >= goal:
			break
		cur = mins[i] + j
		if cur <= maxs[i] and j != 0:
			cursum += 1
			days_hours[i] += 1
print('YES')
days_hours = [str(a) for a in days_hours]
print(' '.join(days_hours))


(d, s) = map(int, input().split())
mini = []
maxi = []
for i in range(d):
	(m1, m2) = map(int, input().split())
	mini.append(m1)
	maxi.append(m2)
if sum(mini) > s or sum(maxi) < s:
	print('NO')
else:
	print('YES')
	if sum(mini) < s:
		z = s - sum(mini)
		for i in range(d):
			if maxi[i] - mini[i] >= z:
				mini[i] = mini[i] + z
				break
			else:
				z = z - maxi[i] + mini[i]
				mini[i] = maxi[i]
		print(*mini)
	else:
		print(*mini)


s = input().split(' ')
d = int(s[0])
total = int(s[1])
dayScMin = []
dayScMax = []
hisTotal = 0
for i in range(d):
	cs = input().split(' ')
	dayScMin += [int(cs[0])]
	dayScMax += [int(cs[1])]
currSum = sum(dayScMin)
diff = total - currSum
if diff >= 0:
	for i in range(d):
		if diff <= dayScMax[i] - dayScMin[i]:
			dayScMin[i] += diff
			currSum += diff
			diff = 0
		else:
			temp = dayScMax[i] - dayScMin[i]
			diff -= temp
			dayScMin[i] = dayScMax[i]
			currSum += temp
if diff == 0:
	print('YES')
	for i in range(d):
		print(dayScMin[i], end=' ')
else:
	print('NO')


(days, hours) = map(int, input().split())
time = [list(map(int, input().split())) for i in range(days)]
min_sum = 0
max_sum = 0
resp = [0] * days
remaining = hours
for i in range(days):
	min_sum += time[i][0]
	max_sum += time[i][1]
	resp[i] = time[i][0]
	remaining -= time[i][0]
if hours < min_sum or hours > max_sum:
	print('NO')
	exit()
i = 0
while remaining > 0:
	dif = time[i][1] - time[i][0]
	aux = min(dif, remaining)
	resp[i] += aux
	remaining -= aux
	i += 1
print('YES')
for day in resp:
	print(day, end=' ')


def read_ints():
	return map(lambda s: int(s), input().split(' '))

def main():
	(d, sumtime) = read_ints()
	intervals = []
	times = []
	for _ in range(d):
		(mintime, maxtime) = read_ints()
		intervals.append((mintime, maxtime))
		times.append(mintime)
	needed = sumtime - sum(times)
	if needed < 0:
		print('NO')
		return
	for i in range(d):
		extra = min(needed, intervals[i][1] - times[i])
		times[i] += extra
		needed -= extra
	if needed > 0:
		print('NO')
	else:
		print('YES')
		print(' '.join(map(lambda t: str(t), times)))
main()


(d, t) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(d)]
b = list(zip(*a))
mn = sum(b[0])
zx = sum(b[1])
if mn <= t <= zx:
	print('YES')
	x = t - mn
	for (i, j) in a:
		y = min(j - i, x)
		x -= y
		print(i + max(0, y), end=' ')
else:
	print('NO')


def do():
	(d, sumT) = map(int, input().split())
	minT = []
	maxT = []
	T = []
	for i in range(d):
		(inp1, inp2) = map(int, input().split())
		minT.append(inp1)
		T.append(inp1)
		maxT.append(inp2)
	curSum = sum(T)
	if curSum > sumT:
		print('NO')
		return
	for i in range(d):
		if sumT - curSum <= maxT[i] - minT[i]:
			T[i] += sumT - curSum
			print('YES')
			T = list(map(str, T))
			print(' '.join(T))
			return
		else:
			T[i] += maxT[i] - minT[i]
			curSum += maxT[i] - minT[i]
	print('NO')
do()


daysTime = input()
arr = daysTime.split()
days = int(arr[0])
totalTime = int(arr[1])
dayMinMaxTimes = []
dayTimeDistribution = []
for x in range(days):
	dayMinMaxTimes.append(input().split())
for x in range(len(dayMinMaxTimes)):
	minT = int(dayMinMaxTimes[x][0])
	totalTime -= minT
	dayTimeDistribution.append(minT)
if totalTime > 0:
	for x in range(len(dayMinMaxTimes)):
		minT = int(dayMinMaxTimes[x][0])
		maxT = int(dayMinMaxTimes[x][1])
		diff = maxT - minT
		if diff > totalTime and totalTime > 0:
			dayTimeDistribution[x] += totalTime
			totalTime = 0
			break
		elif totalTime == 0:
			break
		totalTime -= diff
		dayTimeDistribution[x] += diff
if totalTime > 0 or totalTime < 0:
	print('NO')
else:
	print('YES')
	for x in dayTimeDistribution:
		print(x, end=' ')


[d, sumTime] = [eval(x) for x in str.split(input())]
minTime = []
maxTime = []
for i in range(d):
	[m, n] = [eval(x) for x in str.split(input())]
	minTime.append(m)
	maxTime.append(n)
if sum(minTime) <= sumTime <= sum(maxTime):
	print('YES')
	restTime = sumTime - sum(minTime)
	for k in range(d):
		if restTime >= maxTime[k] - minTime[k]:
			print(maxTime[k], end=' ')
			restTime -= maxTime[k] - minTime[k]
		elif 0 < restTime < maxTime[k] - minTime[k]:
			print(restTime + minTime[k], end=' ')
			restTime = 0
		else:
			print(minTime[k], end=' ')
else:
	print('NO')