← Home
For problem statement at 1000-1999/1600-1699/1600-1609/1607/problemE.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1600-1609/1607/verifierE.go ends with all tests passed can you fix the verifier? ```go
package main

import (
	"io"
	"os"
	"strconv"
)

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	n := len(data)

	skipSpaces := func() {
		for idx < n && (data[idx] <= ' ') {
			idx++
		}
	}
	readInt := func() int {
		skipSpaces()
		sign := 1
		if idx < n && data[idx] == '-' {
			sign = -1
			idx++
		}
		val := 0
		for idx < n && data[idx] >= '0' && data[idx] <= '9' {
			val = val*10 + int(data[idx]-'0')
			idx++
		}
		return val * sign
	}
	readToken := func() string {
		skipSpaces()
		start := idx
		for idx < n && data[idx] > ' ' {
			idx++
		}
		return string(data[start:idx])
	}

	t := readInt()
	out := make([]byte, 0, 32*t)

	for ; t > 0; t-- {
		N := readInt()
		M := readInt()
		s := readToken()

		x, y := 0, 0
		minX, maxX, minY, maxY := 0, 0, 0, 0

		for i := 0; i < len(s); i++ {
			nx, ny := x, y
			switch s[i] {
			case 'L':
				nx--
			case 'R':
				nx++
			case 'U':
				ny--
			case 'D':
				ny++
			}
			newMinX := min(minX, nx)
			newMaxX := max(maxX, nx)
			newMinY := min(minY, ny)
			newMaxY := max(maxY, ny)
			if newMaxX-newMinX+1 > M || newMaxY-newMinY+1 > N {
				break
			}
			x, y = nx, ny
			minX, maxX = newMinX, newMaxX
			minY, maxY = newMinY, newMaxY
		}

		r := 1 - minY
		c := 1 - minX

		out = strconv.AppendInt(out, int64(r), 10)
		out = append(out, ' ')
		out = strconv.AppendInt(out, int64(c), 10)
		out = append(out, '\n')
	}

	os.Stdout.Write(out)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
```