For problem statement at 0-999/700-799/770-779/770/problemC.txt this is a correct solution, but verifier at 0-999/700-799/770-779/770/verifierC.go ends with All 100 tests passed can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
// Configure fast I/O
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
// Helper function to read the next integer
next := func() int {
scanner.Scan()
val, _ := strconv.Atoi(scanner.Text())
return val
}
// Read n and k
// Check if input exists to avoid runtime errors on empty input
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
k := next()
// Read the main courses Polycarp needs to pass
targets := make([]int, k)
for i := 0; i < k; i++ {
targets[i] = next()
}
// Read the dependency graph
// adj[i] contains the list of courses that course i depends on
adj := make([][]int, n+1)
for i := 1; i <= n; i++ {
count := next()
if count > 0 {
adj[i] = make([]int, count)
for j := 0; j < count; j++ {
adj[i][j] = next()
}
}
}
// state array: 0 = unvisited, 1 = visiting (currently in recursion stack), 2 = visited
state := make([]byte, n+1)
result := make([]int, 0, n)
var dfs func(int) bool
// Depth First Search to build topological sort
dfs = func(u int) bool {
state[u] = 1 // Mark as visiting
for _, v := range adj[u] {
if state[v] == 1 {
return false // Cycle detected
}
if state[v] == 0 {
if !dfs(v) {
return false
}
}
}
state[u] = 2 // Mark as visited
result = append(result, u)
return true
}
// Process each main course
for _, t := range targets {
// Only start DFS if the node hasn't been visited yet
if state[t] == 0 {
if !dfs(t) {
fmt.Println("-1")
return
}
}
}
// Output the result
w := bufio.NewWriter(os.Stdout)
defer w.Flush()
fmt.Fprintln(w, len(result))
for i, val := range result {
if i > 0 {
w.WriteByte(' ')
}
fmt.Fprint(w, val)
}
w.WriteByte('\n')
}
```