On yet another of his adventures, Brian Bipai loses his way in an underground network of tunnels. Fortunately, he brought a map with him.
The map of the tunnel system identifies a series of
Brian Bipai does not know which of the points on the map he is located at.
He knows that an exit must exist somewhere, but not where it is.
However, he observes (based on his nearby surroundings) that he is definitely located at a point with
Brian Bipai would like you to determine all points on the map where he could potentially be at.
Furthermore, for each of those points
Constraints
For
Input Specification
The first line contains two integers
The following
Output Specification
For each possible point that Brian Bipai could be at, print
Sample Input
6 3
1 3 1
2 3 1
3 4 3
4 5 2
4 6 2
Sample Output
3 13
4 14
Explanation
Brian Bipai could be located at point
If he begins at point
If he begins at point
Comments