Write a program to computes the same as the program below, but much
more efficiently, both in space and in time. The read variables
n and m are such that
and
.
Every given pair of x and y is such that
.
|
|
|---|
Input
5 4 0 1 1 3 2 4 3 0 6 7 0 1 1 2 2 3 3 4 4 5 5 0 0 3 5 5 2 1 0 1 3 4 4 0 2 3
Output
NC yes no