seventh有一些点,这些点都是非负整数的坐标点,此外,如果某个点(x,y)属于该集合,那么所有的点(x',y'),也就是0≤x'≤x且0≤y'≤y也属于这个集合。
现在seventh要给这些点标点,点从1-n,seventh要给自己提高难度,所以他规定如果某个点(x,y)得到数字i,那么集合中的所有(x',y'),使得x'≥x且y'≥y必须分配一个不少于(x,y)的号码。
举个例子,对于四个点(0,0),(0,1),(1,0)和(1,1)的集合,存在两个美学上令人愉悦的编号。一个是1,2,3,4,另一个是1,3,2,4。
现在seventh的朋友Morning_X过来搞事情,他要挑战seventh,他规定s(x,y)= y - x,
现在他给seventh一些值w1, w2,..., wn, 现在他要求seventh在集合内找到符合规则的数字,并使得得到数字i的点具有与wi相等的特殊值,即s(xi, yi) = yi - xi = wi.
现在seventh很快就解决了问题,并拿这个问题来考你们,希望你们也能迅速的解决
The first line of the input consists of a single integer n (1 ≤ n ≤ 100 000) — the number of points in the set Wilbur is playing with.
Next follow n lines with points descriptions. Each line contains two integers x and y (0 ≤ x, y ≤ 100 000), that give one point in Wilbur's set. It's guaranteed that all points are distinct. Also, it is guaranteed that if some point (x, y) is present in the input, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y, are also present in the input.
The last line of the input contains n integers. The i-th of them is wi ( - 100 000 ≤ wi ≤ 100 000) — the required special value of the point that gets number i in any aesthetically pleasing numbering.
第一行输入一个整数n,代表接下来有n个点在集合在
接下来有n行,包含2个整数x 和y (0 ≤ x, y ≤ 100 000),在seventh 的集合内,如果存在某个点(x,y),则保证所有点(x',y')都存在,使得0≤x'≤x且0≤y'≤y。
接下来一行包括n个整数,它们中的第i个是wi( - 100 000≤wi≤100 000) - 代表第i个点的所需特殊值。
If there exists an aesthetically pleasant numbering of points in the set, such that s(xi, yi) = yi - xi = wi, then print "YES" on the first line of the output. Otherwise, print "NO".
If a solution exists, proceed output with n lines. On the i-th of these lines print the point of the set that gets number i. If there are multiple solutions, print any of them.
如果在集合中存在这样的点数,使得s(xi,yi)= yi - xi = wi,那么在输出的第一行输出“YES”。否则,打印“否”。
如果存在解决方案,则用n行继续输出。在这些行的第i行打印得到数字i的集合的点。如果有多种解决方案,请打印其中的任何一个。
5
2 0
0 0
1 0
1 1
0 1
0 -1 -2 1 0
YES
0 0
1 0
2 0
0 1
1 1
3
1 0
0 0
2 0
0 1 2
NO
NoteIn the first sample, point (2, 0) gets number 3, point (0, 0) gets number one, point (1, 0) gets number 2, point (1, 1) gets number 5 and point (0, 1) gets number 4. One can easily check that this numbering is aesthetically pleasing and yi - xi = wi.
In the second sample, the special values of the points in the set are 0, - 1, and - 2 while the sequence that the friend gives to Wilbur is 0, 1, 2. Therefore, the answer does not exist.