Group Excursion

No attempts yetTime limit1sMemory limit128 MB

Problem

A group of tourists has the chance to visit many beautiful cities. Each member of the group names two cities and, for each of them, says whether they want to visit it or not. A tourist may name the same city twice, wanting to visit it one time and not wanting to visit it the other time.

Write a program that:

  • reads the tourists' preferences from standard input,
  • decides whether it is possible to build a list of cities to visit (the list may be empty) so that at least one wish of every tourist is fulfilled,
  • prints such a list of cities that satisfies all tourists to standard output.

Input

The first line contains two positive integers nn and mm (1n200001 \le n \le 20\,000, 1m80001 \le m \le 8\,000); nn is the number of tourists and mm is the number of cities. Tourists are numbered from 11 to nn and cities from 11 to mm.

Each of the next nn lines contains two nonzero integers separated by a single space. The ii-th of these lines contains the integers wiw_i and wiw'_i describing the wishes of tourist ii, where mwim-m \le w_i \le m, mwim-m \le w'_i \le m, wi0w_i \ne 0 and wi0w'_i \ne 0. A positive number means the tourist wants to visit the city with that number; a negative number means the tourist does not want to visit the city whose number equals its absolute value.

Output

On the first line, print a single non-negative integer ll, the number of cities to visit. On the second line, print the ll city numbers, in increasing order, that must be visited to satisfy all tourists. When l=0l = 0, print 00 on the first line and leave the second line empty.

If no list of cities (possibly empty) can satisfy every tourist, print the word NO on the first and only line.

If several lists of cities satisfy all tourists, print only the lexicographically smallest one. Formally, describe an answer by the binary string b1b2bmb_1 b_2 \dots b_m, where bj=1b_j = 1 if city jj is visited and bj=0b_j = 0 otherwise, and treat 00 as smaller than 11. Among all valid answers, choose the one whose string b1b2bmb_1 b_2 \dots b_m is lexicographically smallest (equivalently, scan the cities from 11 to mm and leave each city unvisited whenever the remaining cities can still be chosen so that every tourist is satisfied). Then print the visited cities in increasing order.