401365: GYM100418 E Hamilton traversal 2
Description
You have a K-dimentional parallelepiped with dimensions N1, N2... Nk You should traversal the parallelepiped in order to visit each cell only at once and returning into the original one. In one operation you can move into the neighboring cell either by coordinate N1 N2 ... or Nk.
InputThe first line of the input contains one integer K — number of dimensions. The second line contains K integer numbers N1, N2... Nk The third line contains K integers X1, X2... Xk representing your initial position.
Constraints: The product of N1, N2... Nk will be between 1 and 106 inclusive. K will be between 2 and 10.
OutputThe output should contain the word No if there is no such traversal. In the other case output the word Yes. The following lines should contain a string in the format “C <+,->” where C is the coordinate, + or - denote the increase or decrease of this coordinate respectively. Please see the samples below for the details.
ExamplesInput3Output
2 2 2
1 2 2
Yes
2 -
3 -
2 +
1 +
2 -
3 +
2 +
1 -