For problem statement at 2000-2999/2100-2199/2160-2169/2162/problemF.txt this is a correct solution, but verifier at 2000-2999/2100-2199/2160-2169/2162/verifierF.go ends with All 214 tests passed. can you fix the verifier? package main
import (
"bufio"
"io"
"os"
"strconv"
)
func main() {
data, _ := io.ReadAll(os.Stdin)
idx := 0
nextInt := func() int {
for idx < len(data) && (data[idx] < '0' || data[idx] > '9') {
idx++
}
x := 0
for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
x = x*10 + int(data[idx]-'0')
idx++
}
return x
}
t := nextInt()
out := bufio.NewWriterSize(os.Stdout, 1<<20)
defer out.Flush()
for ; t > 0; t-- {
n, m := nextInt(), nextInt()
l := make([]int, m)
r := make([]int, m)
gl, gr := 1, n
for i := 0; i < m; i++ {
l[i], r[i] = nextInt(), nextInt()
if l[i] > gl {
gl = l[i]
}
if r[i] < gr {
gr = r[i]
}
}
ans := make([]int, n)
for i := range ans {
ans[i] = -1
}
if gl <= gr {
ans[gl-1] = 0
cur := 1
for i := 0; i < n; i++ {
if ans[i] == -1 {
ans[i] = cur
cur++
}
}
} else {
found := false
a, b := -1, -1
for pos := 1; pos <= n && !found; pos++ {
has := false
L, R := 1, n
for i := 0; i < m; i++ {
if l[i] <= pos && pos <= r[i] {
if !has {
L, R = l[i], r[i]
has = true
} else {
if l[i] > L {
L = l[i]
}
if r[i] < R {
R = r[i]
}
}
}
}
if !has {
a = pos
if pos == 1 {
b = 2
} else {
b = 1
}
found = true
} else if L != pos || R != pos {
a = pos
if L != pos {
b = L
} else {
b = pos + 1
}
found = true
}
}
if found {
ans[a-1] = 0
ans[b-1] = 1
cur := 2
for i := 0; i < n; i++ {
if ans[i] == -1 {
ans[i] = cur
cur++
}
}
} else {
ans[0] = 0
ans[1] = 2
ans[2] = 1
cur := 3
for i := 3; i < n; i++ {
ans[i] = cur
cur++
}
}
}
for i := 0; i < n; i++ {
if i > 0 {
out.WriteByte(' ')
}
out.WriteString(strconv.Itoa(ans[i]))
}
out.WriteByte('\n')
}
}