package main

import (
  "fmt"
  "math/big"
)

const Mod = 1000000007

var a string
var n, k int

func Pow2(p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return 2 % mod
  } else if p % 2 == 0 {
    tmp := Pow2(p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return 2 * Pow2(p - 1, mod) % mod
  }
}

func CalcConstant_slow() int64 {
  numer := (Pow2(int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (Pow2(int64(n), Mod) - 1 + Mod) % Mod
  for inverse := int64(0); inverse < Mod; inverse++ {
    if (denom * inverse) % Mod == numer {
      return inverse
    }
  }
  panic("no mult inverse")
}

func CalcConstant() int64 {
  numer := big.NewInt((Pow2(int64(n)*int64(k), Mod) - 1 + Mod) % Mod)
  denom := big.NewInt((Pow2(int64(n), Mod) - 1 + Mod) % Mod)
  x := big.NewInt(0).ModInverse(denom, big.NewInt(Mod))
  return big.NewInt(0).Mod(big.NewInt(0).Mul(numer, x), big.NewInt(Mod)).Int64()
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  fmt.Scan(&a)
  fmt.Scan(&k)
  //a = "13990" //"1256"
  //k = 2 //200000000
  n = len(a)
  fmt.Println(Solve())
}

package main

import (
  "fmt"
  "math/big"
  "bufio"
  "os"
  "strconv"
)

var rw *bufio.ReadWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func next() string {
  token := []byte{}
  for {
    c, err := rw.ReadByte()
    if err != nil || c == ' ' || c == '\n' {
      return string(token)
    } else if c == '\r' {
    _, _ = rw.ReadByte()
      return string(token)
    } else {
      token = append(token, c)
    }
  }
}

func ni() int {
  ans, _ := strconv.Atoi(next())
  return ans
}

const Mod = 1000000007

var a string
var n, k int

func Pow2(p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return 2 % mod
  } else if p % 2 == 0 {
    tmp := Pow2(p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return 2 * Pow2(p - 1, mod) % mod
  }
}

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant_verySlow() int64 {
  numer := (Pow2(int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (Pow2(int64(n), Mod) - 1 + Mod) % Mod
  for inverse := int64(0); inverse < Mod; inverse++ {
    if (denom * inverse) % Mod == numer {
      return inverse
    }
  }
  panic("no mult inverse")
}

func CalcConstant_slow() int64 {
  numer := big.NewInt((Pow2(int64(n)*int64(k), Mod) - 1 + Mod) % Mod)
  denom := big.NewInt((Pow2(int64(n), Mod) - 1 + Mod) % Mod)
  x := big.NewInt(0).ModInverse(denom, big.NewInt(Mod))
  return big.NewInt(0).Mod(big.NewInt(0).Mul(numer, x), big.NewInt(Mod)).Int64()
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  a = next()
  k = ni()
  //fmt.Scan(&a)
  //fmt.Scan(&k)
  //a = "13990" //"1256"
  //k = 2 //200000000
  n = len(a)
  fmt.Println(Solve())
}

package main

import (
  "fmt"
  "math/big"
)

const Mod = 1000000007

var a string
var n, k int

func Pow2(p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return 2 % mod
  } else if p % 2 == 0 {
    tmp := Pow2(p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return 2 * Pow2(p - 1, mod) % mod
  }
}

func CalcConstant() int64 {
  numer := big.NewInt((Pow2(int64(n)*int64(k), Mod) - 1 + Mod) % Mod)
  denom := big.NewInt((Pow2(int64(n), Mod) - 1 + Mod) % Mod)
  x := big.NewInt(0).ModInverse(denom, big.NewInt(Mod))
  return big.NewInt(0).Mod(big.NewInt(0).Mul(numer, x), big.NewInt(Mod)).Int64()
}

func Solve() (cnt int64) {
  for i, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + Pow2(int64(i), Mod)) % Mod
    }
  }
  cnt = (cnt * CalcConstant()) % Mod
  return
}

func main() {
  fmt.Scan(&a)
  fmt.Scan(&k)
  n = len(a)
  fmt.Println(Solve())
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextString() string {
  sc.Scan()
  return sc.Text()
}

func NextInt() int {
  n, _ := strconv.Atoi(NextString())
  return n
}

const Mod = 1000000007

var a string
var n, k int

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  sc.Split(bufio.ScanWords)
  fmt.Scan(&a)
  fmt.Scan(&k)
  n = len(a)
  fmt.Println(Solve())
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextString() string {
  sc.Scan()
  if err := sc.Err(); err != nil {
    fmt.Println("Err 1")
  }
  return sc.Text()
}

func NextInt() int {
  n, err := strconv.Atoi(NextString())
  if err != nil {
    fmt.Println("Err 2")
  }
  return n
}

const Mod = 1000000007

var a string
var n, k int

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  sc.Split(bufio.ScanWords)
  //a = NextString()
  //k = NextInt()
  //fmt.Println(a, k)
  fmt.Scan(&a)
  fmt.Scan(&k)
  //a = "13990" //"1256"
  //k = 2 //200000000
  n = len(a)
  fmt.Println(Solve())
}

package main

import (
  "fmt"
)

const Mod = 1000000007

var a string
var n, k int

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  fmt.Scan(&a)
  fmt.Scan(&k)
  n = len(a)
  fmt.Println(Solve())
}

package main

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

const mod = int(1e9) + 7
var s string
var k, n int

func pw(a int, b int) int {
	var ret = 1
	for b > 0 {
		if (b & 1) == 1 {
			b--
			ret = int(int64(ret) * int64(a) % int64(mod))
		} else {
			b /= 2
			a = int(int64(a) * int64(a) % int64(mod))
		}
	}
	return ret
}

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%s\n", &s)
	fmt.Fscanf(reader, "%d\n", &k)

	var blockCnt = 1
	var n = len(s)

	for i := 0; i < n; i++ {
		blockCnt = int(int64(blockCnt) * 2 % int64(mod))
	}

	var sufCnt = 0
	var mul = 1

	for i := 0; i < n; i++ {
		if s[i] == '0' || s[i] == '5' {
			sufCnt += mul
			sufCnt %= mod
		}
		mul = int(int64(mul) * 2 % int64(mod))
	}

	var inv = int64(1)
	for i := 1; i <= n; i++ {
		inv = inv * 2 % int64(mod)
	}
	inv = (inv - 1) % int64(mod)
	if inv < 0 {
		inv += int64(mod)
	}

	inv = int64(pw(int(inv), mod - 2))

	var upper = pw(2, int(int64(n) * int64(k) % int64(mod - 1)))

	upper = (upper - 1) % mod
	if upper < 0 {
		upper += mod
	}

	var ret = int64(upper) * int64(inv) % int64(mod) * int64(sufCnt) % int64(mod)
	fmt.Fprintf(writer, "%d", ret)
}

