```go
package main
import (
"bytes"
"fmt"
"os"
)
const mapSize = 1 << 23 // 8,388,608 slots for open-addressing hash table
var keys []int64
var values []int32
func initMap() {
keys = make([]int64, mapSize)
values = make([]int32, mapSize)
for i := 0; i < mapSize; i++ {
keys[i] = -1
}
}
func put(key int64, val int32) {
idx := (uint64(key) * 11400714819323198485) >> 41
mask := uint64(mapSize - 1)
idx &= mask
for keys[idx] != -1 && keys[idx] != key {
idx = (idx + 1) & mask
}
keys[idx] = key
values[idx] = val
}
func get(key int64) (int32, bool) {
idx := (uint64(key) * 11400714819323198485) >> 41
mask := uint64(mapSize - 1)
idx &= mask
for keys[idx] != -1 {
if keys[idx] == key {
return values[idx], true
}
idx = (idx + 1) & mask
}
return 0, false
}
type Node struct {
parent int32
diff int32
c int16
d int8
}
func sumOfDigits(c int16) int32 {
s := int32(0)
for c > 0 {
s += int32(c % 10)
c /= 10
}
return s
}
func main() {
var a int
if _, err := fmt.Scan(&a); err != nil {
return
}
initMap()
nodes := make([]Node, 0, 1000000)
currentQ := make([]int32, 0, 100000)
nextQ := make([]int32, 0, 100000)
nodes = append(nodes, Node{parent: -1, d: -1, c: 0, diff: 0})
currentQ = append(currentQ, 0)
startKey := (int64(0) << 32) | int64(uint32(0))
put(startKey, 0)
for len(currentQ) > 0 {
for _, currIdx := range currentQ {
curr := nodes[currIdx]
for d := 0; d <= 9; d++ {
c := curr.c
diff := curr.diff
nc := int16((d*a + int(c)) / 10)
m_digit := int32((d*a + int(c)) % 10)
ndiff := diff + int32(d) - int32(a)*m_digit
if ndiff < -5000000 || ndiff > 5000000 {
continue
}
if d != 0 && ndiff == int32(a)*sumOfDigits(nc) {
var buf bytes.Buffer
buf.WriteByte(byte(d + '0'))
p := currIdx
for p != 0 {
buf.WriteByte(byte(nodes[p].d + '0'))
p = nodes[p].parent
}
fmt.Println(buf.String())
return
}
key := (int64(nc) << 32) | int64(uint32(ndiff))
if _, ok := get(key); !ok {
if len(nodes) >= mapSize/4*3 {
fmt.Println("-1")
os.Exit(0)
}
nodes = append(nodes, Node{
parent: currIdx,
diff: ndiff,
c: nc,
d: int8(d),
})
idx := int32(len(nodes) - 1)
put(key, idx)
nextQ = append(nextQ, idx)
}
}
}
currentQ, nextQ = nextQ, currentQ
nextQ = nextQ[:0]
}
fmt.Println("-1")
}
```