You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform an arbitrary number of moves (including zero). How many different strings can you obtain? Print the number, or report that it is infinitely large.Two strings are considered different if they have different length, or they differ at some index.

The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting of lowercase Latin letters. The length of $$$t$$$ doesn't exceed $$$50$$$.

For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.

NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then the second letter 'a' again. String $$$s$$$ becomes equal to "aabcbc". And so on, generating infinitely many different strings.In the third example, you can either leave string $$$s$$$ as is, performing zero moves, or replace the only 'a' with "b". String $$$s$$$ becomes equal to "b", so you can't perform more moves on it.

package main

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

// source: https://codeforces.com/contest/1674/problem/C?locale=en

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func solve() string {
	var s, t string
	fmt.Fscan(in, &s, &t)
	if t == "a" {
		return "1"
	}
	if strings.ContainsRune(t, 'a') {
		return "-1"
	}
	return strconv.FormatInt(1<<len(s), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
    fmt.Scanf("%d\n",&t)
    arr :=make([]int64,60)
    var fun int64
    fun=2;
    arr=append(arr,0)
    for j:=1;j<=51;j++{
        arr[j]=fun
        fun*=2
    }
    for i:=1;i<=t;i++{
		var str,str1 string
        fmt.Fscan(in,&str)
		fmt.Fscan(in,&str1)

        if str1=="a"{
            fmt.Println(1)
            continue
        }
        flag:=false
        for jj:=0;jj<len(str1);jj++{
            if str1[jj]=='a'{
                flag=true
            }
        }
        if(flag==true){
            fmt.Println(-1)
            continue
        }
        fmt.Println(arr[len(str)])
    }
}

package main

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

func main() {
	var t int
	reader := bufio.NewReader(os.Stdin)
    fmt.Scanf("%d\n",&t)
    arr :=make([]int64,60)
    var fun int64
    fun=2;
    arr=append(arr,0)
    for j:=1;j<=51;j++{
        arr[j]=fun
        fun*=2
    }
    for i:=1;i<=t;i++{

        str, _ := reader.ReadString('\n')
        str1, _ := reader.ReadString('\n')
		if str[len(str)-1] == 10 {
			str = str[:len(str)-1]
		}
		if str[len(str)-1] == 13 {
			str = str[:len(str)-1]
		}
		if str1[len(str1)-1] == 10 {
			str1 = str1[:len(str1)-1]
		}
		if str1[len(str1)-1] == 13 {
			str1 = str1[:len(str1)-1]
		}
        if str1=="a"{
            fmt.Println(1)
            continue
        }
        flag:=false
        for jj:=0;jj<len(str1);jj++{
            if str1[jj]=='a'{
                flag=true
            }
        }
        if(flag==true){
            fmt.Println(-1)
            continue
        }
        fmt.Println(arr[len(str)])
    }
}

package main

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

func sol(in *bufio.Reader) {
	a, _ := in.ReadString('\n')
	s, _ := in.ReadString('\n')
	a = strings.Trim(a, " \r\n\t")
	s = strings.Trim(s, " \r\n\t")

	l1 := len(a)
	l2 := len(s)
	if l1 > 30 {
		// fmt.Println(a, s)
		// fmt.Println(l1, l2)
	}
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if l1 > 30 {
		// fmt.Println("ca=", ca, "co=", co, "l1=", l1, "l2=", l2)
	}
	if ca == l2 && l2 == 1 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(uint64(1) << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		sol(in)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

// https://codeforces.com/problemset/problem/1674/C

// 1674C - Infinite Replacement

// You are given a string s, consisting only of Latin letters 'a', and a string t, consisting of lowercase Latin letters.
// In one move, you can replace any letter 'a' in the string s with a string t. Note that after the replacement string s might contain letters other than 'a'.
// You can perform an arbitrary number of moves (including zero). How many different strings can you obtain? Print the number, or report that it is infinitely large.
// Two strings are considered different if they have different length, or they differ at some index.

// Input
// The first line contains a single integer q (1≤q≤104) — the number of testcases.
// The first line of each testcase contains a non-empty string s, consisting only of Latin letters 'a'. The length of s doesn't exceed 50.
// The second line contains a non-empty string t, consisting of lowercase Latin letters. The length of t doesn't exceed 50.

// Output
// For each testcase, print the number of different strings s that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.

// Example
// input
// 3
// aaaa
// a
// aa
// abc
// a
// b
// output
// 1
// -1
// 2

// Note

// In the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.
// In the second example, you can replace the second letter 'a' with "abc". String s becomes equal to "aabc". Then the second letter 'a' again. String s becomes equal to "aabcbc". And so on, generating infinitely many different strings.
// In the third example, you can either leave string s as is, performing zero moves, or replace the only 'a' with "b". String s becomes equal to "b", so you can't perform more moves on it.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, q int
	var s, t string
	var has_a bool

	for c, _ = fmt.Fscan(reader, &q); c == 1; c, _ = fmt.Fscan(reader, &q) {
		for ; q > 0; q-- {
			fmt.Fscan(reader, &s, &t)

			has_a = strings.Contains(t, "a")

			if len(t) == 1 && has_a {
				fmt.Fprintln(writer, 1)
			} else if has_a {
				fmt.Fprintln(writer, -1)
			} else {
				fmt.Fprintln(writer, int64(1)<<len(s))
			}
		}
	}

	writer.Flush()
}

// https://codeforces.com/problemset/problem/1674/C

// 1674C - Infinite Replacement

// You are given a string s, consisting only of Latin letters 'a', and a string t, consisting of lowercase Latin letters.
// In one move, you can replace any letter 'a' in the string s with a string t. Note that after the replacement string s might contain letters other than 'a'.
// You can perform an arbitrary number of moves (including zero). How many different strings can you obtain? Print the number, or report that it is infinitely large.
// Two strings are considered different if they have different length, or they differ at some index.

// Input
// The first line contains a single integer q (1≤q≤104) — the number of testcases.
// The first line of each testcase contains a non-empty string s, consisting only of Latin letters 'a'. The length of s doesn't exceed 50.
// The second line contains a non-empty string t, consisting of lowercase Latin letters. The length of t doesn't exceed 50.

// Output
// For each testcase, print the number of different strings s that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.

// Example
// input
// 3
// aaaa
// a
// aa
// abc
// a
// b
// output
// 1
// -1
// 2

// Note

// In the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.
// In the second example, you can replace the second letter 'a' with "abc". String s becomes equal to "aabc". Then the second letter 'a' again. String s becomes equal to "aabcbc". And so on, generating infinitely many different strings.
// In the third example, you can either leave string s as is, performing zero moves, or replace the only 'a' with "b". String s becomes equal to "b", so you can't perform more moves on it.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, q, i int
	var s, t string
	var has_a bool

	for c, _ = fmt.Fscan(reader, &q); c == 1; c, _ = fmt.Fscan(reader, &q) {
		for ; q > 0; q-- {
			fmt.Fscan(reader, &s, &t)

			for i, has_a = 0, false; i < len(t) && !has_a; i++ {
				if t[i] == 'a' {
					has_a = true
				}
			}

			if len(t) == 1 && has_a {
				fmt.Fprintln(writer, 1)
			} else if has_a {
				fmt.Fprintln(writer, -1)
			} else {
				fmt.Fprintln(writer, int64(1)<<len(s))
			}
		}
	}

	writer.Flush()
}

// https://codeforces.com/problemset/problem/1674/C

// 1674C - Infinite Replacement

// You are given a string s, consisting only of Latin letters 'a', and a string t, consisting of lowercase Latin letters.
// In one move, you can replace any letter 'a' in the string s with a string t. Note that after the replacement string s might contain letters other than 'a'.
// You can perform an arbitrary number of moves (including zero). How many different strings can you obtain? Print the number, or report that it is infinitely large.
// Two strings are considered different if they have different length, or they differ at some index.

// Input
// The first line contains a single integer q (1≤q≤104) — the number of testcases.
// The first line of each testcase contains a non-empty string s, consisting only of Latin letters 'a'. The length of s doesn't exceed 50.
// The second line contains a non-empty string t, consisting of lowercase Latin letters. The length of t doesn't exceed 50.

// Output
// For each testcase, print the number of different strings s that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.

// Example
// input
// 3
// aaaa
// a
// aa
// abc
// a
// b
// output
// 1
// -1
// 2

// Note

// In the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.
// In the second example, you can replace the second letter 'a' with "abc". String s becomes equal to "aabc". Then the second letter 'a' again. String s becomes equal to "aabcbc". And so on, generating infinitely many different strings.
// In the third example, you can either leave string s as is, performing zero moves, or replace the only 'a' with "b". String s becomes equal to "b", so you can't perform more moves on it.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, q, i int
	var s, t string
	var has_a bool

	for c, _ = fmt.Fscan(reader, &q); c == 1; c, _ = fmt.Fscan(reader, &q) {
		for ; q > 0; q-- {
			fmt.Fscan(reader, &s, &t)

			if t == "a" {
				fmt.Fprintln(writer, 1)
			} else {
				if len(t) > 1 {
					for i, has_a = 0, false; i < len(t) && !has_a; i++ {
						if t[i] == 'a' {
							has_a = true
						}
					}

					if has_a {
						fmt.Fprintln(writer, -1)
					} else {
						fmt.Fprintln(writer, int64(1)<<len(s))
					}
				} else {
					fmt.Fprintln(writer, int64(1)<<len(s))
				}
			}
		}
	}

	writer.Flush()
}