package main

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

type Scanner struct {
  r            io.Reader
  split        bufio.SplitFunc
  maxTokenSize int
  token        []byte
  buf          []byte
  start        int
  end          int
}

const MaxScanTokenSize = 16777216

func NewScanner(r io.Reader) *Scanner {
  return &Scanner{
    r:            r,
    split:        bufio.ScanWords,
    maxTokenSize: MaxScanTokenSize,
    buf:          make([]byte, 4096),
  }
}

func (s *Scanner) Text() string {
  return string(s.token)
}

func (s *Scanner) Scan() bool {
  for {
    if s.end > s.start {
      advance, token, err := s.split(s.buf[s.start:s.end], false)
      if err != nil || !s.advance(advance) {
        return false
      }
      s.token = token
      if token != nil {
        return true
      }
    }
    if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
      copy(s.buf, s.buf[s.start:s.end])
      s.end -= s.start
      s.start = 0
    }
    if s.end == len(s.buf) {
      if len(s.buf) >= s.maxTokenSize {
        return false
      }
      newSize := len(s.buf) * 2
      if newSize > s.maxTokenSize {
        newSize = s.maxTokenSize
      }
      newBuf := make([]byte, newSize)
      copy(newBuf, s.buf[s.start:s.end])
      s.buf = newBuf
      s.end -= s.start
      s.start = 0
      continue
    }
    for loop := 0; ; {
      n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
      s.end += n
      if n > 0 {
        break
      }
      loop++
      if loop > 100 {
        break
      }
    }
  }
}

func (s *Scanner) advance(n int) bool {
  if n < 0 || n > s.end-s.start {
    return false
  }
  s.start += n
  return true
}

func (s *Scanner) Split(split bufio.SplitFunc) {
  s.split = split
}

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var sc *Scanner = NewScanner(os.Stdin)

func next() string { sc.Scan(); return sc.Text() }

func ni32() int {
  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())
  return n
}

func ni64() int64 {
  sc.Scan()
  n, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return n
}

func pri32(i int)   { w.WriteString(strconv.Itoa(i)) }
func pri64(i int64) { w.WriteString(strconv.FormatInt(i, 10)) }
func sp()           { w.WriteByte(' ') }
func endl()         { w.WriteByte('\n') }

var mod int64 = 1000000007

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  s := next()
  k := ni32()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  ans := int64(0)
  x := int64(1)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (x*A)%mod) % mod
    }
    x *= 2
    if x >= mod {
      x -= mod
    }

  }
  pri64(ans)
  w.Flush()
}

package main

import (
  "bufio"
  "os"
  "strconv"
)

var rw *bufio.ReadWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func next() string {
  token := []byte{}
  for {
    c, err := rw.ReadByte()
    if err != nil || c == ' ' || c == '\n' {
      return string(token)
    } else if c == '\r' {
    _, _ = rw.ReadByte()
      return string(token)
    } else {
      token = append(token, c)
    }
  }
}

func ni() int {
  ans, _ := strconv.Atoi(next())
  return ans
}

func nll() int64 {
  ans, _ := strconv.ParseInt(next(), 10, 64)
  return ans
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { rw.WriteString(strconv.Itoa(n)) }
func prll(n int64) { rw.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { rw.WriteByte(' ') }
func endl()        { rw.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  ans := int64(0)
  x := int64(1)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (x*A)%mod) % mod
    }
    // prll(ans)
    // sp()
    x *= 2
    if x >= mod {
      x -= mod
    }

  }
  prll(ans)
  rw.Flush()
}

package main

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

type Scanner struct {
  r            io.Reader
  split        bufio.SplitFunc
  maxTokenSize int
  token        []byte
  buf          []byte
  start        int
  end          int
}

const (
  MaxScanTokenSize = 64 * 1024 * 256
)

func NewScanner(r io.Reader) *Scanner {
  return &Scanner{
    r:            r,
    split:        bufio.ScanWords,
    maxTokenSize: MaxScanTokenSize,
    buf:          make([]byte, 4096),
  }
}

func (s *Scanner) Text() string {
  return string(s.token)
}

func (s *Scanner) Scan() bool {
  for {
    if s.end > s.start {
      advance, token, err := s.split(s.buf[s.start:s.end], false)
      if err != nil || !s.advance(advance) {
        return false
      }
      s.token = token
      if token != nil {
        return true
      }
    }
    if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
      copy(s.buf, s.buf[s.start:s.end])
      s.end -= s.start
      s.start = 0
    }
    if s.end == len(s.buf) {
      if len(s.buf) >= s.maxTokenSize {
        return false
      }
      newSize := len(s.buf) * 2
      if newSize > s.maxTokenSize {
        newSize = s.maxTokenSize
      }
      newBuf := make([]byte, newSize)
      copy(newBuf, s.buf[s.start:s.end])
      s.buf = newBuf
      s.end -= s.start
      s.start = 0
      continue
    }
    for loop := 0; ; {
      n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
      s.end += n
      if n > 0 {
        break
      }
      loop++
      if loop > 100 {
        break
      }
    }
  }
}

func (s *Scanner) advance(n int) bool {
  if n < 0 || n > s.end-s.start {
    return false
  }
  s.start += n
  return true
}

func (s *Scanner) Split(split bufio.SplitFunc) {
  s.split = split
}

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var sc *Scanner = NewScanner(os.Stdin)

func next() string { sc.Scan(); return sc.Text() }

func ni32() int {
  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())
  return n
}

func ni64() int64 {
  sc.Scan()
  n, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return n
}

func pri32(i int)   { w.WriteString(strconv.Itoa(i)) }
func pri64(i int64) { w.WriteString(strconv.FormatInt(i, 10)) }
func sp()           { w.WriteByte(' ') }
func endl()         { w.WriteByte('\n') }

var mod int64 = 1000000007

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func dec(k int64) int64 {
  ans := k - 1
  if ans < 0 {
    ans += mod
  }
  return ans
}

func rroot(k int64) int64 {
  return binpow(k, mod-2)
}

func main() {
  s := next()
  k := ni64()
  l := len(s)
  A := (dec(binpow(binpow(2, int64(l)), k)) * rroot(dec(binpow(2, int64(l))))) % mod
  ans := int64(0)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans += (binpow(2, int64(i)) * A) % mod
      if ans >= mod {
        ans -= mod
      }
    }
  }
  pri64(ans % mod)
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2) //reverse root of (q-1)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  // prll(A)
  // endl()
  ans := int64(0)
  for i := 0; i < l; i++ {
    // pri(i)
    // sp()
    // prll((binpow(2, int64(i)) * A) % mod)
    // endl()
    if s[i] == '0' || s[i] == '5' {
      ans += (binpow(2, int64(i)) * A) % mod
      if ans >= mod {
        ans -= mod
      }
    }
  }
  prll(ans)
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func dec(k int64) int64 {
  ans := k - 1
  if ans < 0 {
    ans += mod
  }
  return ans
}

