← Home
For problem statement at 1000-1999/1300-1399/1380-1389/1385/problemE.txt this is a correct solution, but verifier at 1000-1999/1300-1399/1380-1389/1385/verifierE.go ends with All tests passed can you fix the verifier?  ```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	fmt.Fscan(in, &t)
	for tc := 0; tc < t; tc++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

		adj := make([][]int, n+1)
		inDeg := make([]int, n+1)
		directed := make([][2]int, 0)
		undirected := make([][2]int, 0)

		for i := 0; i < m; i++ {
			var typ, x, y int
			fmt.Fscan(in, &typ, &x, &y)
			if typ == 1 {
				adj[x] = append(adj[x], y)
				inDeg[y]++
				directed = append(directed, [2]int{x, y})
			} else {
				undirected = append(undirected, [2]int{x, y})
			}
		}

		q := make([]int, 0)
		for i := 1; i <= n; i++ {
			if inDeg[i] == 0 {
				q = append(q, i)
			}
		}

		topo := make([]int, 0, n)
		for i := 0; i < len(q); i++ {
			u := q[i]
			topo = append(topo, u)
			for _, v := range adj[u] {
				inDeg[v]--
				if inDeg[v] == 0 {
					q = append(q, v)
				}
			}
		}

		if len(topo) != n {
			fmt.Fprintln(out, "NO")
			continue
		}

		pos := make([]int, n+1)
		for i, v := range topo {
			pos[v] = i
		}

		fmt.Fprintln(out, "YES")
		for _, e := range directed {
			fmt.Fprintln(out, e[0], e[1])
		}
		for _, e := range undirected {
			u, v := e[0], e[1]
			if pos[u] < pos[v] {
				fmt.Fprintln(out, u, v)
			} else {
				fmt.Fprintln(out, v, u)
			}
		}
	}
}
```