// https://codeforces.com/problemset/problem/1674/C

// 1674C - Infinite Replacement

// You are given a string s, consisting only of Latin letters 'a', and a string t, consisting of lowercase Latin letters.
// In one move, you can replace any letter 'a' in the string s with a string t. Note that after the replacement string s might contain letters other than 'a'.
// You can perform an arbitrary number of moves (including zero). How many different strings can you obtain? Print the number, or report that it is infinitely large.
// Two strings are considered different if they have different length, or they differ at some index.

// Input
// The first line contains a single integer q (1≤q≤104) — the number of testcases.
// The first line of each testcase contains a non-empty string s, consisting only of Latin letters 'a'. The length of s doesn't exceed 50.
// The second line contains a non-empty string t, consisting of lowercase Latin letters. The length of t doesn't exceed 50.

// Output
// For each testcase, print the number of different strings s that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.

// Example
// input
// 3
// aaaa
// a
// aa
// abc
// a
// b
// output
// 1
// -1
// 2

// Note

// In the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.
// In the second example, you can replace the second letter 'a' with "abc". String s becomes equal to "aabc". Then the second letter 'a' again. String s becomes equal to "aabcbc". And so on, generating infinitely many different strings.
// In the third example, you can either leave string s as is, performing zero moves, or replace the only 'a' with "b". String s becomes equal to "b", so you can't perform more moves on it.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, q int
	var s, t string

	for c, _ = fmt.Fscan(reader, &q); c == 1; c, _ = fmt.Fscan(reader, &q) {
		for ; q > 0; q-- {
			fmt.Fscan(reader, &s, &t)

			if t == "a" {
				fmt.Fprintln(writer, 1)
			} else if strings.Count(t, "a") != 0 {
				fmt.Fprintln(writer, -1)
			} else {
				fmt.Fprintln(writer, uint(math.Pow(2, float64(len(s)))))
			}
		}
	}

	writer.Flush()
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		t, _ := reader.ReadString('\n')
		if t[len(t)-1] == 10 {
			t = t[:len(t)-1]
		}
		if t[len(t)-1] == 13 {
			t = t[:len(t)-1]
		}

		done := false

		if len(t) == 1 && t[0] == 97 {
			fmt.Println(1)
			continue
		}

		for i := 0; i < len(t); i++ {
			if t[i] == 97 {
				fmt.Println(-1)
				done = true
				break
			}
		}
		if done {
			continue
		}

		ans := uint64( math.Pow(2, float64(len(s))) )
		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	c1674(os.Stdin, os.Stdout)
}

func c1674(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var x string
	var y string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		Fscan(in, &y)

		ac := 0
		ot := 0
		for _, v := range y {
			if v == 'a' {
				ac++
			} else {
				ot++
			}
		}
		ans := int64(0)
		if ac > 0 {
			if len(y) > 1 {
				ans = -1
			} else {
				ans = 1
			}
		} else if ac == 0 {
			ans = quickPow(2, int64(len(x)))
		}
		Fprintln(out, ans)
	}
}

func quickPow(a, n int64) int64 {
	ans := int64(1)
	for n > 0 {
		if n&1 > 0 {
			ans = ans * a
		}
		a *= a
		n /= 2
	}
	return ans
}

package main

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

func main() {
	CF1674C(os.Stdin, os.Stdout)
}