func rroot(k int64) int64 {
  return binpow(k, mod-2)
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  if len(s) == 0 {
    s = next()
  }
  k := nll()
  l := len(s)
  A := (dec(binpow(binpow(2, int64(l)), k)) * rroot(dec(binpow(2, int64(l))))) % mod
  ans := int64(0)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (binpow(2, int64(i))*A)%mod) % mod
    }
  }
  prll(ans)
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  if len(sc.Text()) == 0 {
    sc.Scan()
  }
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2) //reverse root of (q-1)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  // prll(A)
  // endl()
  ans := int64(0)
  for i := 0; i < l; i++ {
    // pri(i)
    // sp()
    // prll((binpow(2, int64(i)) * A) % mod)
    // endl()
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (binpow(2, int64(i))*A)%mod) % mod
    }
  }
  prll(ans)
  endl()
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  if len(sc.Text()) == 0 {
    sc.Scan()
  }
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  ans := int64(0)
  x := int64(1)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (x*A)%mod) % mod
    }
    x *= 2
    if x >= mod {
      x -= mod
    }

  }
  prll(ans)
  endl()
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  if len(sc.Text()) == 0 {
    sc.Scan()
  }
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  ans := int64(0)
  x := int64(1)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (x*A)%mod) % mod
    }
    x *= 2
    if x >= mod {
      x -= mod
    }

  }
  w.Flush()
  prll(ans % mod)
  endl()
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  if len(sc.Text()) == 0 {
    sc.Scan()
  }
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2) //reverse root of (q-1)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  // prll(A)
  // endl()
  ans := int64(0)
  for i := 0; i < l; i++ {
    // pri(i)
    // sp()
    // prll((binpow(2, int64(i)) * A) % mod)
    // endl()
    if s[i] == '0' || s[i] == '5' {
      ans += (binpow(2, int64(i)) * A) % mod
      if ans >= mod {
        ans -= mod
      }
    }
  }
  prll(ans)
  endl()
  w.Flush()
}

package main

import (
  "bufio"
  "os"
  "strconv"
)

var rw *bufio.ReadWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func next() string {
  token := []byte{}
  for {
    c, err := rw.ReadByte()
    if err != nil || c == ' ' || c == '\n' {
      return string(token)
    } else {
      token = append(token, c)
    }
  }
}

func ni() int {
  ans, _ := strconv.Atoi(next())
  return ans
}

func nll() int64 {
  ans, _ := strconv.ParseInt(next(), 10, 64)
  return ans
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { rw.WriteString(strconv.Itoa(n)) }
func prll(n int64) { rw.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { rw.WriteByte(' ') }
func endl()        { rw.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  ans := int64(0)
  x := int64(1)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (x*A)%mod) % mod
    }
    // prll(ans)
    // sp()
    x *= 2
    if x >= mod {
      x -= mod
    }

  }
  prll(ans)
  rw.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func dec(k int64) int64 {
  ans := k - 1
  if ans < 0 {
    ans += mod
  }
  return ans
}

func rroot(k int64) int64 {
  return binpow(k, mod-2)
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := nll()
  l := len(s)
  A := (dec(binpow(binpow(2, int64(l)), k)) * rroot(dec(binpow(2, int64(l))))) % mod
  ans := int64(0)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans = (ans + (binpow(2, int64(i))*A)%mod) % mod
    }
  }
  prll(ans % mod)
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func dec(k int64) int64 {
  ans := k - 1
  if ans < 0 {
    ans += mod
  }
  return ans
}

func rroot(k int64) int64 {
  return binpow(k, mod-2)
}

// A = ((2**len)**k-1) / (2**len-1)

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := nll()
  l := len(s)
  A := (dec(binpow(binpow(2, int64(l)), k)) * rroot(dec(binpow(2, int64(l))))) % mod
  ans := int64(0)
  for i := 0; i < l; i++ {
    if s[i] == '0' || s[i] == '5' {
      ans += (binpow(2, int64(i)) * A) % mod
      if ans >= mod {
        ans -= mod
      }
    }
  }
  prll(ans % mod)
  w.Flush()
}

package main

import (
  "bufio"
  // "math/big" //too slow, poor golang poor -_-
  "os"
  "strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func ni() int {
  sc.Scan()
  ans, _ := strconv.Atoi(sc.Text())
  return ans
}

func nll() int64 {
  sc.Scan()
  ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return ans
}

