← Home
```go
package main

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

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

	var t int
	if _, err := fmt.Fscan(reader, &t); err != nil {
		return
	}

	for i := 0; i < t; i++ {
		var s string
		fmt.Fscan(reader, &s)

		balance := 0
		minBalance := 0
		firstNeg := -1
		lastNeg := -1

		// 1-based indexing for logic tracking
		for idx, char := range s {
			if char == '+' {
				balance++
			} else {
				balance--
			}

			if balance < minBalance {
				minBalance = balance
			}

			if balance < 0 {
				if firstNeg == -1 {
					firstNeg = idx + 1
				}
				lastNeg = idx + 1
			}
		}

		if minBalance >= 0 {
			// Already valid, swap character with itself
			fmt.Fprintln(writer, "1 1")
		} else if balance < 0 || minBalance < -2 {
			// Impossible if:
			// 1. Total balance is negative (swapping maintains total count).
			// 2. Minimum balance goes below -2 (swapping can at most add +2 to a segment).
			fmt.Fprintln(writer, "-1")
		} else {
			// Swap the first character causing a negative balance ('-')
			// with the character immediately after the last negative balance position ('+').
			// firstNeg is the index of the first time balance drops below 0.
			// lastNeg is the index of the last time balance is below 0.
			// The +2 boost applies to the range [firstNeg, lastNeg], fixing the sequence.
			fmt.Fprintln(writer, firstNeg, lastNeg+1)
		}
	}
}
```