← Home
```go
package main

import "fmt"

func solve(s int) int {
	// We want the minimum number with all distinct digits summing to s.
	// Strategy: use the largest digits first (to minimize the number of digits),
	// and then arrange them in ascending order (to get the smallest number).
	
	digits := []int{}
	remaining := s
	for d := 9; d >= 1 && remaining > 0; d-- {
		if remaining >= d {
			digits = append(digits, d)
			remaining -= d
		}
	}
	
	if remaining > 0 {
		// Not possible, but constraints guarantee 1 <= s <= 45
		return -1
	}
	
	// digits are in descending order, reverse to get ascending
	result := 0
	for i := len(digits) - 1; i >= 0; i-- {
		result = result*10 + digits[i]
	}
	return result
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var s int
		fmt.Scan(&s)
		fmt.Println(solve(s))
	}
}
```