func next() string {
  sc.Scan()
  if len(sc.Text()) == 0 {
    sc.Scan()
  }
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func Min(i, j int) int {
  if i < j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

var mod int64 = 1000000007
var r []int64
var rroot int64

func binpow(a, n int64) int64 {
  if n == 0 {
    return int64(1)
  }
  if n%int64(2) == 1 {
    return (a * binpow(a, n-1)) % mod
  } else {
    b := binpow(a, n/2)
    return (b * b) % mod
  }
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  k := ni()
  l := len(s)
  q := binpow(2, int64(l))
  rq := q - 1
  if rq < 0 {
    rq += mod
  }
  rq = binpow(rq, mod-2) //reverse root of (q-1)
  qn := binpow(q, int64(k)) - 1
  if qn < 0 {
    qn += mod
  }
  A := (qn * rq) % mod
  // prll(A)
  // endl()
  ans := int64(0)
  for i := 0; i < l; i++ {
    // pri(i)
    // sp()
    // prll((binpow(2, int64(i)) * A) % mod)
    // endl()
    if s[i] == '0' || s[i] == '5' {
      ans += (binpow(2, int64(i)) * A) % mod
      if ans >= mod {
        ans -= mod
      }
    }
  }
  prll(ans % mod)
  endl()
  w.Flush()
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextString() string {
  sc.Scan()
  if err := sc.Err(); err != nil {
    fmt.Println("Err 1", err)
  }
  return sc.Text()
}

func NextInt() int {
  n, err := strconv.Atoi(NextString())
  if err != nil {
    fmt.Println("Err 2", err)
  }
  return n
}

const Mod = 1000000007

var a string
var n, k int

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  sc.Split(bufio.ScanWords)
  a = NextString()
  k = NextInt()
  //fmt.Println(a, k)
  //fmt.Scan(&a)
  //fmt.Scan(&k)
  //a = "13990" //"1256"
  //k = 2 //200000000
  n = len(a)
  fmt.Println(Solve())
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextString() string {
  sc.Scan()
  if err := sc.Err(); err != nil {
    fmt.Println("Err 1")
  }
  return sc.Text()
}

func NextInt() int {
  n, err := strconv.Atoi(NextString())
  if err != nil {
    fmt.Println("Err 2")
  }
  return n
}

const Mod = 1000000007

var a string
var n, k int

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  sc.Split(bufio.ScanWords)
  a = NextString()
  k = NextInt()
  //fmt.Println(a, k)
  //fmt.Scan(&a)
  //fmt.Scan(&k)
  //a = "13990" //"1256"
  //k = 2 //200000000
  n = len(a)
  fmt.Println(Solve())
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextString() string {
  sc.Scan()
  return sc.Text()
}

func NextInt() int {
  n, _ := strconv.Atoi(NextString())
  return n
}

const Mod = 1000000007

var a string
var n, k int

func PowMod(a, p, mod int64) int64 {
  if p == 0 {
    return 1
  } else if p == 1 {
    return a % mod
  } else if p % 2 == 0 {
    tmp := PowMod(a, p / 2, mod)
    return (tmp * tmp) % mod
  } else {
    return (a * PowMod(a, p - 1, mod)) % mod
  }
}

func CalcConstant() int64 {
  numer := (PowMod(2, int64(n)*int64(k), Mod) - 1 + Mod) % Mod
  denom := (PowMod(2, int64(n), Mod) - 1 + Mod) % Mod
  denomInverse := PowMod(denom, Mod - 2, Mod)
  return (denomInverse * numer) % Mod
}

func Solve() (cnt int) {
  pow2 := 1
  for _, c := range a {
    if c == '0' || c == '5' {
      cnt = (cnt + pow2) % Mod
    }
    pow2 = (pow2 * 2) % Mod
  }
  cnt = int((int64(cnt) * CalcConstant()) % Mod)
  return
}

func main() {
  sc.Split(bufio.ScanWords)
  a = NextString()
  k = NextInt()
  n = len(a)
  fmt.Println(Solve())
}


package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)

		mp := make(map[int]int)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
			mp[nums[i]] = i
		}

		if n == 1 {
			Fprintln(out, -1)
			continue
		}
		ans := make([]int, n)
		sort.Ints(nums)

		for i := range ans {
			// fmt.Println(nums, ans)
			sid := findSmallestIdx(nums, mp, i)
			// fmt.Println(sid)
			ans[i] = nums[sid]
			nums[sid] = -1
			if mp[ans[i]] == i {
				ans[i-1], ans[i] = ans[i], ans[i-1]
			}
		}
		Fprintln(out, strings.Trim(Sprint(ans), "[]"))

	}
}

