Statues
시간 제한2초메모리 제한2048 MB
맨해튼 거리로 주어진 각 구간 길이와 마지막 좌표가 주어질 때, 격자 위 경로가 존재하는지 판정하고 하나를 출력한다.
문제
The mayor of a city wants to place statues at intersections around the city. The intersections in the city are at all points with integer coordinates. Distances between intersections are measured using Manhattan distance, defined as follows:
.
The city council has provided the following requirements for the placement of the statues:
- The first statue is placed at ;
- The -th statue is placed at ;
- For , the distance between the -th statue and the -th statue is .
It is allowed to place multiple statues at the same intersection.
Help the mayor find a valid arrangement of the statues, or determine that it does not exist.
입력
The first line contains an integer () — the number of statues.
The second line contains two integers and () — the coordinates of the intersection where the -th statue must be placed.
The third line contains integers () — the distance between the -th statue and the -th statue.
출력
Print YES if there is a valid arrangement of the statues. Otherwise, print NO.
If there is a valid arrangement, print a valid arrangement in the following lines. The -th of these lines must contain two integers and — the coordinates of the intersection where the -th statue is placed. You can print any valid arrangement if multiple exist.