#K59462. Valid Route for Jumpicorn
Valid Route for Jumpicorn
Valid Route for Jumpicorn
You are given an (n \times n) grid and a route represented as a sequence of coordinates. The Jumpicorn must move between adjacent cells, meaning that for each consecutive pair of coordinates ((x_1, y_1)) and ((x_2, y_2)), the absolute differences satisfy (|x_2 - x_1| \le 1) and (|y_2 - y_1| \le 1). A route with a single coordinate is always considered valid. Your task is to determine whether the provided route is valid.
inputFormat
The first line of input contains two integers: (n) (the grid size) and (k) (the number of coordinates in the route). The following (k) lines each contain two integers representing the x and y coordinates of the route respectively.
outputFormat
Output a single line: (True) if the route is valid, or (False) otherwise.## sample
5 3
0 0
0 1
1 1
True