In chess, rooks are able to move in a horizontal direction or in a vertical one. In one move, they can get to any other location on the board until reaching an obstacle or the end of the board. If there is another figure on the path, the rook hits the figure.
Having two rooks, we would like to know if they hit each other. Given the
y1coordinates of the first rook, and
y2coordinates of the second rook, print
Yesif they hit each other, and
1 2 5 2