func findSmallestIdx(nums []int, mp map[int]int, idx int) int {
	// fmt.Println("============================================")
	for i := range nums {
		// fmt.Println(nums[i], mp[nums[i]])
		if nums[i] != -1 && mp[nums[i]] != idx {
			return i
		}
	}
	return idx
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Scan(&T)

	for t := 0; t < T; t++ {
		var buf bytes.Buffer
		var n int
		fmt.Scan(&n)

		p := make([]int, n)
		q := make([]int, n)
		for i := range q {
			fmt.Scan(&q[i])
			p[i] = q[i]
		}

		if n > 1 {
			sort.Ints(q)

			for i := 0; i < n; i++ {
				if p[i] == q[i] {
					if i != n-1 {
						q[i], q[i+1] = q[i+1], q[i]
					} else {
						q[i], q[i-1] = q[i-1], q[i]
					}
				}

			}

			for i := 0; i < n; i++ {
				buf.WriteString(strconv.Itoa(q[i]))
				buf.WriteRune(' ')
			}

		} else {
			buf.WriteString("-1")
		}
		fmt.Fprintln(out, buf.String())
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		arr := make([]int, n+1)
		b := make([]int, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
			b[i] = i + 1
		}

		if n == 1 {
			fmt.Fprintln(out, -1)
			continue
		}

		for i := 0; i < n; i++ {
			if arr[i] == b[i] {
				b[i], b[i+1] = b[i+1], b[i]
			}
		}
		if b[n] == n {
			b[n-2], b[n-1] = n, b[n-2]
		}
		for i := 0; i < n; i++ {
			fmt.Fprintf(out, "%d ", b[i])
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}

		if n == 1 {
			fmt.Fprintln(out, -1)
		} else {
			g := make([]int, n)
			x := 1
			m := make([]bool, n+2)
			m[0] = true
			for i, v := range arr {
				if v == x {
					if !m[x-1] {
						g[i] = x - 1
						m[x-1] = true
					} else {
						if x >= n {
							g[i], g[i-1] = g[i-1], n
						} else {
							g[i] = x + 1
							m[x+1] = true
						}
					}
				} else {
					g[i] = x
					m[x] = true
					x++
					if m[x] {
						x++
					}
				}
			}

			for _, v := range g {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var ntests int
	fmt.Fscan(scanner, &ntests)
outer:
	for iter := 0; iter < ntests; iter++ {
		var n int
		fmt.Fscan(scanner, &n)
		slice := make([]int, n)
		tmp := make([]int, n)
		res := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(scanner, &slice[i])
		}
		if n == 1 {
			fmt.Fprintln(writer, "-1")
			continue outer
		}
		copy(tmp, slice)
		sort.Slice(tmp, func(i, j int) bool { return tmp[i] < tmp[j] })
		for i := 0; i < n; i++ {
			min := tmp[0]
			if min != slice[0] {
				tmp = tmp[1:]
				slice = slice[1:]
				res[i] = min
			} else {
				if i == n-1 {
					// special case
					// have to swap something; n >= 3
					res[n-1] = res[n-2]
					res[n-2] = min
				} else {
					min = tmp[1]
					tmp = append(tmp[:1], tmp[2:]...)
					slice = slice[1:]
					res[i] = min
				}
			}
		}
		for i := 0; i < n; i++ {
			fmt.Fprintf(writer, "%d ", res[i])
		}
		fmt.Fprintln(writer)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gi2() (int,int) { return gi(),gi() }
func gi3() (int,int,int) { return gi(),gi(),gi() }
func gi4() (int,int,int,int) { return gi(),gi(),gi(),gi() }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func tern(cond bool, a int, b int) int { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }

type rbtreesetnode struct { left, right, up int32; red bool; key int }
type rbtreeset struct {
	lessthan func(a, b int) bool; tree []rbtreesetnode; root int32; recycler []int32; sz int; minidx int32
	maxidx int32
}
type rbtreesetIterator interface { Next() (ok bool); Prev() (ok bool); Key() int }
type rbtreesetiter struct { cur int32; key int; rbtree *rbtreeset }
func (i *rbtreesetiter) Key() int { return i.key }
func (i *rbtreesetiter) Next() bool {
	rbtree := i.rbtree; v := rbtree.nextidx(i.cur); if v == 0 { return false }; i.cur, i.key = v, rbtree.tree[v].key
	return true
}
func (i *rbtreesetiter) Prev() bool {
	rbtree := i.rbtree; v := rbtree.previdx(i.cur); if v == 0 { return false }; i.cur, i.key = v, rbtree.tree[v].key
	return true
}
func Newrbtreeset(lessthan func(a, b int) bool) *rbtreeset {
	q := &rbtreeset{lessthan, make([]rbtreesetnode, 2), int32(0), make([]int32, 0), 0, 0, 0}
	q.tree[0].left, q.tree[0].right, q.tree[0].up, q.tree[0].red = 0, 0, 0, false; q.recycler = append(q.recycler, 1)
	return q
}
func (q *rbtreeset) Add(k int) {
	if q.sz == 0 {
		z := q.getNewNodenum(); tree := q.tree; q.minidx, q.maxidx, q.sz, q.root = z, z, q.sz+1, z
		tree[z].key, tree[z].up, tree[z].left, tree[z].right, tree[z].red = k, 0, 0, 0, false; return
	}
	y, cmp := q.findInsertionPoint(k); if cmp == 0 { return }; z := q.getNewNodenum(); q.sz += 1; tree := q.tree
	tree[z].key, tree[z].up, tree[z].left, tree[z].right, tree[z].red = k, y, 0, 0, true
	if cmp < 0 { tree[y].left = z } else { tree[y].right = z }
	if q.sz == 0 || q.lessthan(k, tree[q.minidx].key) { q.minidx = z }
	if q.sz == 0 || q.lessthan(tree[q.maxidx].key, k) { q.maxidx = z }; var p, g, u int32
	for p = tree[z].up; tree[p].red; p = tree[z].up {
		g = tree[p].up ; if g == 0 { break }
		if p == tree[g].left {
			u = tree[g].right
			if tree[u].red { tree[p].red, tree[u].red, tree[g].red, z = false, false, true, g; continue }
			if z == tree[p].right { z = p; q.rotleft(z); p = tree[z].up }; q.rotright(g)
			tree[g].red, tree[p].red = true, false
		} else {
			u = tree[g].left
			if tree[u].red { tree[p].red, tree[u].red, tree[g].red, z = false, false, true, g; continue }
			if z == tree[p].left { z = p; q.rotright(z); p = tree[z].up }; q.rotleft(g)
			tree[g].red, tree[p].red = true, false
		}
	}
	tree[q.root].red = false
}
func (q *rbtreeset) Delete(k int) bool {
	if q.sz == 0 { return false }; z, cmp := q.findInsertionPoint(k); if cmp != 0 { return false }; q.sz--
	q.recycler = append(q.recycler, z)
	if q.sz > 0 && !q.lessthan(q.tree[q.minidx].key, k) { q.minidx = q.nextidx(q.minidx) }
	if q.sz > 0 && !q.lessthan(k, q.tree[q.maxidx].key) { q.maxidx = q.previdx(q.maxidx) }
	if q.sz == 0 { q.root = 0; return true }; tree := q.tree; var x int32; y, y_orig_red := z, tree[z].red
	if tree[z].left == 0 {
		x = tree[z].right; q.rbTransplant(z, x)
	} else if tree[z].right == 0 {
		x = tree[z].left; q.rbTransplant(z, x)
	} else {
		y = q.findminidx(tree[z].right); y_orig_red = tree[y].red; x = tree[y].right
		if tree[y].up == z {
			tree[x].up = y
		} else {
			q.rbTransplant(y, x); tree[y].right = tree[z].right; tree[tree[y].right].up = y
		}
		q.rbTransplant(z, y); tree[y].left = tree[z].left; tree[tree[y].left].up = y; tree[y].red = tree[z].red
	}
	if !y_orig_red {
		for q.root != x && !tree[x].red {
			p := tree[x].up
			if tree[p].left == x {
				s := tree[p].right
				if tree[s].red { tree[s].red = false; tree[p].red = true; q.rotleft(p); s = tree[p].right }
				c := tree[s].left; d := tree[s].right
				if !tree[c].red && !tree[d].red {
					tree[s].red = true; x = p
				} else {
					if !tree[d].red { tree[c].red = false; tree[s].red = true; q.rotright(s); s = tree[p].right }
					tree[s].red = tree[p].red; tree[p].red = false; tree[tree[s].right].red = false; q.rotleft(p)
					x = q.root
				}
			} else {
				s := tree[p].left
				if tree[s].red { tree[s].red = false; tree[p].red = true; q.rotright(p); s = tree[p].left }
				c := tree[s].right; d := tree[s].left
				if !tree[c].red && !tree[d].red {
					tree[s].red = true; x = p
				} else {
					if !tree[d].red { tree[c].red = false; tree[s].red = true; q.rotleft(s); s = tree[p].left }
					tree[s].red = tree[p].red; tree[p].red = false; tree[tree[s].left].red = false; q.rotright(p)
					x = q.root
				}
			}
		}
		tree[x].red = false
	}
	return true
}
func (q *rbtreeset) Clear() {
	q.tree, q.root, q.recycler, q.sz = q.tree[:2], 0, q.recycler[:0], 0; q.recycler = append(q.recycler, int32(1))
}
func (q *rbtreeset) IsEmpty() bool { return q.sz == 0 }
func (q *rbtreeset) Contains(k int) bool { _, cmp := q.findInsertionPoint(k); return cmp == 0 }
func (q *rbtreeset) Count(k int) int { _, cmp := q.findInsertionPoint(k); if cmp == 0 { return 1 }; return 0 }
func (q *rbtreeset) Len() int { return q.sz }
func (q *rbtreeset) MinKey() (k int) {
	if q.sz == 0 { panic("Called MinKey on an empty rbtreeset") }; return q.tree[q.minidx].key
}
func (q *rbtreeset) MaxKey() (k int) {
	if q.sz == 0 { panic("Called MaxKey on an empty rbtreeset") }; return q.tree[q.maxidx].key
}
func (q *rbtreeset) findLtIdx(k int) (int32, bool) {
	if q.sz == 0 || !q.lessthan(q.tree[q.minidx].key, k) { return 0, false }; idx, pos := q.findInsertionPoint(k)
	if pos != 1 { idx = q.previdx(idx) }; return idx, true
}
func (q *rbtreeset) findLeIdx(k int) (int32, bool) {
	if q.sz == 0 || q.lessthan(k, q.tree[q.minidx].key) { return 0, false }; idx, pos := q.findInsertionPoint(k)
	if pos == -1 { idx = q.previdx(idx) }; return idx, true
}
func (q *rbtreeset) findGtIdx(k int) (int32, bool) {
	if q.sz == 0 || !q.lessthan(k, q.tree[q.maxidx].key) { return 0, false }; idx, pos := q.findInsertionPoint(k)
	if pos != -1 { idx = q.nextidx(idx) }; return idx, true
}
func (q *rbtreeset) findGeIdx(k int) (int32, bool) {
	if q.sz == 0 || q.lessthan(q.tree[q.maxidx].key, k) { return 0, false }; idx, pos := q.findInsertionPoint(k)
	if pos == 1 { idx = q.nextidx(idx) }; return idx, true
}
func (q *rbtreeset) FindLt(k int) (int, bool) {
	var ans int; idx, ok := q.findLtIdx(k); if ok { ans = q.tree[idx].key }; return ans, ok
}
func (q *rbtreeset) FindLe(k int) (int, bool) {
	var ans int; idx, ok := q.findLeIdx(k); if ok { ans = q.tree[idx].key }; return ans, ok
}
func (q *rbtreeset) FindGt(k int) (int, bool) {
	var ans int; idx, ok := q.findGtIdx(k); if ok { ans = q.tree[idx].key }; return ans, ok
}
func (q *rbtreeset) FindGe(k int) (int, bool) {
	var ans int; idx, ok := q.findGeIdx(k); if ok { ans = q.tree[idx].key }; return ans, ok
}
func (q *rbtreeset) FindLtIter(k int) (rbtreesetIterator, bool) {
	var ans *rbtreesetiter; idx, ok := q.findLtIdx(k); if ok { ans = &rbtreesetiter{idx, q.tree[idx].key, q} }
	return ans, ok
}
func (q *rbtreeset) FindLeIter(k int) (rbtreesetIterator, bool) {
	var ans *rbtreesetiter; idx, ok := q.findLeIdx(k); if ok { ans = &rbtreesetiter{idx, q.tree[idx].key, q} }
	return ans, ok
}
func (q *rbtreeset) FindGtIter(k int) (rbtreesetIterator, bool) {
	var ans *rbtreesetiter; idx, ok := q.findGtIdx(k); if ok { ans = &rbtreesetiter{idx, q.tree[idx].key, q} }
	return ans, ok
}
func (q *rbtreeset) FindGeIter(k int) (rbtreesetIterator, bool) {
	var ans *rbtreesetiter; idx, ok := q.findGeIdx(k); if ok { ans = &rbtreesetiter{idx, q.tree[idx].key, q} }
	return ans, ok
}
func (q *rbtreeset) FindIter(k int) (rbtreesetIterator, bool) {
	if q.sz == 0 { return nil, false }; idx, pos := q.findInsertionPoint(k); if pos != 0 { return nil, false }
	return &rbtreesetiter{idx, q.tree[idx].key, q}, true
}
func (q *rbtreeset) MinIter() (rbtreesetIterator, bool) {
	if q.sz == 0 { return nil, false }; idx := q.findminidx(q.root)
	return &rbtreesetiter{idx, q.tree[idx].key, q}, true
}
func (q *rbtreeset) MaxIter() (rbtreesetIterator, bool) {
	if q.sz == 0 { return nil, false }; idx := q.findmaxidx(q.root)
	return &rbtreesetiter{idx, q.tree[idx].key, q}, true
}
func (q *rbtreeset) rbTransplant(u, v int32) {
	tree := q.tree
	if tree[u].up == 0 {
		q.root = v
	} else {
		p := tree[u].up; if u == tree[p].left { tree[p].left = v } else { tree[p].right = v }
	}
	tree[v].up = tree[u].up
}
func (q *rbtreeset) findInsertionPoint(k int) (int32, int8) {
	n, lt, tree := q.root, q.lessthan, q.tree
	for {
		nkey := tree[n].key
		if lt(nkey, k) {
			r := tree[n].right; if r == 0 { return n, 1 }; n = r
		} else if lt(k, nkey) {
			l := tree[n].left; if l == 0 { return n, -1 }; n = l
		} else {
			return n, 0
		}
	}
}
func (q *rbtreeset) findmaxidx(n1 int32) int32 {
	tree := q.tree; for { xx := tree[n1].right; if xx == 0 { break }; n1 = xx }; return n1
}
func (q *rbtreeset) findminidx(n1 int32) int32 {
	tree := q.tree; for { xx := tree[n1].left; if xx == 0 { break }; n1 = xx }; return n1
}
func (q *rbtreeset) nextidx(cur int32) int32 {
	last := int32(-2); tree := q.tree; rr := tree[cur].right; if rr > 0 { return q.findminidx(rr) }
	for { last, cur = cur, tree[cur].up; if cur == 0 || tree[cur].left == last { break } }; return cur
}
func (q *rbtreeset) previdx(cur int32) int32 {
	last := int32(0); tree := q.tree; ll := tree[cur].left; if ll > 0 { return q.findmaxidx(ll) }
	for { last, cur = cur, tree[cur].up; if cur == 0 || tree[cur].right == last { break } }; return cur
}
func (q *rbtreeset) rotleft(x int32) {
	tree := q.tree; y := tree[x].right; p := tree[x].up; tree[x].right = tree[y].left
	if tree[y].left != 0 { tree[tree[y].left].up = x }; tree[y].up = p
	if p == 0 {
		q.root = y
	} else if x == tree[p].left {
		tree[p].left = y
	} else {
		tree[p].right = y
	}
	tree[y].left = x; tree[x].up = y
}
func (q *rbtreeset) rotright(x int32) {
	tree := q.tree; y := tree[x].left; p := tree[x].up; tree[x].left = tree[y].right
	if tree[y].right != 0 { tree[tree[y].right].up = x }; tree[y].up = p
	if p == 0 {
		q.root = y
	} else if x == tree[p].right {
		tree[p].right = y
	} else {
		tree[p].left = y
	}
	tree[y].right = x; tree[x].up = y
}
func (q *rbtreeset) getNewNodenum() int32 {
	l := len(q.recycler); newnode := q.recycler[l-1]; q.recycler = q.recycler[:l-1]
	if l == 1 { q.tree = append(q.tree, rbtreesetnode{}); q.recycler = append(q.recycler, int32(len(q.tree)-1)) }
	return newnode
}

func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	ss := Newrbtreeset(func (a,b int) bool { return a < b } )
	for tt:=1;tt<=T;tt++ {
		N := gi(); P := gis(N)
		if N == 1 { fmt.Fprintln(wrtr,-1); continue }
		ss.Clear(); for i:=1;i<=N;i++ { ss.Add(i) }
		ansarr := ia(N)
		for i:=0;i<N-1;i++ {
			p := P[i]
			m := ss.MinKey()
			if m == p { m,_ = ss.FindGt(m) }
			ansarr[i] = m; ss.Delete(m)
		}
		m,_ := ss.FindGt(0); ansarr[N-1] = m
		if P[N-1] == ansarr[N-1] { ansarr[N-2],ansarr[N-1] = ansarr[N-1],ansarr[N-2] }
		fmt.Fprintln(wrtr,vecintstring(ansarr))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

/*
1 2 3 -> 2 3 1

2 3 4 5 1
1 2 3 4 5

2 3 1 4
1 2 4 3

2
4
1 3 2 4
5
1 3 2 4 5
===
2 1 4 3

2 1 3 5 4

*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	p := make([]int, n)
	q := make([]int, n)

	for i := range p {
		scanf("%d", &p[i])
		q[i] = p[i]
	}
	scanf("\n")

	sort.Ints(q)

	for i, num := range q {
		if num == p[i] {
			if i != len(q)-1 {
				q[i], q[i+1] = q[i+1], q[i]
			} else if i != 0 {
				q[i], q[i-1] = q[i-1], q[i]
			} else {
				fmt.Fprintln(writer, -1)
				return
			}
		}
	}

	for _, num := range q {
		fmt.Fprintf(writer, "%d ", num)
	}
	fmt.Fprintln(writer)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int64) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)
		copy(p, nums)

		sort.Ints(nums)
		cnt := 0
		for !isMystic(p, nums) && cnt < 10005 {
			nextPermutation(nums)
			cnt++
		}

		if cnt >= 10005 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, strings.Trim(Sprint(nums), "[]"))
		}

	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {

	numsLen := len(nums)
	first := -1
	second := -1

	for i, j := numsLen-2, numsLen-1; i >= 0; {
		if nums[i] < nums[j] {
			first = i
			second = j
			break
		} else {
			i--
			j--
		}
	}

	if !(first == -1) {
		smallestGreaterIndex := second
		for i := second + 1; i < numsLen; i++ {
			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
				smallestGreaterIndex = i
			}
		}
		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

		sort.Slice(nums[second:numsLen], func(i, j int) bool {
			return nums[second+i] < nums[second+j]
		})
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)
		copy(p, nums)

		sort.Ints(nums)
		cnt := 0
		for !isMystic(p, nums) && cnt < 2005 {
			nextPermutation(nums)
			cnt++
		}

		if cnt >= 2005 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, strings.Trim(Sprint(nums), "[]"))
		}

	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {

	numsLen := len(nums)
	first := -1
	second := -1

	for i, j := numsLen-2, numsLen-1; i >= 0; {
		if nums[i] < nums[j] {
			first = i
			second = j
			break
		} else {
			i--
			j--
		}
	}

	if !(first == -1) {
		smallestGreaterIndex := second
		for i := second + 1; i < numsLen; i++ {
			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
				smallestGreaterIndex = i
			}
		}
		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

		sort.Slice(nums[second:numsLen], func(i, j int) bool {
			return nums[second+i] < nums[second+j]
		})
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)
		copy(p, nums)

		sort.Ints(nums)
		cnt := 0
		for !isMystic(p, nums) && cnt < 1005 {
			nextPermutation(nums)
			cnt++
		}

		if cnt >= 1005 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, strings.Trim(Sprint(nums), "[]"))
		}

	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {

	numsLen := len(nums)
	first := -1
	second := -1

	for i, j := numsLen-2, numsLen-1; i >= 0; {
		if nums[i] < nums[j] {
			first = i
			second = j
			break
		} else {
			i--
			j--
		}
	}

	if !(first == -1) {
		smallestGreaterIndex := second
		for i := second + 1; i < numsLen; i++ {
			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
				smallestGreaterIndex = i
			}
		}
		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

		sort.Slice(nums[second:numsLen], func(i, j int) bool {
			return nums[second+i] < nums[second+j]
		})
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)
		copy(p, nums)

		sort.Ints(nums)
		cnt := 0
		for !isMystic(p, nums) && cnt < 2*n {
			nextPermutation(nums)
			cnt++
		}

		if cnt >= 2*n {
			Fprintln(out, -1)
		} else {
			Fprintln(out, strings.Trim(Sprint(nums), "[]"))
		}

	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {

	numsLen := len(nums)
	first := -1
	second := -1

	for i, j := numsLen-2, numsLen-1; i >= 0; {
		if nums[i] < nums[j] {
			first = i
			second = j
			break
		} else {
			i--
			j--
		}
	}

	if !(first == -1) {
		smallestGreaterIndex := second
		for i := second + 1; i < numsLen; i++ {
			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
				smallestGreaterIndex = i
			}
		}
		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

		sort.Slice(nums[second:numsLen], func(i, j int) bool {
			return nums[second+i] < nums[second+j]
		})
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)
		copy(p, nums)

		sort.Ints(nums)
		cnt := 0
		for !isMystic(p, nums) && cnt < 2*n {
			nextPermutation(nums)
			cnt++
		}

		if cnt >= 2*n {
			Fprintln(out, -1)
			continue
		}

		Fprintln(out, strings.Trim(Sprint(nums), "[]"))
	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {
	length := len(nums)
	if length == 1 {
		return
	}
	if nums[length-1] > nums[length-2] {
		nums[length-1], nums[length-2] = nums[length-2], nums[length-1]
		return
	}

	idx := length - 1
	for idx > 0 {
		if nums[idx] > nums[idx-1] {
			break
		}
		idx--
	}
	if idx == 0 {
		sort.Sort(sort.IntSlice(nums))
	} else {
		minNum, minIdx := nums[idx], idx

		for i := idx + 1; i < length; i++ {
			if nums[i] < minNum && nums[i] > nums[idx-1] {
				minNum = nums[i]
				minIdx = i
			}
		}

		nums[minIdx], nums[idx-1] = nums[idx-1], nums[minIdx]
		sort.Sort(sort.IntSlice(nums[idx:]))
	}
}

// func nextPermutation(nums []int) {

// 	numsLen := len(nums)
// 	first := -1
// 	second := -1

// 	for i, j := numsLen-2, numsLen-1; i >= 0; {
// 		if nums[i] < nums[j] {
// 			first = i
// 			second = j
// 			break
// 		} else {
// 			i--
// 			j--
// 		}
// 	}

// 	if !(first == -1) {
// 		smallestGreaterIndex := second
// 		for i := second + 1; i < numsLen; i++ {
// 			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
// 				smallestGreaterIndex = i
// 			}
// 		}
// 		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

// 		sort.Slice(nums[second:numsLen], func(i, j int) bool {
// 			return nums[second+i] < nums[second+j]
// 		})
// 	}
// }

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)
		copy(p, nums)

		sort.Ints(nums)
		cnt := 0
		for !isMystic(p, nums) && cnt < n+5 {
			nextPermutation(nums)
			cnt++
		}

		if len(nums) == 1 || cnt > n {
			Fprintln(out, -1)
			continue
		}

		Fprintln(out, strings.Trim(Sprint(nums), "[]"))
	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {
	length := len(nums)
	if length == 1 {
		return
	}
	if nums[length-1] > nums[length-2] {
		nums[length-1], nums[length-2] = nums[length-2], nums[length-1]
		return
	}

	idx := length - 1
	for idx > 0 {
		if nums[idx] > nums[idx-1] {
			break
		}
		idx--
	}
	if idx == 0 {
		sort.Sort(sort.IntSlice(nums))
	} else {
		minNum, minIdx := nums[idx], idx

		for i := idx + 1; i < length; i++ {
			if nums[i] < minNum && nums[i] > nums[idx-1] {
				minNum = nums[i]
				minIdx = i
			}
		}

		nums[minIdx], nums[idx-1] = nums[idx-1], nums[minIdx]
		sort.Sort(sort.IntSlice(nums[idx:]))
	}
}

// func nextPermutation(nums []int) {

// 	numsLen := len(nums)
// 	first := -1
// 	second := -1

// 	for i, j := numsLen-2, numsLen-1; i >= 0; {
// 		if nums[i] < nums[j] {
// 			first = i
// 			second = j
// 			break
// 		} else {
// 			i--
// 			j--
// 		}
// 	}

// 	if !(first == -1) {
// 		smallestGreaterIndex := second
// 		for i := second + 1; i < numsLen; i++ {
// 			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
// 				smallestGreaterIndex = i
// 			}
// 		}
// 		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

// 		sort.Slice(nums[second:numsLen], func(i, j int) bool {
// 			return nums[second+i] < nums[second+j]
// 		})
// 	}
// }

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)

		copy(p, nums)
		found := false
		sort.Ints(nums)
		for i := 0; i <= 2*n; i++ {
			if isMystic(p, nums) {
				found = true
				break
			}
			nextPermutation(nums)
		}

		if !found {
			Fprintln(out, -1)
		} else {
			Fprintln(out, strings.Trim(Sprint(nums), "[]"))
		}
	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {

	numsLen := len(nums)
	first := -1
	second := -1

	for i, j := numsLen-2, numsLen-1; i >= 0; {
		if nums[i] < nums[j] {
			first = i
			second = j
			break
		} else {
			i--
			j--
		}
	}

	if !(first == -1) {
		smallestGreaterIndex := second
		for i := second + 1; i < numsLen; i++ {
			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
				smallestGreaterIndex = i
			}
		}
		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

		sort.Slice(nums[second:numsLen], func(i, j int) bool {
			return nums[second+i] < nums[second+j]
		})
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"sort"
	"strings"
)

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}
		p := make([]int, n)

		copy(p, nums)
		found := false
		sort.Ints(nums)
		for i := 0; i <= n; i++ {
			if isMystic(p, nums) {
				found = true
				break
			}
			nextPermutation(nums)
		}

		if !found {
			Fprintln(out, -1)
		} else {
			Fprintln(out, strings.Trim(Sprint(nums), "[]"))
		}
	}
}

func isMystic(p, q []int) bool {
	for i := range p {
		if p[i] == q[i] {
			return false
		}
	}
	return true
}

func nextPermutation(nums []int) {

	numsLen := len(nums)
	first := -1
	second := -1

	for i, j := numsLen-2, numsLen-1; i >= 0; {
		if nums[i] < nums[j] {
			first = i
			second = j
			break
		} else {
			i--
			j--
		}
	}

	if !(first == -1) {
		smallestGreaterIndex := second
		for i := second + 1; i < numsLen; i++ {
			if nums[i] > nums[first] && nums[i] < nums[smallestGreaterIndex] {
				smallestGreaterIndex = i
			}
		}
		nums[first], nums[smallestGreaterIndex] = nums[smallestGreaterIndex], nums[first]

		sort.Slice(nums[second:numsLen], func(i, j int) bool {
			return nums[second+i] < nums[second+j]
		})
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Scan(&T)

	for t := 0; t < T; t++ {
		var buf bytes.Buffer
		var n int
		fmt.Scan(&n)

		p := make([]int, n)
		q := make([]int, n)
		for i := range q {
			fmt.Scan(&q[i])
			p[i] = q[i]
		}

		if n > 1 {
			sort.Ints(q)

			if q[0] == p[0] {
				q[0], q[1] = q[1], q[0]
			}
			i := n - 1
			for ; i > 0; i-- {
				if p[i] == q[i] {
					q[i], q[i-1] = q[i-1], q[i]
				}
			}
			for ; i < n; i++ {
				buf.WriteString(strconv.Itoa(q[i]))
				buf.WriteRune(' ')
			}

		} else {
			buf.WriteString("-1")
		}
		fmt.Fprintln(out, buf.String())
	}
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)

	sizes := make(map[string]int)
	for i := 0; i < n; i++ {
		var size string
		fmt.Scanln(&size)
		sizes[size]++
	}

	for i := 0; i < n; i++ {
		var size string
		fmt.Scanln(&size)
		if sizes[size] > 0 {
			sizes[size]--
			if sizes[size] == 0 {
				delete(sizes, size)
			}
		}
	}

	ans := 0
	for _, count := range sizes {
		ans += count
	}

	fmt.Println(ans)
}

package main

import "fmt"

func main() {
   var n int
   fmt.Scanln(&n)

   m := make(map[string]int)
   for i:=1; i <= n;i++{
   		var sze string
   		fmt.Scanln(&sze)
   		m[sze]++
   }
   for i:=1; i<= n;i++{
   		var sze string
   		fmt.Scanln(&sze)
   		if m[sze] > 0{
   			m[sze]--
   			if m[sze] == 0{
   				delete(m,sze)
			}
		}
   }
   ans := 0
   for _, count := range m{
   	    ans += count
   }
   fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)

	sizes := make(map[string]int)
	for i := 0; i < n; i++ {
		var size string
		fmt.Scanln(&size)
		sizes[size]++
	}

	for i := 0; i < n; i++ {
		var size string
		fmt.Scanln(&size)
		if sizes[size] > 0 {
			sizes[size]--
			if sizes[size] == 0 {
				delete(sizes, size)
			}
		}
	}

	fmt.Println(len(sizes))
}