Bender Problem(翻译)

来源:https://codeforces.com/contest/28/problem/A

Bender Problem

Robot Bender decided to make Fray a birthday present. He drove n nails and numbered them from 1 to n in some order. Bender decided to make a picture using metal rods. The picture is a closed polyline, which vertices should be nails (in the given order). The segments of the polyline should be parallel to the coordinate axes. Polyline is allowed to have self-intersections. Bender can take a rod and fold it exactly once in any place to form an angle of 90 degrees. Then he can attach the place of the fold to some unoccupied nail and attach two ends of this rod to adjacent nails. A nail is considered unoccupied if there is no rod attached to it (neither by it's end nor the by the fold place). No rod could be used twice. It is not required to use all the rods.

Help Bender to solve this difficult task.

Input

The first line contains two positive integers n and m (4 ≤ n ≤ 500, 2 ≤ m ≤ 500, n is even) — the amount of nails and the amount of rods. i-th of the following n lines contains a pair of integers, denoting the coordinates of the i-th nail. Nails should be connected in the same order as they are given in the input. The last line contains m integers — the lenghts of the rods. All coordinates do not exceed 104 by absolute value. Lengths of the rods are between 1 and 200 000. No rod can be used twice. It is guaranteed that all segments of the given polyline are parallel to coordinate axes. No three consecutive nails lie on the same line.

Output

If it is impossible to solve Bender's problem, output NO. Otherwise, output YES in the first line, and in the second line output n numbers — i-th of them should be the number of rod, which fold place is attached to the i-th nail, or -1, if there is no such rod.

If there are multiple solutions, print any of them.

Examples

input

4 2
0 0
0 2
2 2
2 0
4 4

output

YES
1 -1 2 -1 

input

6 3
0 0
1 0
1 1
2 1
2 2
0 2
3 2 3

output

YES
1 -1 2 -1 3 -1 

input

6 3
0 0
1 0
1 1
2 1
2 2
0 2
2 2 3

output

NO

 翻译:

机器人本德尔决定给弗雷做生日礼物。他驾驶‎‎n‎‎个钉子,并按某种顺序将它们从‎‎1‎‎编号到‎‎n‎‎。Bender决定用金属棒制作一幅画。该图片是一条闭合的折线,其顶点应为钉子(按给定顺序)。折线的线段应平行于坐标轴。允许折线具有自交点。Bender可以拿起一根杆,在任何地方折叠一次,形成90度的角度。然后,他可以将褶皱的位置连接到一些未占用的钉子上,并将该杆的两端连接到相邻的钉子上。如果钉子上没有杆连接到它(无论是在它的末端还是在折叠的地方),则认为钉子是空的。任何杆都不能使用两次。不需要使用所有的棒。‎

‎帮助本德尔解决这个困难的任务。‎

‎输入‎

‎第一行包含两个正整数 ‎‎n‎‎ 和 ‎‎m‎‎(‎‎4 ≤ ‎‎n‎‎ ≤ 500,2 ≤ ‎‎m‎‎ ≤ 500‎‎,‎‎n‎‎ 是偶数)钉子的数量和杆的数量。以下 ‎‎n‎‎ 行中的第 ‎‎i‎‎ 行包含一对整数,表示第 ‎‎i‎‎ 个钉子的坐标。钉子的连接顺序应与输入中给出的顺序相同。最后一行包含 ‎‎m‎‎ 个整数 — 杆的长度。所有坐标不超过‎104‎按绝对值。棒的长度在‎‎1到‎‎200 000‎‎之间。任何杆都不能使用两次。可以保证给定折线的所有线段都平行于坐标轴。没有三个连续的钉子在同一条线上。‎

‎输出‎

‎如果无法解决本德尔的问题,则输出 ‎‎NO‎‎。否则,在第一行中输出 ‎‎YES‎‎,在第二行中输出 ‎‎n‎‎ 个数字  其中‎‎第 i‎‎ 个应该是杆数,折叠位置连接到第 ‎‎i‎‎ 个钉子上,如果没有这样的杆,则为 ‎‎-1‎‎。‎

‎如果有多个解决方案,请打印其中任何一个。‎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值