```go
package main
import (
"bufio"
"os"
"strconv"
"strings"
)
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
func main() {
in := bufio.NewScanner(os.Stdin)
in.Buffer(make([]byte, 1024), 1<<20)
in.Split(bufio.ScanWords)
next := func() string {
in.Scan()
return in.Text()
}
t, _ := strconv.Atoi(next())
var out strings.Builder
for ; t > 0; t-- {
s := next()
n := len(s)
var pos [26][]int
for i := 0; i < n; i++ {
pos[int(s[i]-'a')] = append(pos[int(s[i]-'a')], i+1)
}
a := int(s[0] - 'a')
b := int(s[n-1] - 'a')
path := make([]int, 0, n)
if a <= b {
for c := a; c <= b; c++ {
path = append(path, pos[c]...)
}
} else {
for c := a; c >= b; c-- {
path = append(path, pos[c]...)
}
}
out.WriteString(strconv.Itoa(abs(a - b)))
out.WriteByte(' ')
out.WriteString(strconv.Itoa(len(path)))
out.WriteByte('\n')
for i, idx := range path {
if i > 0 {
out.WriteByte(' ')
}
out.WriteString(strconv.Itoa(idx))
}
out.WriteByte('\n')
}
w := bufio.NewWriter(os.Stdout)
w.WriteString(out.String())
w.Flush()
}
```