func CF1674C(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	t := 0
	fmt.Fscan(in, &t)
	str1 := ""
	str2 := ""
	for ; t > 0; t-- {
		fmt.Fscan(in, &str1)
		fmt.Fscan(in, &str2)
		mp := make(map[rune]int)
		for _, ch := range str2 {
			mp[ch]++
		}
		if mp['a'] > 0 && (len(mp) > 1 || mp['a'] > 1) {
			fmt.Fprintln(out, -1)
			continue
		} else if mp['a'] > 0 && mp['a'] == 1 {
			fmt.Fprintln(out, 1)
		} else {
			ans := math.Pow(2, float64(len(str1)))
			fmt.Fprintln(out, int64(ans))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var s, t string
		fmt.Fscan(in, &s, &t)
		if t == "a" {
			fmt.Fprintln(out, 1)
		} else if strings.Contains(t, "a") {
			fmt.Fprintln(out, -1)
		} else {
			count := strings.Count(s, "a")
			fmt.Fprintln(out, int64(math.Pow(2, float64(count))))
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
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 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()
	for tt:=1;tt<=T;tt++ {
		s := gs(); t := gs()
		aint := false; for _,c := range t { if c == 'a' { aint = true } }
		ans := int64(0)
		if len(t) == 1 && aint {
			ans = 1
		} else if aint {
			ans = -1
		} else {
			ans = int64(1)<<len(s)
		}
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

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

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var s1, s2 string
		fmt.Fscan(in, &s1, &s2)

		if s2 == "a" {
			fmt.Fprintln(out, 1)
			continue
		}

		if strings.Contains(s2, "a") {
			fmt.Fprintln(out, -1)
			continue
		}

		fmt.Fprintln(out, int64(math.Pow(float64(2), float64(len(s1)))))
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	defer w.Flush()
	var s, t string
	fmt.Fscan(r, &s, &t)
	if len(t) > 1 && strings.Contains(t, "a") {
		fmt.Fprintln(w, "-1")
		return
	}
	if len(t) == 1 {
		if t[0] == 'a' {
			fmt.Fprintln(w, "1")
			return
		}
	}
	n := len(s)
	fmt.Fprintln(w, (int64(1) << n))
}

func main() {
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

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 s1, s2 string
		fmt.Fscan(in, &s1, &s2)

		var a1 int
		for _, ch := range s1 {
			if ch == 'a' {
				a1++
			}
		}

		var a2 int
		for _, ch := range s2 {
			if ch == 'a' {
				a2++
			}
		}

		if a1 == len(s1) && a2 == 1 && len(s2) == 1 || a1 == 0 {
			fmt.Fprintln(out, 1)
		} else if a1 > 0 && a2 > 1 {
			fmt.Fprintln(out, -1)
		} else if a1 > 0 && a2 > 0 && len(s2) != a2 {
			fmt.Fprintln(out, -1)
		} else {
			x := int64(1)
			for i := 0; i < a1; i++ {
				x *= 2
			}
			fmt.Fprintln(out, x)
		}
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
loop:
	for t := io.ReadInt(); t > 0; t-- {
		s := io.ReadString()
		u := io.ReadString()

		if u == "a" {
			fmt.Println(1)
			continue loop
		}

		for _, v := range u {
			if v == 'a' {
				fmt.Println(-1)
				continue loop
			}
		}

		var ans int64 = 1
		for i := 0; i < len(s); i++ {
			ans *= 2
		}

		fmt.Println(ans)
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var s, t string
		fmt.Fscan(reader, &s, &t)
		if t == "a" {
			fmt.Println(1)
		} else if strings.Contains(t, "a") {
			fmt.Println(-1)
		} else {
			fmt.Println(int64(1) << len(s))
		}
	}
}

package main

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

const mod = 998244353

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var s, t string
	fmt.Fscan(in, &s, &t)
	cnt := 0
	aCnt := 0
	for _, v := range s {
		if v == 'a' {
			cnt++
		}
	}
	for _, v := range t {
		if v == 'a' {
			aCnt++
		}
	}
	if cnt == 0 || (aCnt == 1 && aCnt == len(t)) {
		fmt.Fprintln(out, 1)
		return
	}
	if aCnt != 0 {
		fmt.Fprintln(out, -1)
		return
	}
	ans := int64(1)
	ans <<= int64(cnt)
	fmt.Fprintln(out, ans)
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func sum(a, b int64) int64 {
	return (b + a) * (b - a + 1) / 2
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	//stdin, _ := os.Open("/project/go/algo/input")
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var q int
	var S,T string
	var anc int64

	fmt.Fscan(in, &q)
	//list := make([]string,N)
	//A := rune('a')
	for i := 0;i < q;i++{
		fmt.Fscan(in, &S,&T)
		//どんな時でもTがaなら１
		if T == "a"{
			anc = 1
		}else if strings.Index(T, "a") != -1{
			anc = -1
		}else{
			//Tがa以外の一文字なら2^len(S)
			anc = int64(math.Pow(2, float64(len(S))))
		}
		fmt.Println(anc)
	}
}

package main

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

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func solve() {
	var s, t string
	fmt.Fscan(in, &s, &t)
	if t == "a" {
		fmt.Fprintf(out, "1\n")
		return
	}
	if strings.Contains(t, "a") {
		fmt.Fprintf(out, "-1\n")
		return
	}
	fmt.Fprintf(out, "%d\n", int64(1)<<len(s))
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		solve()
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var q int
	fmt.Scanf("%d\n", &q)
	for ; q > 0; q-- {
		s, _ := reader.ReadString('\n')
		s = strings.TrimSpace(s)
		t, _ := reader.ReadString('\n')
		t = strings.TrimSpace(t)
		if strings.Contains(t, "a") {
			if len(t) > 1 {
				fmt.Println(-1)
				continue
			} else {
				fmt.Println(1)
				continue
			}
		}
		res := int64(1)
		for i := 1; i <= len(s); i++ {
			res = res * 2
		}
		fmt.Println(res)
	}
}

package main

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

/*
3
aa
af
aaa
sdf
aaaaaaaaaa
b
---
-1
8?
1024
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var s, t string
	scanf("%s\n%s\n", &s, &t)

	if len(t) == 1 && t[0] == 'a' {
		fmt.Fprintln(writer, 1)
		return
	}

	for _, r := range t {
		if r == 'a' {
			fmt.Fprintln(writer, -1)
			return
		}
	}

	ans := int64(math.Exp2(float64(len(s))))

	fmt.Fprintln(writer, ans)
}

//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"
	"strings"
)

// source: https://codeforces.com/contest/1674/problem/C?locale=en

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func solve() interface{} {
	var s, t string
	fmt.Scan(&s, &t)

	if t == "a" {
		return 1
	}
	if strings.ContainsRune(t, 'a') {
		return -1
	}
	return 1 << len(s)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

package main

import (
	"fmt"
	"strings"
)

// source: https://codeforces.com/contest/1674/problem/C?locale=en

func solve() {
	var s, t string
	fmt.Scan(&s, &t)

	if t == "a" {
		fmt.Printf("1")
	}

	tHasA := strings.ContainsRune(t, 'a')
	if !tHasA {
		fmt.Printf("%d", 1<<len(s))
		return
	}

	if len(t) > 1 {
		fmt.Printf("-1")
	}
}

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

package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

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

	solve := func() int {
		var s, t string
		fmt.Scanf("%s\n%s", &s, &t)

		tHasA := strings.ContainsRune(t, 'a')
		if len(t) == 1 && tHasA {
			return 1
		}

		if len(t) > 1 && tHasA {
			return -1
		}

		return int(math.Pow(2., float64(len(s))))
	}

	for i := 0; i < n; i++ {
		fmt.Println(strconv.FormatInt(int64(solve()), 10))
	}
}

package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

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

	solve := func() int {
		var s, t string
		fmt.Scanf("%s\n%s", &s, &t)

		tHasA := strings.ContainsRune(t, 'a')
		if len(t) > 1 && tHasA {
			return -1
		}
		if len(t) == 1 && tHasA {
			return 1
		}

		return int(math.Pow(2., float64(len(s))))
	}

	for i := 0; i < n; i++ {
		fmt.Println(strconv.FormatInt(int64(solve()), 10))
	}
}

package main

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

func main() {
	var t int
	reader := bufio.NewReader(os.Stdin)
    fmt.Scanf("%d\n",&t)
    arr :=make([]int64,60)
    var fun int64
    fun=2;
    arr=append(arr,0)
    for j:=1;j<=51;j++{
        arr[j]=fun
        fun*=2
    }
    for i:=1;i<=t;i++{

        str, _ := reader.ReadString('\n')
        str1, _ := reader.ReadString('\n')
		if str[len(str)-1] == 10 {
			str = str[:len(str)-1]
		}
		if str[len(str)-1] == 13 {
			str = str[:len(str)-1]
		}
		if str1[len(str1)-1] == 10 {
			str1 = str1[:len(str1)-1]
		}
		if str1[len(str1)-1] == 13 {
			str1 = str1[:len(str1)-1]
		}
		fmt.Println(str)
		fmt.Println(str1)
        if str1=="a"{
            fmt.Println(1)
            continue
        }
        flag:=false
        for jj:=0;jj<len(str1);jj++{
            if str1[jj]=='a'{
                flag=true
            }
        }
        if(flag==true){
            fmt.Println(-1)
            continue
        }
        fmt.Println(arr[len(str)])
    }
}

package main

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

func main() {
	var t int
	reader := bufio.NewReader(os.Stdin)
    fmt.Scanf("%d\n",&t)
    arr :=make([]int64,60)
    var fun int64
    fun=2;
    arr=append(arr,0)
    for j:=1;j<=51;j++{
        arr[j]=fun
        fun*=2
    }
    for i:=1;i<=t;i++{
        var str string
        var str1 string
        str, _ = reader.ReadString('\n')
        str1, _ = reader.ReadString('\n')
        if str1=="a"{
            fmt.Println(1)
            continue
        }
        flag:=false
        for jj:=0;jj<len(str1);jj++{
            if str1[jj]=='a'{
                flag=true
            }
        }
        if(flag==true){
            fmt.Println(-1)
            continue
        }
        fmt.Println(arr[len(str)])
    }
}

package main

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

func sol(in *bufio.Reader) {
	a, _ := in.ReadString('\n')
	s, _ := in.ReadString('\n')
	a = strings.Trim(a, " \r\n\t")
	s = strings.Trim(s, " \r\n\t")

	l1 := len(a)
	l2 := len(s)
	if l1 > 30 {
		fmt.Println(a, s)
		fmt.Println(l1, l2)
	}
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if l1 > 30 {
		fmt.Println("ca=", ca, "co=", co, "l1=", l1, "l2=", l2)
	}
	if ca == l2 && l2 == 1 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(1 << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		sol(in)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

package main

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

func sol(in *bufio.Reader) {
	a, _ := in.ReadString('\n')
	s, _ := in.ReadString('\n')
	a = strings.Trim(a, " \r\n\t")
	s = strings.Trim(s, " \r\n\t")

	l1 := len(a)
	l2 := len(s)
	if l1 > 30 {
		fmt.Println(a, s)
		fmt.Println(l1, l2)
	}
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if ca == l2 && l2 == 1 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(1 << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		sol(in)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

package main

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

func sol(in *bufio.Reader) {
	a, _ := in.ReadString('\n')
	s, _ := in.ReadString('\n')
	a = strings.Trim(a, " \r\n\t")
	s = strings.Trim(s, " \r\n\t")

	l1 := len(a)
	l2 := len(s)
	if l1 > 30 {
		fmt.Println(a, s)
	}
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if ca == l2 && ca == 1 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(1 << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		sol(in)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

package main

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

func sol(in *bufio.Reader) {
	a, _ := in.ReadString('\n')
	s, _ := in.ReadString('\n')
	a = strings.Trim(a, " \r\n\t")
	s = strings.Trim(s, " \r\n\t")

	l1 := len(a)
	l2 := len(s)
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if ca == l2 && ca == 1 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(1 << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		sol(in)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

package main

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

func sol(in *bufio.Reader) {
	// var a, s string
	// fmt.Scanf("%s\n%s\n", &a, &s)

	a, _ := in.ReadString('\n')
	s, _ := in.ReadString('\n')
	a = strings.Trim(a, " \r\n\t")
	s = strings.Trim(s, " \r\n\t")
	// fmt.Println(a, s)

	l1 := len(a)
	l2 := len(s)
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if ca == l2 && ca == 1 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(1 << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		sol(in)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

package main

import (
	"fmt"
)

func sol() {
	var a, s string
	fmt.Scanf("%s\n%s\n", &a, &s)

	l1 := len(a)
	l2 := len(s)
	ca, co := 0, 0
	for i := 0; i < l2; i++ {
		if s[i] == 'a' {
			ca += 1
		} else {
			co += 1
		}
	}
	if ca == l2 {
		fmt.Println(1)
	} else if co == l2 {
		fmt.Println(1 << l1)
	} else {
		fmt.Println(-1)
	}
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		sol()
	}
}

// https://codeforces.com/problemset/problem/1674/C

// 1674C - Infinite Replacement

// You are given a string s, consisting only of Latin letters 'a', and a string t, consisting of lowercase Latin letters.
// In one move, you can replace any letter 'a' in the string s with a string t. Note that after the replacement string s might contain letters other than 'a'.
// You can perform an arbitrary number of moves (including zero). How many different strings can you obtain? Print the number, or report that it is infinitely large.
// Two strings are considered different if they have different length, or they differ at some index.

// Input
// The first line contains a single integer q (1≤q≤104) — the number of testcases.
// The first line of each testcase contains a non-empty string s, consisting only of Latin letters 'a'. The length of s doesn't exceed 50.
// The second line contains a non-empty string t, consisting of lowercase Latin letters. The length of t doesn't exceed 50.

// Output
// For each testcase, print the number of different strings s that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.

// Example
// input
// 3
// aaaa
// a
// aa
// abc
// a
// b
// output
// 1
// -1
// 2

// Note

// In the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.
// In the second example, you can replace the second letter 'a' with "abc". String s becomes equal to "aabc". Then the second letter 'a' again. String s becomes equal to "aabcbc". And so on, generating infinitely many different strings.
// In the third example, you can either leave string s as is, performing zero moves, or replace the only 'a' with "b". String s becomes equal to "b", so you can't perform more moves on it.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, q int
	var s, t string

	for c, _ = fmt.Fscan(reader, &q); c == 1; c, _ = fmt.Fscan(reader, &q) {
		for ; q > 0; q-- {
			fmt.Fscan(reader, &s, &t)

			if t == "a" {
				fmt.Fprintln(writer, 1)
			} else if strings.Count(t, "a") != 0 {
				fmt.Fprintln(writer, -1)
			} else {
				fmt.Fprintln(writer, math.Pow(2, float64(len(s))))
			}
		}
	}

	writer.Flush()
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		t, _ := reader.ReadString('\n')
		if t[len(t)-1] == 10 {
			t = t[:len(t)-1]
		}
		if t[len(t)-1] == 13 {
			t = t[:len(t)-1]
		}

		done := false

		if len(t) == 1 && t[0] == 97 {
			fmt.Println(1)
			continue
		}

		for i := 0; i < len(t); i++ {
			if t[i] == 97 {
				fmt.Println(-1)
				done = true
				break
			}
		}
		if done {
			continue
		}

		ans := int( math.Pow(2, float64(len(s))) )
		fmt.Println(ans)
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		t, _ := reader.ReadString('\n')
		if t[len(t)-1] == 10 {
			t = t[:len(t)-1]
		}
		if t[len(t)-1] == 13 {
			t = t[:len(t)-1]
		}

		done := false

		if len(t) == 1 && t[0] == 97 {
			fmt.Println(1)
			continue
		}

		for i := 0; i < len(t); i++ {
			if t[i] == 97 {
				fmt.Println(-1)
				done = true
				break
			}
		}
		if done {
			continue
		}

		ans := int( math.Pow(2, float64(len(t))) )
		fmt.Println(ans)
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		t, _ := reader.ReadString('\n')
		if t[len(t)-1] == 10 {
			t = t[:len(t)-1]
		}
		if t[len(t)-1] == 13 {
			t = t[:len(t)-1]
		}

		done := false

		if len(t) == 1 && t[0] == 97 {
			fmt.Println(1)
			continue
		}

		for i := 0; i < len(t); i++ {
			if t[i] == 97 {
				fmt.Println(-1)
				done = true
				break
			}
		}
		if done {
			continue
		}

		n := len(s)
		ans := ( ( n * (n-1) ) + 2 )
		fmt.Println(ans)
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		t, _ := reader.ReadString('\n')
		if t[len(t)-1] == 10 {
			t = t[:len(t)-1]
		}
		if t[len(t)-1] == 13 {
			t = t[:len(t)-1]
		}

		done := false

		if len(t) == 1 && t[0] == 97 {
			fmt.Println(1)
			continue
		}

		for i := 0; i < len(t); i++ {
			if t[i] == 97 {
				fmt.Println(-1)
				done = true
				break
			}
		}
		if done {
			continue
		}

		c := 1
		for i := 0; i < len(s); i++ {
			if s[i] == 97 {
				c++
			}
		}
		fmt.Println(c)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	c1674(os.Stdin, os.Stdout)
}

func c1674(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var x string
	var y string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		Fscan(in, &y)

		ac := 0
		ot := 0
		for _, v := range y {
			if v == 'a' {
				ac++
			} else {
				ot++
			}
		}
		ans := int64(0)
		if ac > 0 {
			if len(y) > 1 {
				ans = -1
			} else {
				ans = 1
			}
		} else if ac == 0 {
			ans = quickPow(2, len(x))
		}
		Fprintln(out, ans)
	}
}

func quickPow(a, n int) int64 {
	ans := int64(1)
	for n > 0 {
		if n&1 > 0 {
			ans = ans * int64(a)
		}
		a *= a
		n /= 2
	}
	return ans
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	c1674(os.Stdin, os.Stdout)
}

func c1674(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var x string
	var y string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		Fscan(in, &y)

		//if y == "a" {
		//	Fprintln(out, 1)
		//	continue loop
		//}
		//for _, v := range y {
		//	if v == 'a' {
		//		Fprintln(out, -1)
		//		continue loop
		//	}
		//}

		cnt := 0
		nc := 0
		for _, v := range y {
			if v == 'a' {
				cnt++
			} else {
				nc++
			}
		}
		if nc == 0 {
			if len(y) == 1 {
				Fprintln(out, 1)
			} else {
				Fprintln(out, len(x)+1)
			}
		} else if nc > 0 && cnt > 0 {
			Fprintln(out, -1)
		} else if cnt == 0 && nc > 0 {
			Fprintln(out, quickPow(2, len(x)))
		}
	}
}

func quickPow(a, n int) int64 {
	ans := int64(1)
	for n > 0 {
		if n&1 > 0 {
			ans = ans * int64(a)
		}
		a *= a
		n /= 2
	}
	return ans
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	c1674(os.Stdin, os.Stdout)
}

func c1674(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var x string
	var y string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		Fscan(in, &y)

		//if y == "a" {
		//	Fprintln(out, 1)
		//	continue loop
		//}
		//for _, v := range y {
		//	if v == 'a' {
		//		Fprintln(out, -1)
		//		continue loop
		//	}
		//}

		cnt := 0
		nc := 0
		for _, v := range y {
			if v == 'a' {
				cnt++
			} else {
				nc++
			}
		}
		if nc == 0 {
			if len(y) == 1 {
				Fprintln(out, 1)
			} else {
				Fprintln(out, len(x)+1)
			}
		} else if nc > 0 && cnt > 0 {
			Fprintln(out, -1)
		} else if cnt == 0 && nc > 0 {
			Fprintln(out, quickPow(2, cnt))
		}
	}
}

func quickPow(a, n int) int64 {
	ans := int64(1)
	for n > 0 {
		if n&1 > 0 {
			ans = ans * int64(a)
		}
		a *= a
		n /= 2
	}
	return ans
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	c1674(os.Stdin, os.Stdout)
}

func c1674(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var x string
	var y string

loop:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		Fscan(in, &y)

		if y == "a" {
			Fprintln(out, 1)
			continue loop
		}
		for _, v := range y {
			if v == 'a' {
				Fprintln(out, -1)
				continue loop
			}
		}

		cnt := 0
		for _, v := range x {
			if v == 'a' {
				cnt++
			}
		}
		Fprintln(out, quickPow(2, cnt))
	}
}

func quickPow(a, n int) int64 {
	ans := int64(1)
	for n > 0 {
		if n&1 > 0 {
			ans = ans * int64(a)
		}
		a *= a
		n /= 2
	}
	return ans
}

package main

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

func main() {
	CF1674C(os.Stdin, os.Stdout)
}

func CF1674C(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	t := 0
	fmt.Fscan(in, &t)
	str1 := ""
	str2 := ""
	for ; t > 0; t-- {
		fmt.Fscan(in, &str1)
		fmt.Fscan(in, &str2)
		mp := make(map[rune]bool)
		for _, ch := range str2 {
			mp[ch] = true
		}
		if mp['a'] && len(mp) > 1 {
			fmt.Fprintln(out, -1)
			continue
		} else if mp['a'] && len(mp) == 1 {
			fmt.Fprintln(out, 1)
		} else {
			ans := math.Pow(2, float64(len(str1)))
			fmt.Fprintln(out, int64(ans))
		}
	}
}

package main

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

func main() {
	CF1674C(os.Stdin, os.Stdout)
}

func CF1674C(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	t := 0
	fmt.Fscan(in, &t)
	str1 := ""
	str2 := ""
	for ; t > 0; t-- {
		fmt.Fscan(in, &str1)
		fmt.Fscan(in, &str2)
		mp := make(map[rune]bool)
		for _, ch := range str2 {
			mp[ch] = true
		}
		if mp['a'] && len(mp) > 1 {
			fmt.Fprintln(out, -1)
			continue
		} else if mp['a'] && len(mp) == 1 {
			fmt.Fprintln(out, 1)
		} else {
			ans := math.Pow(2, float64(len(str2)))
			fmt.Fprintln(out, int64(ans))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var s, t string
		fmt.Fscan(in, &s, &t)
		if t == "a" {
			fmt.Fprintln(out, 1)
		} else if strings.Contains(t, "a") {
			fmt.Fprintln(out, -1)
		} else {
			count := strings.Count(s, "a")
			fmt.Fprintln(out, math.Pow(2, float64(count)))
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
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 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()
	for tt:=1;tt<=T;tt++ {
		s := gs(); t := gs()
		aint := false; for _,c := range t { if c == 'a' { aint = true } }
		ans := 0
		if len(t) == 1 && aint {
			ans = 1
		} else if aint {
			ans = -1
		} else {
			ans = 1<<len(s)
		}
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

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

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var s1, s2 string
		fmt.Fscan(in, &s1, &s2)

		if s2 == "a" {
			fmt.Fprintln(out, 1)
			continue
		}

		if strings.Contains(s2, "a") {
			fmt.Fprintln(out, -1)
			continue
		}

		fmt.Fprintln(out, math.Pow(float64(2), float64(len(s1))))
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	defer w.Flush()
	var s, t string
	fmt.Fscan(r, &s, &t)
	if len(t) > 1 && strings.Contains(t, "a") {
		fmt.Fprintln(w, "-1")
		return
	}
	if len(t) == 1 {
		if t[0] == 'a' {
			fmt.Fprintln(w, "1")
			return
		}
	}
	n := len(s)
	fmt.Fprintln(w, (1 << n))
}

func main() {
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

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 s1, s2 string
		fmt.Fscan(in, &s1, &s2)

		var a1 int
		for _, ch := range s1 {
			if ch == 'a' {
				a1++
			}
		}

		var a2 int
		for _, ch := range s2 {
			if ch == 'a' {
				a2++
			}
		}

		if a1 == len(s1) && a2 == 1 && len(s2) == 1 || a1 == 0 {
			fmt.Fprintln(out, 1)
		} else if a1 > 0 && a2 > 1 {
			fmt.Fprintln(out, -1)
		} else if a1 > 0 && a2 > 0 && len(s2) != a2 {
			fmt.Fprintln(out, -1)
		} else {
			x := 1
			for i := 0; i < a1; i++ {
				x *= 2
			}
			fmt.Fprintln(out, x)
		}
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
loop:
	for t := io.ReadInt(); t > 0; t-- {
		s := io.ReadString()
		u := io.ReadString()

		if u == "a" {
			fmt.Println(1)
			continue loop
		}

		for _, v := range u {
			if v == 'a' {
				fmt.Println(-1)
				continue loop
			}
		}

		ans := 1
		for i := 0; i < len(s); i++ {
			ans *= 2
		}

		fmt.Println(ans)
	}
}


Vova's house is an array consisting of $$$n$$$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $$$i$$$-th element of the array is $$$1$$$ if there is a heater in the position $$$i$$$, otherwise the $$$i$$$-th element of the array is $$$0$$$.Each heater has a value $$$r$$$ ($$$r$$$ is the same for all heaters). This value means that the heater at the position $$$pos$$$ can warm up all the elements in range $$$[pos - r + 1; pos + r - 1]$$$.Vova likes to walk through his house while he thinks, and he hates cold positions of his house. Vova wants to switch some of his heaters on in such a way that each element of his house will be warmed up by at least one heater. Vova's target is to warm up the whole house (all the elements of the array), i.e. if $$$n = 6$$$, $$$r = 2$$$ and heaters are at positions $$$2$$$ and $$$5$$$, then Vova can warm up the whole house if he switches all the heaters in the house on (then the first $$$3$$$ elements will be warmed up by the first heater and the last $$$3$$$ elements will be warmed up by the second heater).Initially, all the heaters are off.But from the other hand, Vova didn't like to pay much for the electricity. So he wants to switch the minimum number of heaters on in such a way that each element of his house is warmed up by at least one heater.Your task is to find this number of heaters or say that it is impossible to warm up the whole house.

The first line of the input contains two integers $$$n$$$ and $$$r$$$ ($$$1 \le n, r \le 1000$$$) — the number of elements in the array and the value of heaters. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$) — the Vova's house description.

Print one integer — the minimum number of heaters needed to warm up the whole house or -1 if it is impossible to do it.

NoteIn the first example the heater at the position $$$2$$$ warms up elements $$$[1; 3]$$$, the heater at the position $$$3$$$ warms up elements $$$[2, 4]$$$ and the heater at the position $$$6$$$ warms up elements $$$[5; 6]$$$ so the answer is $$$3$$$.In the second example the heater at the position $$$1$$$ warms up elements $$$[1; 3]$$$ and the heater at the position $$$5$$$ warms up elements $$$[3; 5]$$$ so the answer is $$$2$$$.In the third example there are no heaters so the answer is -1.In the fourth example the heater at the position $$$3$$$ warms up elements $$$[1; 5]$$$, the heater at the position $$$6$$$ warms up elements $$$[4; 8]$$$ and the heater at the position $$$10$$$ warms up elements $$$[8; 10]$$$ so the answer is $$$3$$$.

package main

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

var n, r int
var a [1050]int

var ans = 0
var coveredTo = -1
var p = 0

func getNext(toCover int) int {
  next := -1
  for p < n {
    // fmt.Println(p)
    if a[p] == 0 {
      p++
      continue
    }
    if p + r - 1 < toCover {
      p++
      continue
    }
    if p - r + 1 > toCover {
      break
    }
    next = p
    p++
  }
  return next
}

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

  fmt.Fscanf(reader, "%d %d\n", &n, &r);
  for i := 0; i < n; i++ {
    fmt.Fscanf(reader, "%d", &a[i])
  }

  for i := 0; i < n; i++ {
    if coveredTo < i {
      next := getNext(i)
      if next == -1 {
        fmt.Fprintf(writer, "%d\n", -1)
        return
      }
      coveredTo = next + r - 1
      ans++
    }
  }

  fmt.Fprintf(writer, "%d\n", ans)
}

package main

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

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

	var n, r int
	a := make([]int, 1000+5)
	vis := make([]int, 1000+5)

	fmt.Fscan(reader, &n, &r)
	for i := 1; i <= n; i ++{
		fmt.Fscan(reader, &a[i]);
	}

	last, lasta, ok, ans := 1, -1, 1, 0
	_ = vis
	_ = last
	_ = lasta
	_ = ans

	for i := 1; i <= n; i ++{
		if a[i] == 1{
			if last >= i - r + 1{
				lasta = i
				continue
			}
			if lasta == -1 || lasta + r - 1 < last || lasta - r + 1 > last{
				if(i + r - 1 < last || i - r + 1 > last) {
					ok = 0
					break
				}
				ans ++
				lasta = i
				last = i + r
			}else {
				last = lasta + r
				lasta = i
				ans ++
			}
		}
	}
	//fmt.Println(ans, last, lasta)
	if last <= n{
		if lasta == -1 || lasta - r + 1 > last || lasta + r - 1 < n{
			ok = 0
		}
		ans ++
	}

	if ok == 0{
		fmt.Fprint(writer, -1)
		return
	}else if ok == 1 {
		fmt.Fprint(writer, ans)
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	scanner.Scan()
	w, _ := strconv.Atoi(scanner.Text())
	arr := []string{}
	for scanner.Scan() {
		arr = append(arr, scanner.Text())
	}

	unHeatIndex, count := 0, 0
	for unHeatIndex < len(arr) {
		l, r, pos := unHeatIndex-w+1, unHeatIndex+w-1, -1
		for i := l; i <= r; i++ {
			if (i >= 0) && (i < len(arr)) && (arr[i] == "1") {
				pos = i
			}
		}
		if pos == -1 {
			fmt.Println(-1)
			os.Exit(0)
		}
		unHeatIndex = pos + w
		count++
	}
	fmt.Println(count)
}

package main

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

const (
	MaxIntervals = 100000
)

type interval struct {
	start, end int
}

var n, r int
var a []interval
var dp []int

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &r)
	a = make([]interval, 0)
	dp = make([]int, n + 1)
	for i := 1; i <= n; i++ {
		var tmp int
		fmt.Fscanf(buf, "%d", &tmp)
		if tmp == 1 {
			start := i - r + 1
			if start < 1 {
				start = 1
			}
			end := i + r - 1
			if end > n {
				end = n
			}
			a = append(a, interval{start, end})
		}
	}
	m := len(a)
	dp[0] = 0
	for i := 1; i <= n; i++ {
		dp[i] = MaxIntervals
		for j := 0; j < m; j++ {
			if a[j].start <= i && i <= a[j].end {
				k := dp[a[j].start-1] + 1
				if k < dp[i] {
					dp[i] = k
				}
			}
		}
		if dp[i] == MaxIntervals {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(dp[n])
}

package main

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

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

	var n, r int
	a := make([]int, 1000+5)
	vis := make([]int, 1000+5)

	fmt.Fscan(reader, &n, &r)
	for i := 1; i <= n; i ++{
		fmt.Fscan(reader, &a[i]);
	}

	last, lasta, ok, ans := 1, -1, 1, 0
	_ = vis
	_ = last
	_ = lasta
	_ = ans

	for i := 1; i <= n; i ++{
		if a[i] == 1{
			if last >= i - r + 1{
				lasta = i
				continue
			}
			if lasta == -1 || lasta + r - 1 < last || lasta - r + 1 > last{
				ok = 0
				break
			}
			last = lasta + r - 1
			lasta = i
			ans ++
		}
	}
	//fmt.Println(ans, last, lasta)
	if last < n{
		if lasta == -1 || lasta + r - 1 <= n{
			ok = 0
		}
		ans ++
	}

	if ok == 0{
		fmt.Fprint(writer, -1)
		return
	}else if ok == 1 {
		fmt.Fprint(writer, ans)
	}
}

package main

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

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

	var n, r int
	a := make([]int, 1000+5)
	vis := make([]int, 1000+5)

	fmt.Fscan(reader, &n, &r)
	for i := 1; i <= n; i ++{
		fmt.Fscan(reader, &a[i]);
	}

	last, lasta, ok, ans := 1, -1, 1, 0
	_ = vis
	_ = last
	_ = lasta
	_ = ans

	for i := 1; i <= n; i ++{
		if a[i] == 1{
			if last >= i - r + 1{
				lasta = i
				continue
			}
			if lasta == -1 || lasta + r - 1 < last || lasta - r + 1 > last{
				if(i + r - 1 < last || i - r + 1 > last) {
					ok = 0
					break
				}
				ans ++
				lasta = i
				last = i + r
			}else {
				last = lasta + r
				lasta = i
				ans ++
			}
		}
	}
	//fmt.Println(ans, last, lasta)
	if last <= n{
		if lasta == -1 || lasta + r - 1 < n{
			ok = 0
		}
		ans ++
	}

	if ok == 0{
		fmt.Fprint(writer, -1)
		return
	}else if ok == 1 {
		fmt.Fprint(writer, ans)
	}
}

package main

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

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

	var n, r int
	a := make([]int, 1000+5)
	vis := make([]int, 1000+5)

	fmt.Fscan(reader, &n, &r)
	for i := 1; i <= n; i ++{
		fmt.Fscan(reader, &a[i]);
	}

	last, lasta, ok, ans := 1, -1, 1, 0
	_ = vis
	_ = last
	_ = lasta
	_ = ans

	for i := 1; i <= n; i ++{
		if a[i] == 1{
			if last >= i - r + 1{
				lasta = i
				continue
			}
			if lasta == -1 || lasta + r - 1 < last || lasta - r + 1 > last{
				ok = 0
				break
			}
			last = lasta + r
			lasta = i
			ans ++
		}
	}
	//fmt.Println(ans, last, lasta)
	if last <= n{
		if lasta == -1 || lasta + r - 1 <= n{
			ok = 0
		}
		ans ++
	}

	if ok == 0{
		fmt.Fprint(writer, -1)
		return
	}else if ok == 1 {
		fmt.Fprint(writer, ans)
	}
}


Formula 1 officials decided to introduce new competition. Cars are replaced by space ships and number of points awarded can differ per race.Given the current ranking in the competition and points distribution for the next race, your task is to calculate the best possible ranking for a given astronaut after the next race. It's guaranteed that given astronaut will have unique number of points before the race.

The first line contains two integer numbers $$$N$$$ ($$$1 \leq N \leq 200000$$$) representing number of F1 astronauts, and current position of astronaut $$$D$$$ ($$$1 \leq D \leq N$$$) you want to calculate best ranking for (no other competitor will have the same number of points before the race). The second line contains $$$N$$$ integer numbers $$$S_k$$$ ($$$0 \leq S_k \leq 10^8$$$, $$$k=1...N$$$), separated by a single space, representing current ranking of astronauts. Points are sorted in non-increasing order. The third line contains $$$N$$$ integer numbers $$$P_k$$$ ($$$0 \leq P_k \leq 10^8$$$, $$$k=1...N$$$), separated by a single space, representing point awards for the next race. Points are sorted in non-increasing order, so winner of the race gets the maximum number of points.

Output contains one integer number — the best possible ranking for astronaut after the race. If multiple astronauts have the same score after the race, they all share the best ranking.

NoteIf the third ranked astronaut wins the race, he will have 35 points. He cannot take the leading position, but he can overtake the second position if the second ranked astronaut finishes the race at the last position.

// Codeforces 1046 C Space Formula, train
package main

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

var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var n,d int
var s []int
var p []int
var bestRank int

func readData() {
	in = bufio.NewReader(os.Stdin)
	n,d,_,_,_ = readFive()
	s = readLineNumbs(n)
	p = readLineNumbs(n)
}

func solve() {
	d = d-1
	gpo := s[d] + p[0]
	s = append(s[0 : d], s[d+1 : n]...)
	p = p[1 : n]
	ip := n-2
	worse := 0
	for i := 0; i<n-1 && ip>=0; {
		sum := p[ip] + s[i];
		// fmt.Println("i,ip,sum,worse = ",i,ip,sum, worse)
		if sum <= gpo {
			worse++
			i++
			ip--
		} else {
			i++
		}
	}
	bestRank = n-worse
}

func printRes() {
	fmt.Println(bestRank)
}

func main() {
	readData()
	solve()
	printRes()
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()

  var N,D,i int64

  scanf("%d %d\n", &N, &D)
  lineS, _ := reader.ReadString('\n')
  lineS = strings.TrimSuffix(lineS, "\r\n")
  lineP, _ := reader.ReadString('\n')
  lineP = strings.TrimSuffix(lineP, "\r\n")
  S := strings.Split(lineS, " ")
  P := strings.Split(lineP, " ")
  tmpC,_ := strconv.ParseInt(S[D-1], 10, 64)
  tmpM,_ := strconv.ParseInt(P[0], 10, 64)
  tmpV := tmpC+tmpM
  rank := D
  N--
  for i = 0 ; i < D-1 ; i++ {
    tmpP,_ := strconv.ParseInt(P[N], 10, 64)
    tmpS,_ := strconv.ParseInt(S[i], 10, 64)
    if tmpP + tmpS <= tmpV {
      rank--
      N--
    }
  }
  printf("%d\n", rank)

}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()

  var N,D,i int64

  scanf("%d %d\n", &N, &D)
  lineS, _ := reader.ReadString('\n')
  lineS = strings.TrimSuffix(lineS, "\r\n")
  lineP, _ := reader.ReadString('\n')
  lineP = strings.TrimSuffix(lineP, "\r\n")
  S := strings.Split(lineS, " ")
  P := strings.Split(lineP, " ")
  tmpC,_ := strconv.ParseInt(S[D-1], 10, 64)
  tmpM,_ := strconv.ParseInt(P[0], 10, 64)
  rank1 := D
  indexN := N
  for i = D-2 ; i>0 ; i-- {
      tmpS,_ := strconv.ParseInt(S[i], 10, 64)
      indexN--
      tmpP,_ := strconv.ParseInt(P[indexN], 10, 64)
      if tmpS+tmpP <= tmpC+tmpM {
        rank1--
      }else{
        break
      }
  }
  rank2 := D
  indexN = N
  for i = 0 ; i < D-1 ; i++ {
      tmpS,_ := strconv.ParseInt(S[i], 10, 64)
      indexN--
      tmpP,_ := strconv.ParseInt(P[indexN], 10, 64)
      if tmpS+tmpP <= tmpC+tmpM {
        rank2--
      }
  }
  if rank1 > rank2 {
    printf("%d\n", rank2)
  }else{
    printf("%d\n", rank1)
  }

}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()

  var N,D int64

  scanf("%d %d\n", &N, &D)
  lineS, _ := reader.ReadString('\n')
  lineS = strings.TrimSuffix(lineS, "\r\n")
  lineP, _ := reader.ReadString('\n')
  lineP = strings.TrimSuffix(lineP, "\r\n")
  S := strings.Split(lineS, " ")
  P := strings.Split(lineP, " ")
  rank := D
  for i := D-2 ; i>0 ; i-- {
      tmpC,_ := strconv.ParseInt(S[D-1], 10, 64)
      tmpM,_ := strconv.ParseInt(P[0], 10, 64)
      tmpS,_ := strconv.ParseInt(S[i], 10, 64)
      N--
      tmpP,_ := strconv.ParseInt(P[N], 10, 64)
      if tmpC+tmpM >= tmpS+tmpP  {
        rank--
      }else{
          break
      }
  }
  printf("%d\n", rank)

}