Under construction

Still being built. Things may change

Kernel Scheduler

Time limit2sMemory limit1024 MB

Summary
Given n tasks and m directed dependencies, keep at least m/2 of them so that the kept dependencies contain no cycle and print their ids.
Level

Medium5 of 10

Topics
Graph, Topological sort, Greedy
Solved
No attempts yet

Problem

You are developing the scheduling module for a new operating system. The module takes nn tasks to execute and the dependencies between them, then puts them in an order for execution.

More formally, the tasks are numbered from 1 to nn. You are given mm dependencies numbered from 1 to mm. The ii-th dependency is described by two numbers aia_i and bib_i, meaning that task aia_i must be executed before task bib_i.

Sometimes there are cyclical dependencies: task t1t_1 must run before t2t_2, t2t_2 before t3t_3, ..., tk−1t_{k-1} before tkt_k, and tkt_k before t1t_1. Cyclical dependencies break scheduling, so you must remove some of the given dependencies so that the remaining set has no cycles.

However, you still need to keep at least m/2m/2 of the original dependencies to preserve some of the original information. Write a program that performs this task.

Input

The first line contains nn and mm (2≤n≤1052 \le n \le 10^5, 1≤m≤3⋅1051 \le m \le 3 \cdot 10^5). Each of the next mm lines contains two numbers aia_i and bib_i (1≤ai,bi≤n1 \le a_i, b_i \le n, ai≠bia_i \ne b_i), describing the corresponding dependency between tasks aia_i and bib_i.

Output

The first line should contain YES if the desired subset of dependencies exists, and NO otherwise. In the YES case, the second line contains the number kk of selected dependencies (note that kk must be at least m/2m/2), and the third line contains the kk ids of the selected dependencies. The ids are numbered from 1 to mm in input order.

Examples3

  1. Example 1

    Input
    3 3
    1 2
    2 3
    3 1
    
    Expected output
    YES
    2
    1 2
    
  2. Example 2

    Input
    2 5
    1 2
    1 2
    1 2
    2 1
    2 1
    
    Expected output
    YES
    3
    1 2 3
    
  3. Example 3

    Input
    4 4
    1 2
    2 3
    2 4
    3 4
    
    Expected output
    YES
    4
    1 2 3 4