package main

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

func main() {
	var t, n int
	var input string
	var out byte
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &input)
		fmt.Printf("1")
		sum := (input[0] - '0') + 1
		for j := 1; j < n; j++ {
			//fmt.Println("--", int(sum), string(input[j]))
			sum, out = getOut(input[j], sum)
			//fmt.Println(int(sum), string(out))
			fmt.Printf("%s", string(out))
		}
		fmt.Println()
	}
}

func getOut(a byte, prev byte) (byte, byte) {
	switch prev {
	case 2:
		if a == '1' {
			return 1, '0'
		}
		return 1, '1'
	case 1:
		if a == '1' {
			return 2, '1'
		}
		return 0, '0'
	case 0:
		return a - '0' + 1, '1'
	}
	return 1, '1'
}

package main

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

type CF1474A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1474A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1474A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1474A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1474A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1474A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1474A
Date: 17/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1474/A
Problem: CF1474A
**/
func (in *CF1474A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		a := in.NextString()
		var sol strings.Builder
		result := ""
		for i := 0; i < n; i++ {
			choose := ""
			if i == 0 {
				choose = "1"
			} else {
				if a[i] == '1' {
					if result == "2" {
						choose = "0"
					} else {
						choose = "1"
					}
				} else {
					if result == "1" {
						choose = "0"
					} else {
						choose = "1"
					}
				}
			}

			if choose == "1" && a[i] == '1' {
				result = "2"
			} else if (choose == "0" && a[i] == '1') || (choose == "1" && a[i] == '0') {
				result = "1"
			} else if choose == "0" && a[i] == '0' {
				result = "0"
			}
			sol.WriteString(choose)
		}
		fmt.Println(sol.String())
	}
}

func NewCF1474A(r *bufio.Reader) *CF1474A {
	return &CF1474A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1474A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

func ReadLine(reader *bufio.Reader) string {
    line, _ := reader.ReadString('\n')
    return strings.TrimRight(strings.TrimRight(line, "\n"), "\r")
}

func ReadInt(reader *bufio.Reader) int {
    num, _ := strconv.Atoi(ReadLine(reader))
    return num
}

func ReadArray(reader *bufio.Reader) []int {
    line := ReadLine(reader);
    strs := strings.Split(line, " ")
    nums := make([]int, len(strs))
    for i, s := range strs {
        nums[i], _ = strconv.Atoi(s)
    }
    return nums
}

func main() {
    reader := bufio.NewReader(os.Stdin)
    T := ReadInt(reader)
    for casi := 0; casi < T; casi++ {
        ReadInt(reader)
        s := ReadLine(reader);

        r := []rune(s)
        pre := 0
        for i, c := range r {
            x := int(c - 48)
            if x + 1 == pre {
                r[i] = 0
            } else {
                r[i] = 1
            }
            pre = x + int(r[i])
            r[i] += 48
        }

        fmt.Println(string(r))
    }
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := scanInt(); t > 0; t-- {
		n := scanInt()
		b := ScanString()
		a := make([]rune, n)

		prevC := '0'
		for i, c := range b {
			if c+1 != prevC {
				a[i] = '1'
				prevC = c + 1
			} else {
				a[i] = '0'
				prevC = c
			}
		}

		fmt.Println(string(a))
	}
}

package main

import (
  "errors"
  "fmt"
)

func main() {
  cases, err := readInput()
  if err != nil {
    panic(err)
  }
  for _, c := range cases {
    c.findA()
    fmt.Printf("%v\n", c.a)
  }
}

type TestCase struct {
  b string
  a string
}

func (t *TestCase) findA() (string, error) {
  prevSum := 0
  aArr := make([]rune, len(t.b))
  for i, bi := range t.b {
    biInt := int(bi - '0')
    var aiInt int
    switch prevSum {
      case 2: // Get 1
        aiInt = 1 - biInt
      case 1: // Get 2 if possible, else get 0
        if biInt == 1 {
          aiInt = 1
        } else {
          aiInt = 0
        }
      case 0: // Get 2 if possible, else get 1
        aiInt = 1 // works if ai == 1 or ai == 0
      default:
        return "", errors.New(fmt.Sprintf("Unexpected previous sum not 0, 1, or 2...", prevSum))
    }

    aArr[i] = rune(aiInt) + '0'
    prevSum = aiInt + biInt
  }
  a := string(aArr)
  t.a = a
  return a, nil
}

func readInput() ([]*TestCase, error) {
  var numTestCases int
  fmt.Scanf("%d\n", &numTestCases)
  ret := make([]*TestCase, numTestCases)
  for i := 0; i < numTestCases; i++ {
    var strLen int
    var str string
    fmt.Scanf("%d\n", &strLen)
    fmt.Scanf("%s\n", &str)
    if len(str) != strLen {
      return nil, errors.New(fmt.Sprintf("string %v length %v did not match expected length %v", str, len(str), strLen))
    }
    ret[i] = &TestCase{
      b: str,
    }
  }
  return ret, nil
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int
	b   string
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &n)
		fmt.Fscan(in, &b)

		solve2(n, b)

	}

}

func solve2(n int, b string) {

	a := make([]byte, n)
	a[0] = '1'

	for i := 1; i < n; i++ {

		if getSum(b[i-1], a[i-1]) != getSum(b[i], '1') {
			a[i] = '1'
		} else {
			a[i] = '0'
		}

	}

	printCharArr(a)

}

//印出字元陣列
func printCharArr(array []byte) {

	for i := range array {
		fmt.Fprintf(out, "%c", array[i])
	}

	fmt.Fprintln(out)

}

func getSum(a byte, b byte) int {
	return int((a - '0') + (b - '0'))
}

func solve(n int, b string) {

	bArray := make([]int, n)
	d := make([]int, n)

	//轉成數字陣列
	for i := range b {

		if b[i] == '1' {
			bArray[i] = 1
		} else {
			bArray[i] = 0
		}

	}

	for i := range bArray {

		if bArray[i] == 1 {
			d[i] = 2
		} else {
			d[i] = 1
		}

	}

	for i := 1; i < n; i++ {

		if d[i] == d[i-1] {
			if d[i] == 2 {
				d[i] = 1
			} else {
				d[i] = 2
			}
		}

	}

	printIntArr(d)

	for i := range d {
		if d[i] == 2 && bArray[i] == 0 {
			if i > 0 && d[i]-1 != d[i-1] {
				fmt.Print(1)
			} else {
				fmt.Print(0)
			}
			if i != n-1 {
				d[i+1] = 2
			}

		} else {
			fmt.Print(d[i] - bArray[i])
		}
	}

	fmt.Println()

}

//印出數字陣列
func printIntArr(array []int) {

	for i := range array {
		fmt.Printf("%d ", array[i])
	}

	fmt.Println()

}

package main

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

// var f, _ = os.Open("./inp")
// var reader *bufio.Reader = bufio.NewReader(f)

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() {
	var t int64
	scanf("%d\n", &t)
	for index := int64(0); index < t; index++ {
		var n int64
		scanf("%d\n", &n)
		bin := make([]int64, n)
		var binStr string
		scanf("%s\n", &binStr)
		for i := int64(0); i < n; i++ {
			bin[i] = int64(binStr[i] - '0')
		}
		result := process(bin)
		for i := int64(0); i < n; i++ {
			fmt.Printf("%d", result[i])
		}
		fmt.Printf("\n")
	}
}

func process(a []int64) []int64 {
	result := make([]int64, len(a))
	currentState := make([]int64, len(a))
	for index := 0; index < len(a); index++ {
		if index == 0 {
			result[index] = 1
			currentState[index] = result[index] + a[index]
			continue
		}
		if 1+a[index] == currentState[index-1] {
			result[index] = 0
		} else {
			result[index] = 1
		}
		currentState[index] = result[index] + a[index]
	}
	return result
}

package main

import (
  "os"
  "bufio"
  "fmt"
  "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() {
  // STDOUT MUST BE FLUSHED MANUALLY!!!
  defer writer.Flush()

  var t, n, i, j uint64
  var prev int
  var a [100001]rune
  var b string
  scanf("%d\n", &t);
  for j=0;j<t;j++ {
    prev = 0
    scanf("%d\n",&n);
    scanf("%s\n",&b);
    for i=0;i<n;i++ {
        if i==0 {
          a[i] = '1'
          prev, _ = strconv.Atoi(string(b[i]))
          prev = prev + 1
          continue
        } else {
          if b[i] == '0' && prev == 0 {
            a[i] = '1'
            prev = 1
          } else if b[i] == '0' && prev == 1 {
            a[i] = '0'
            prev = 0
          } else if b[i] == '0' && prev == 2 {
            a[i] = '1'
            prev = 1
          } else if b[i] == '1' && prev == 0 {
            a[i] = '1'
            prev = 2
          } else if b[i] == '1' && prev == 1 {
            a[i] = '1'
            prev = 2
          } else if b[i] == '1' && prev == 2 {
            a[i] = '0'
            prev = 1
          }
        }
    }
    for i=0;i<n;i++ {
      printf("%c",a[i])
    }
    printf("\n")
  }

//  var a, b int
//  scanf("%d %d\n", &a, &b)
//  printf("%d\n", a+b)

}

package main

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

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		_ = sint64()
		b := sstring()
		printf("%s\n", sol(b))
	}
}

func sol(b string) string {
	ret := "1"
	prev := b[0] + 1
	for i := 1; i < len(b); i++ {
		byt := b[i]
		if byt+1 != prev {
			ret += "1"
			prev = byt + 1
			continue
		}
		ret += "0"
		prev = byt
	}
	return ret
}

package main

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

func main() {
	rd:=bufio.NewReader(os.Stdin)
	tx, _:=rd.ReadBytes('\n')
	l,_ := strconv.Atoi(strings.Trim(strings.Trim(string(tx), "\n"), "\r"))
	for i:=0; i<l;i++{
		sin, _:=rd.ReadBytes('\n')
		lenv,_:=strconv.Atoi(strings.Trim(strings.Trim(string(sin), "\n"), "\r"))
		s,_ := rd.ReadBytes('\n')
		s = []byte(strings.Trim(strings.Trim(string(s), "\n"), "\r"))
		m:=make([]int, lenv)
		for j:=0; j<lenv; j++{
			m[j], _= strconv.Atoi(string(s[j]))
		}
		r:=fn(m)
		rss:=""
		for j:=0; j < lenv; j++{
			rss += strconv.Itoa(r[j])
		}
		fmt.Printf("%s\n", rss)
	}
}

func fn(b []int) (res []int){
	res = make([]int, len(b))
	res[0] = 1
	pr:=res[0] + b[0]
	for i:=1; i<len(b); i++{
		if pr != (1 + b[i]){
			res[i] = 1
			pr = 1 + b[i]
		}else{
			res[i] = 0
			pr = b[i]
		}
	}

	return res
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var t int
	fmt.Scanln(&t)
	for t>0{
		var s int
		fmt.Scanln(&s)
		var x string
		fmt.Scanln(&x)
		z:=""
		p:=""
		for i:=0;i<s;i++{
			if p==""{
				z+="1"
				p=strconv.Itoa(1+int(x[i]-'0'))
			} else if p=="1"{
				if x[i]=='1'{
					z+="1"
					p="2"
				} else{
					z+="0"
					p="0"
				}
			} else if p=="0"{
				z+="1"
				p=strconv.Itoa(1+int(x[i]-'0'))
			} else{
				if x[i]=='1'{
					z+="0"
					p="1"
				} else{
					z+="1"
					p="1"
				}
			}
			//fmt.Println(p)
		}
		fmt.Println(z)
		t--
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
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 n int
		fmt.Fscan(in,&n)
		var binary string
		fmt.Fscan(in,&binary)
		var list []int
		for j:=0;j<n;j++{
			s,_:= strconv.Atoi(string(binary[j]))
			list= append(list,s)
		}
		var output []int
		for j:=0;j<n;j++{
			if j==0{
				output= append(output,1)
				list[j]++
			} else {
				if list[j]+1 == list[j-1] {
					output= append(output,0)
				} else {
					output= append(output,1)
					list[j]++
				}
			}
		}
		for j:=0;j<n;j++{
			fmt.Fprintf(out,"%v",output[j])
		}
		fmt.Fprintln(out,)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscanln(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}
func solve() {
    var (
        n int
        b string
    )
    fmt.Fscanln(input, &n)
    fmt.Fscanln(input, &b)
    prev := byte('1')
    a := "1"
    prev = a[0] + b[0] - '0'
    for i := 1; i < len(b); i++ {
        if b[i] + byte('1') - '0' != prev {
            a += "1"
        } else {
            a += "0"
        }
        prev = a[i] + b[i] - '0'
    }
    fmt.Fprintln(output, a)
}

package main

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

func main() {
	rd:=bufio.NewReader(os.Stdin)
	tx, _,_:=rd.ReadLine()
	l,_ := strconv.Atoi(string(tx))
	for i:=0; i<l;i++{
		tx, _, _=rd.ReadLine()
		lenv,_:=strconv.Atoi(string(tx))
		s,pref,_ := rd.ReadLine()
		for pref{
			var s2 []byte
			s2,pref,_ = rd.ReadLine()
			s = []byte(string(s) + string(s2))
		}
		m:=make([]int, lenv)
		for j:=0; j<lenv; j++{
			m[j], _= strconv.Atoi(string(s[j]))
		}
		r:=fn(m)
		rss:=""
		for j:=0; j < lenv; j++{
			rss += strconv.Itoa(r[j])
		}
		fmt.Printf("%s\n", rss)
	}
}

func fn(b []int) (res []int){
	res = make([]int, len(b))
	res[0] = 1
	pr:=res[0] + b[0]
	for i:=1; i<len(b); i++{
		if pr != (1 + b[i]){
			res[i] = 1
			pr = 1 + b[i]
		}else{
			res[i] = 0
			pr = b[i]
		}
	}

	return res
}

package main

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

func main() {
	rd:=bufio.NewReader(os.Stdin)
	tx, _,_:=rd.ReadLine()
	l,_ := strconv.Atoi(string(tx))
	for i:=0; i<l;i++{
		tx, _, _=rd.ReadLine()
		lenv,_:=strconv.Atoi(string(tx))
		s,pref,_ := rd.ReadLine()
		for pref{
			var s2 []byte
			s2,pref,_ = rd.ReadLine()
			s = append(s, s2...)
		}
		m:=make([]int, lenv)
		for j:=0; j<lenv; j++{
			m[j], _= strconv.Atoi(string(s[j]))
		}
		r:=fn(m)
		rss:=""
		for j:=0; j < lenv; j++{
			rss += strconv.Itoa(r[j])
		}
		fmt.Printf("%s\n", rss)
	}
}

func fn(b []int) (res []int){
	res = make([]int, len(b))
	res[0] = 1
	pr:=res[0] + b[0]
	for i:=1; i<len(b); i++{
		if pr != (1 + b[i]){
			res[i] = 1
			pr = 1 + b[i]
		}else{
			res[i] = 0
			pr = b[i]
		}
	}

	return res
}

package main

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

func main() {
	rd:=bufio.NewScanner(os.Stdin)
	rd.Scan()
	l,_ := strconv.Atoi(rd.Text())
	for i:=0; i<l;i++{
		rd.Scan()
		lenv,_:=strconv.Atoi(rd.Text())
		rd.Scan()
		s:=rd.Bytes()
		m:=make([]int, lenv)
		if len(s) != len(m){
			return
		}
		for j:=0; j<lenv; j++{
			m[j], _= strconv.Atoi(string(s[j]))
		}
		r:=fn(m)
		rss:=""
		for j:=0; j < lenv; j++{
			rss += strconv.Itoa(r[j])
		}
		fmt.Printf("%s\n", rss)
	}
}

func fn(b []int) (res []int){
	res = make([]int, len(b))
	res[0] = 1
	pr:=res[0] + b[0]
	for i:=1; i<len(b); i++{
		if pr != (1 + b[i]){
			res[i] = 1
			pr = 1 + b[i]
		}else{
			res[i] = 0
			pr = b[i]
		}
	}

	return res
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var t int
	fmt.Scanln(&t)
	for t>0{
		var s int
		fmt.Scanln(&s)
		var x string
		fmt.Scanln(&x)
		z:=""
		p:=""
		for i:=0;i<s;i++{
			if p==""{
				z+="1"
				p=strconv.Itoa(1+int(x[i]-'0'))
			} else if p=="1"{
				if x[i]=='1'{
					z+="1"
					p="2"
				} else{
					z+="0"
					p="1"
				}
			} else if p=="0"{
				z+="1"
				p="1"
			} else{
				if x[i]=='1'{
					z+="0"
					p="1"
				} else{
					z+="1"
					p="1"
				}
			}
		}
		fmt.Println(z)
		t--
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
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 n int
		fmt.Fscan(in,&n)
		var binary string
		fmt.Fscan(in,&binary)
		var list []int
		for j:=0;j<n;j++{
			s,_:= strconv.Atoi(string(binary[j]))
			list= append(list,s)
		}
		var output []int
		for j:=0;j<n;j++{
			if j==0{
				output= append(output,1)
				list[j]++
			} else {
				if list[j]+1 == list[j-1] {
					output= append(output,0)
				} else {
					output= append(output,1)
					list[j]++
				}
			}
		}
		for j:=0;j<n;j++{
			fmt.Fprintf(out,"%v ",output[j])
		}
		fmt.Fprintln(out,)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscanln(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}
func solve() {
    var (
        n int
        b string
    )
    fmt.Fscanln(input, &n)
    fmt.Fscanln(input, &b)
    prev := byte('1')
    a := "1"
    prev = a[0] + b[0] - '0'
    for i := 1; i < len(b); i++ {
        fmt.Println("prev:", string(prev))
        if b[i] + byte('1') - '0' != prev {
            a += "1"
        } else {
            a += "0"
        }
        prev = a[i] + b[i] - '0'
    }
    fmt.Fprintln(output, a)
}


package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscanf(in, "%v\n", &t)
	for now := 0; now < t;now++ {
		var n int
		fmt.Fscanf(in, "%v\n", &n)
		mas := make([]int, n, n)
		var c1, c2 int
		for i := 0;i < n;i++ {
			fmt.Fscan(in, &mas[i])
			if mas[i] % 2 == 1 {
				c1++
			}
			if mas[i] % 2 != i % 2 {
				c2++
			}

		}
		fmt.Fscanf(in, "\n")
		if c1 == n / 2 {
			fmt.Fprintln(out, c2 / 2)
		} else {
			fmt.Fprintln(out, -1)
		}
	}
	return
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\r\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scan(&n)
        a := make([]int,40)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scan(&a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        //fmt.Printf("%d\n",n)
        if s0 != s1 {
            fmt.Println("-1")
        } else {
            fmt.Printf("%d\n",s0)
        }
    }
}

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-- {
		var n, a int
		var cnt [2]int
		fmt.Fscan(in, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			if i%2 != a%2 {
				cnt[a%2]++
			}
		}
		if cnt[0] == cnt[1] {
			fmt.Fprintln(out, cnt[0])
		} else {
			fmt.Fprintln(out, -1)
		}
	}
}

package main

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

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		fmt.Println(solve(n, A))
	}
}

func solve(n int, A []int) int {
	if n == 1 {
		if A[0]&1 == 0 {
			return 0
		}
		return -1
	}
	var j = 1

	var res int
	for i := 0; i < n; i += 2 {
		if A[i]&1 == 0 {
			continue
		}

		for j < n && A[j]&1 == 1 {
			j += 2
		}
		if j >= n {
			return -1
		}
		// A[j] & 1 == 0 && A[i] & 1 == 1
		A[i], A[j] = A[j], A[i]
		j += 2
		res++
	}

	for j < n && A[j]&1 == 1 {
		j += 2
	}

	if j < n {
		return -1
	}

	return res
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, tmp int
	fmt.Fscan(input, &n)
	even, odd := 0, 0
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if i & 1 == tmp & 1 { continue }
		if i & 1 == 1 {
			odd++
		} else {
			even++
		}
	}
	if even == odd {
		fmt.Println(even)
	} else {
		fmt.Println(-1)
	}
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		evens, odds := 0, 0
		for j := 0; j < n; j++ {
			var x int
			fmt.Fscan(in, &x)
			if j%2 == 0 && x%2 != 0 {
				evens++
			} else if j%2 != 0 && x%2 == 0 {
				odds++
			}
		}
		if evens == odds {
			fmt.Println(evens)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.ParseInt(string(line), 10, 64)
		line = readLine(reader)
		ans := strings.Split(string(line), " ")
		wepos, wopos := 0, 0
		for i := int64(0); i < n; i++ {
			ai, _ := strconv.ParseInt(ans[i], 10, 64)
			if ai%2 == 1 && i%2 == 0 {
				wepos++
			} else if ai%2 == 0 && i%2 == 1 {
				wopos++
			}
		}
		if wepos != wopos {
			fmt.Println(-1)
		} else {
			fmt.Println(wepos)
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import "fmt"

func main() {

	var t, n int
	var arr [40]int
	var ans [1000]int

	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		swap := 0
		odd := 0
		fmt.Scan(&n)
		cnt := n / 2
		for i := 0; i < n; i++ {
			fmt.Scan(&arr[i])
			if arr[i]%2 != 0 {
				odd++
				if i%2 == 0 {
					swap++
				}
			}
		}
		if cnt == odd {
			ans[i] = swap
		} else {
			ans[i] = -1
		}
	}

	for i := 0; i < t; i++ {
		fmt.Printf("%v\n", ans[i])
	}
}

package main

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

var (
	input = bufio.NewScanner(os.Stdin)
)

func getint() int {
	if input.Scan() {
		res, _ := strconv.Atoi(input.Text())
		return res
	}
	return -1
}

func main() {
	input.Split(bufio.ScanWords)

	var t = getint()
	for ; t > 0; t-- {
		var n = getint()
		var cnt1, cnt0 = 0, 0
		for i := 0; i < n; i++ {
			if i%2 != getint()%2 {
				if i%2 == 1 {
					cnt1++
				} else {
					cnt0++
				}
			}
		}
		if cnt1 != cnt0 {
			fmt.Printf("-1\n")
		} else{
			fmt.Printf("%d\n", cnt0)
		}
	}
}

package main

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

var n, nTest int

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

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n)
		var x int
		even := 0
		odd := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &x)
			if x%2 != j%2 {
				if x%2 == 0 {
					even++
				} else {
					odd++
				}
			}
		}

		if even != odd {
			fmt.Fprintln(out, -1)
			continue
		}

		fmt.Fprintln(out, even)
	}

	out.Flush()
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	for tt := NextInt(); tt > 0; tt-- {
		n := NextInt()
		foo, bar := 0, 0
		for i := 0; i < n; i++ {
			if NextInt() % 2 != i % 2 {
				if i % 2 == 1 {
					foo++
				} else {
					bar++
				}
			}
		}
		if foo != bar {
			fmt.Println("-1")
		} else {
			fmt.Println(foo)
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ;t>=1; t-- {
		var n,ji,ou int
		fmt.Scan(&n)
		for i,x:=0,0;i<n;i++{
			fmt.Scan(&x)
			if ((i%2==0)&&(x%2==1)) {
			   ou++
			}else if ((i%2==1)&&(x%2==0)) {
				ji++
			}
		}
		if (ji==ou) {
			fmt.Printf("%d\n",ji)
		}else{
			fmt.Printf("-1\n")
		}

	}
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n int
    var data [45] int
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n)
        even, odd := 0, 0
        for i := 0; i < n; i++ {
            fmt.Fscan(in, &data[i])
            if i % 2 == 0 && data[i] % 2 == 1 {
                even++
            } else if i % 2 == 1 && data[i] % 2 == 0 {
                odd++
            }
        }
        if even == odd {
            fmt.Println(even)
        } else {
            fmt.Printf("-1\n")
        }
    }
}

package main

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

var (
	debug = false
	tests = 0
	reader io.Reader
)

func main() {
	input()
}

func process(array []int) {
	totalOdd := 0
	totalEven := 0

	for i, item := range array {
		if i % 2 == item % 2 {
			continue
		}

		if item % 2 == 0 {
			totalEven++
		} else {
			totalOdd++
		}
	}

	if totalEven != totalOdd {
		fmt.Println(-1)
		return
	}

	fmt.Println(totalEven)
}

func input() {
	if debug {
		var e error
		reader, e = os.Open("input.txt")
		if e != nil {
			fmt.Println("error", e.Error())
			return
		}
	} else {
		reader = os.Stdin
	}

	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	if scanner.Scan() {
		tests = parseInt(scanner.Text())
	}

	for ; tests > 0; tests-- {
		len := 0
		a := make([]int, 0)
		if scanner.Scan() {
			len = parseInt(scanner.Text())

			for ; len > 0; len-- {
				if scanner.Scan() {
					a = append(a, parseInt(scanner.Text()))
				}
			}

			process(a)
		}
	}
}

func parseInt(text string) int {
	result, _ := strconv.Atoi(text)
	return result
}

package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(val []int) int {
	retVal := 0
	numGood := 0
	numEven := 0
	numOdd := 0
	//fmt.Println(retVal)
	for x := 0; x < len(val); x++ {

		if x%2 != val[x]%2 {
			retVal++
			if val[x]%2 == 0 {
				numEven++
			} else {
				numOdd++
			}
		} else {
			numGood++
		}
	}
	if retVal%2 == 0 {
		if len(val)%2 == 1 {
			if numEven == numOdd {
				retVal /= 2
			} else {
				retVal = -1
			}
		} else {
			if numEven == numOdd {
				retVal /= 2
			} else {
				retVal = -1
			}
		}

	} else {
		retVal = -1
	}
	return retVal
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var num int
	//var ret string
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	num = fastGetInt(scanner.Bytes())
	for x := 0; x < num; x++ {
		scanner.Scan()
		arrLen := fastGetInt(scanner.Bytes())
		arr := make([]int, arrLen)
		for y := 0; y < arrLen; y++ {
			scanner.Scan()
			arr[y] = fastGetInt(scanner.Bytes())
		}
		fmt.Println(solution(arr))
	}
	//======================================================

	//==================== OUTPUT ==========================

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int
	var a [50]int
	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)

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

		}

		odd, even := 0, 0
		for i := 0; i < n; i += 2 {
			if a[i]%2 == 1 {
				even++
			}
		}

		for i := 1; i < n; i += 2 {
			if a[i]%2 == 0 {
				odd++
			}
		}

		if odd == even {
			fmt.Println(odd)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

// https://codeforces.com/problemset/problem/1367/B
// B. Even Array
// time limit per test
// 2 seconds
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// You are given an array a[0…n−1]
// of length n

// which consists of non-negative integers. Note that array indices start from zero.

// An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all i
// (0≤i≤n−1) the equality imod2=a[i]mod2 holds, where xmod2 is the remainder of dividing x

// by 2.

// For example, the arrays [0,5,2,1
// ] and [0,17,0,3] are good, and the array [2,4,6,7] is bad, because for i=1, the parities of i and a[i] are different: imod2=1mod2=1, but a[i]mod2=4mod2=0

// .

// In one move, you can take any two elements of the array and swap them (these elements are not necessarily adjacent).

// Find the minimum number of moves in which you can make the array a

// good, or say that this is not possible.
// Input

// The first line contains a single integer t
// (1≤t≤1000) — the number of test cases in the test. Then t

// test cases follow.

// Each test case starts with a line containing an integer n
// (1≤n≤40) — the length of the array a

// .

// The next line contains n
// integers a0,a1,…,an−1 (0≤ai≤1000

// ) — the initial array.
// Output

// For each test case, output a single integer — the minimum number of moves to make the given array a
// good, or -1 if this is not possible.

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

	var t int
	_, _ = fmt.Fscan(bufStdin, &t)

	for i := 0; i < t; i++ {
		var n int
		_, _ = fmt.Fscan(bufStdin, &n)

		as := make([]int, n)
		for i := range as {
			_, _ = fmt.Fscan(bufStdin, &as[i])
		}

		var badEvens, badOdds int
		for i, v := range as {
			if i%2 != v%2 {
				if i%2 == 0 {
					badEvens++
				} else {
					badOdds++
				}
			}
		}

		if badEvens != badOdds {
			_, _ = fmt.Fprintln(bufStdout, -1)
		} else {
			_, _ = fmt.Fprintln(bufStdout, badEvens)
		}
	}
}

package main

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

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t int
	fmt.Fscan(r, &t)
	for i := 0; i < t; i++ {
		var n, b, c int
		fmt.Fscan(r, &n)
		for j := 0; j < n; j++ {
			var a int
			fmt.Fscan(r, &a)
			if j%2 != a%2 {
				if j%2 == 0 {
					b++
				} else {
					c++
				}
			}
		}
		if b != c {
			 fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, b)
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

type test struct {
	a []int
}

const TEST_MAX_SIZE = 40

func calc_wrongs(a []int) (wrong_even, wrong_odd int) {
	// even == четные
	// odd  == нечетные
	for i := 0; i < len(a)/2; i += 1 {
		if a[2*i]%2 != 0 {
			wrong_even += 1
		}
		if a[2*i+1]%2 == 0 {
			wrong_odd += 1
		}
	}

	if len(a)%2 != 0 && a[len(a)-1]%2 != 0 {
		wrong_even += 1
	}
	return wrong_even, wrong_odd
}

// https://codeforces.com/problemset/problem/1367/B
// комментарий к решению
// Т.к. от нас не требуется выводить результирующий хороший массив,
// то достаточно считать кол-во элементов требующих перестановки
// на четных и нечетных местах
func taskSolution(in []test) string {
	ans := make([]int, len(in))
	for i, t := range in {
		wrong_even, wrong_odd := calc_wrongs(t.a)
		if wrong_even != wrong_odd {
			ans[i] = -1
		} else {
			ans[i] = wrong_even
		}
	}
	res := fmt.Sprint(ans)
	return strings.Replace(res[1:len(res)-1], " ", "\n", len(ans)-1)
}

func main() {
	var t int
	if _, err := fmt.Scan(&t); err != nil {
		panic(err)
	}

	in := make([]test, 0, t)
	for i := 0; i < t; i += 1 {
		var n, ai int
		a := make([]int, 0, TEST_MAX_SIZE)
		if _, err := fmt.Scan(&n); err != nil {
			panic(err)
		}
		for j := 0; j < n; j += 1 {
			if _, err := fmt.Scan(&ai); err != nil {
				panic(err)
			}
			a = append(a, ai)
		}
		in = append(in, test{a})
	}

	fmt.Println(taskSolution(in))
}

package main

import (
  "fmt"
)

var t int
func main() {
  fmt.Scan(&t)
  for i := 0; i < t; i++ {
    var n int
    fmt.Scan(&n)
    even := 0
    odd := 0
    for j := 0; j < n; j++ {
      var a int
      fmt.Scan(&a)
      if j % 2 == 1 {
        if a % 2 != 1 {
          odd++
        }
      } else {
        if a % 2 != 0 {
	        even++
        }
      }
    }
    if even == odd {
      fmt.Println(even)
    } else {
      fmt.Println(-1)
    }
  }
}

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

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

package main

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

func main() {
	var t, n, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		c1 := 0
		c2 := 0
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if j%2 != a%2 {
				if j%2 == 1 {
					c1++
				} else {
					c2++
				}
			}
		}
		if c1 == c2 {
			fmt.Println(c1)
		} else {
			fmt.Println(-1)
		}
	}

}

package main

import (
  "fmt"
)

var t int
func main() {
  fmt.Scan(&t)
  for i := 0; i < t; i++ {
    var n int
    fmt.Scan(&n)
    even := 0
    odd := 0
    for j := 0; j < n; j++ {
      var a int
      fmt.Scan(&a)
      if j % 2 == 1 {
        if a % 2 != 1 {
          odd++
        }
      } else {
        if a % 2 != 0 {
	        even++
        }
      }
    }
    if (even+odd) % 2 == 0 {
      fmt.Println((even+odd)/2 + abs(even-odd)/2)
    } else {
      fmt.Println(-1)
    }
  }
}

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

package main

import (
  "fmt"
)

var t int
func main() {
  fmt.Scan(&t)
  for i := 0; i < t; i++ {
    var n int
    fmt.Scan(&n)
    even := 0
    odd := 0
    for j := 0; j < n; j++ {
      var a int
      fmt.Scan(&a)
      if j % 2 == 1 {
        if a % 2 != 1 {
          odd++
        }
      } else {
        if a % 2 != 0 {
	        even++
        }
      }
    }
    if (even+odd) % 2 == 0 {
      fmt.Println(min(even, odd) + abs(even-odd)/2)
    } else {
      fmt.Println(-1)
    }
  }
}

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

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

package main

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

func main() {
	var t, n, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		c1 := 0
		c2 := 0
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if j%2 != a%2 {
				if j%2 == 1 {
					c1++
				} else {
					c2++
				}
			}
		}
		if c1 == c2 {
			fmt.Println(c1 / 2)
		} else {
			fmt.Println(-1)
		}
	}

}

package main

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

func main() {
	var t, n, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		count := 0
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if j%2 != a%2 {
				count++
			}
		}
		if count%2 == 0 {
			fmt.Println(count / 2)
		} else {
			fmt.Println(-1)
		}
	}

}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scanf("%d\n", &n)
        a := make([]int,40)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scanf("%d", &a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        fmt.Printf("%d\n",n)
//         if s0 != s1 {
//             fmt.Println("-1")
//         } else {
//             fmt.Printf("%d\n",s0)
//         }
    }
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scanf("%d\n", &n)
        var a [40]int
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scanf("%d", &a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        if s0 != s1 {
            fmt.Println("-1")
        } else {
            fmt.Printf("%d\n",s0)
        }
    }
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\r\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scan(&n)
        a := make([]int,40)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scan(&a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        fmt.Printf("%d\n",n)
//         if s0 != s1 {
//             fmt.Println("-1")
//         } else {
//             fmt.Printf("%d\n",s0)
//         }
    }
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scanf("%d\n", &n)
        a := make([]int,n)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scanf("%d", &a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        if s0 != s1 {
            fmt.Println("-1")
        } else {
            fmt.Printf("%d\n",s0)
        }
    }
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scanf("%d\n", &n)
        a := make([]int,40)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scanf("%d", &a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        if s0 != s1 {
            fmt.Println("-1")
        } else {
            fmt.Printf("%d\n",s0)
        }
    }
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\r\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scanf("%d\r\n", &n)
        a := make([]int,40)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scanf("%d", &a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        fmt.Printf("%d\n",n)
//         if s0 != s1 {
//             fmt.Println("-1")
//         } else {
//             fmt.Printf("%d\n",s0)
//         }
    }
}

package main

import "fmt"

func main() {
    var CASE int
    fmt.Scanf("%d\n",&CASE)
    for K := 0;K < CASE;K++ {
        var n int
        fmt.Scanf("%d", &n)
        a := make([]int,40)
        s0 := 0
        s1 := 0
        for i := 0;i < n;i++ {
            fmt.Scanf("%d", &a[i])
            if i % 2 == 0 && a[i] % 2 != 0 {
                s0++
            } else if i % 2 == 1 && a[i] % 2 != 1 {
                s1++
            }
        }
        fmt.Printf("%d\n",n)
//         if s0 != s1 {
//             fmt.Println("-1")
//         } else {
//             fmt.Printf("%d\n",s0)
//         }
    }
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.ParseInt(string(line), 10, 64)
		line = readLine(reader)
		ans := strings.Split(string(line), " ")
		wpos := 0
		for i := int64(0); i < n; i++ {
			ai, _ := strconv.ParseInt(ans[i], 10, 64)
			if ai % 2 != i % 2 {
				wpos++
			}
		}
		if wpos % 2 == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(wpos / 2)
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(val []int) int {
	retVal := 0
	//fmt.Println(retVal)
	for x := 0; x < len(val); x++ {
		if x%2 != val[x]%2 {
			retVal++
		}
	}
	if retVal%2 == 0 {
		retVal /= 2
	} else {
		retVal = -1
	}
	return retVal
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var num int
	//var ret string
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	num = fastGetInt(scanner.Bytes())
	for x := 0; x < num; x++ {
		scanner.Scan()
		arrLen := fastGetInt(scanner.Bytes())
		arr := make([]int, arrLen)
		for y := 0; y < arrLen; y++ {
			scanner.Scan()
			arr[y] = fastGetInt(scanner.Bytes())
		}
		fmt.Println(solution(arr))
	}
	//======================================================

	//==================== OUTPUT ==========================

}

package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(val []int) int {
	retVal := 0
	numGood := 0
	numEven := 0
	numOdd := 0
	//fmt.Println(retVal)
	for x := 0; x < len(val); x++ {
		if val[x]%2 == 0 {
			numEven++
		} else {
			numOdd++
		}
		if x%2 != val[x]%2 {
			retVal++
		} else {
			numGood++
		}
	}
	if retVal%2 == 0 {
		if len(val)%2 == 1 {
			if numEven >= numOdd {
				retVal /= 2
			}
		} else {
			if numEven <= numOdd {
				retVal /= 2
			}
		}

	} else {
		retVal = -1
	}
	return retVal
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var num int
	//var ret string
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	num = fastGetInt(scanner.Bytes())
	for x := 0; x < num; x++ {
		scanner.Scan()
		arrLen := fastGetInt(scanner.Bytes())
		arr := make([]int, arrLen)
		for y := 0; y < arrLen; y++ {
			scanner.Scan()
			arr[y] = fastGetInt(scanner.Bytes())
		}
		fmt.Println(solution(arr))
	}
	//======================================================

	//==================== OUTPUT ==========================

}

package main

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

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t int
	fmt.Fscan(r, &t)
	for i := 0; i < t; i++ {
		var n, b int
		fmt.Fscan(r, &n)
		for j := 0; j < n; j++ {
			var a int
			fmt.Fscan(r, &a)
			if j%2 != a%2 {
				b++
			}
		}
		if b%2 != 0 {
			 fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, b/2)
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

type test struct {
	a []int
}

const TEST_MAX_SIZE = 40

func calc_wrongs(a []int) (wrong_even, wrong_odd int) {
	// even == четные
	// odd  == нечетные
	for i := 0; i < len(a)/2; i += 1 {
		if a[2*i]%2 != 0 {
			wrong_even += 1
		}
		if a[2*i+1]%2 == 0 {
			wrong_odd += 1
		}
	}

	if len(a)%2 > 0 && a[len(a)-1]%2 != 0 {
		wrong_odd += 1
	}
	return wrong_even, wrong_odd
}

// https://codeforces.com/problemset/problem/1367/B
// комментарий к решению
// Т.к. от нас не требуется выводить результирующий хороший массив,
// то достаточно считать кол-во элементов требующих перестановки
// на четных и нечетных местах
func taskSolution(in []test) string {
	ans := make([]int, len(in))
	for i, t := range in {
		wrong_even, wrong_odd := calc_wrongs(t.a)
		if wrong_even != wrong_odd {
			ans[i] = -1
		} else {
			ans[i] = wrong_even
		}
	}
	res := fmt.Sprint(ans)
	return strings.Replace(res[1:len(res)-1], " ", "\n", len(ans)-1)
}

func main() {
	var t int
	if _, err := fmt.Scan(&t); err != nil {
		panic(err)
	}

	in := make([]test, 0, t)
	for i := 0; i < t; i += 1 {
		var n, ai int
		a := make([]int, 0, TEST_MAX_SIZE)
		if _, err := fmt.Scan(&n); err != nil {
			panic(err)
		}
		for j := 0; j < n; j += 1 {
			if _, err := fmt.Scan(&ai); err != nil {
				panic(err)
			}
			a = append(a, ai)
		}
		in = append(in, test{a})
	}

	fmt.Println(taskSolution(in))
}


package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

var err error

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("d.in")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	n := nextInt()
	adj := make([][]int, n)
	for i := range adj {
		adj[i] = []int{}
	}

	for i := 1; i < n; i++ {
		u, v := nextInt()-1, nextInt()-1
		adj[u] = append(adj[u], v)
		adj[v] = append(adj[v], u)
	}

	color := make([]int, n)
	for i := range color {
		color[i] = -1
	}
	color[0] = 0
	num := [2]int{0, 0}
	queue := []int{0}
	for len(queue) > 0 {
		curr := queue[0]
		queue = queue[1:]
		num[color[curr]]++
		for _, v := range adj[curr] {
			if color[v] == -1 {
				color[v] = color[curr] ^ 1
				queue = append(queue, v)
			}
		}
	}

	if num[0] < num[1] {
		printf("%d\n", num[0]-1)
	} else {
		printf("%d\n", num[1]-1)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	E := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		E[i] = readNNums(reader, 2)
	}
	fmt.Println(solve(n, E))
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, edges [][]int) int {
	if n <= 3 {
		return 0
	}
	G := getGraph(n, edges)
	cnt := make([]int, 2)
	var dfs func(p, u, h int)

	dfs = func(p, u, h int) {
		cnt[h]++
		for _, v := range G[u] {
			if p == v {
				continue
			}
			dfs(u, v, 1-h)
		}
	}

	dfs(-1, 0, 0)

	return min(cnt[0], cnt[1]) - 1
}

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

func getGraph(n int, E [][]int) [][]int {
	degree := make([]int, n)
	for _, e := range E {
		u, v := e[0]-1, e[1]-1
		degree[u]++
		degree[v]++
	}
	adj := make([][]int, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]int, 0, degree[i])
	}

	for _, e := range E {
		u, v := e[0]-1, e[1]-1
		adj[u] = append(adj[u], v)
		adj[v] = append(adj[v], u)
	}

	return adj
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s []byte
		fmt.Scan(&s)
		var pre byte
		l := len(s)
		flag := true
		for index, val := range s {
			if index == 0 {
				if val == '?' {
					if l > 1 {
						s[index] = (s[index+1]+1)%3 + 97
					} else {
						s[index] = 97
					}
				}
				pre = s[0]
				continue
			}
			if val == pre {
				fmt.Println(-1)
				flag = false
				break
			}
			if val == '?' {
				if index+1 < l && s[index+1] != '?' && s[index+1] != pre {
					a := 3*97 + 3 - uint32(pre) - uint32(s[index+1])
					s[index] = byte(a)
				} else {
					s[index] = byte((pre-96)%3 + 97)
				}
			}
			pre = s[index]
		}
		if flag {
			fmt.Println(string(s))
		}
	}
}

package main

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

func main() {
	var n, res int
	var s string
	ocr := bufio.NewReader(os.Stdin)
	// scr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(ocr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(ocr, &s)

		for u, v := range s {
			if u >= 1 && u < len(s)-1 {
				if (v == rune(s[u-1]) || v == rune(s[u+1])) && string(v) != "?" {
					res = 5
					break
				}
			}
		}

		res1 := make([]rune, 0)

		if res != 5 {
			for u, v := range s {
				if string(v) == "?" {
					m := make(map[string]bool)
					m["a"] = true
					m["b"] = true
					m["c"] = true

					if u >= 1 {
						m[string(res1[u-1])] = false
					}
					if u < len(s)-1 {
						m[string(s[u+1])] = false
					}

					for x, y := range m {
						if y == true {
							r := []rune(x)
							res1 = append(res1, r[0])
							break
						}
					}
				} else {
					res1 = append(res1, v)
				}
			}
		}

		if res == 5 {
			fmt.Println(-1)
		} else {
			fmt.Println(string(res1))
		}

		res = 0
	}

}

package main

import (
	"fmt"
)

func getTempMap() map[rune]rune {
	tempMap := make(map[rune]rune)
	tempMap['a'] = 'a'
	tempMap['b'] = 'b'
	tempMap['c'] = 'c'

	return tempMap
}

func getRune(tempMap map[rune]rune) rune {
	_, ok := tempMap['a']
	if ok {
		return 'a'
	}

	_, ok = tempMap['b']
	if ok {
		return 'b'
	}

	_, ok = tempMap['c']
	if ok {
		return 'c'
	}

	return '?'
}

func solve(str string) string {
	runes := []rune(str)
	for i, temprune := range runes {
		switch temprune {
		case 'a', 'b', 'c':
			if i != 0 {
				if runes[i] == runes[i-1] {
					return "-1"
				}
			}
		case '?':
			tempMap := getTempMap()
			if i == 0 && len(str) == 1 {
				runes[i] = 'a'
			}else if i == 0 {
				_, ok := tempMap[runes[i+1]]
				if ok {
					delete(tempMap, runes[i+1])
				}

				runes[i] = getRune(tempMap)
			}else if i == len(str) - 1 {
				_, ok := tempMap[runes[i-1]]
				if ok {
					delete(tempMap, runes[i-1])
				}

				runes[i] = getRune(tempMap)
			}else {
				_, ok := tempMap[runes[i-1]]
				if ok {
					delete(tempMap, runes[i-1])
				}

				_, ok = tempMap[runes[i+1]]
				if ok {
					delete(tempMap, runes[i+1])
				}

				runes[i] = getRune(tempMap)
			}
		}
	}

	return string(runes)
}

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

	var strs []string = []string{}
	for i:=0; i<n; i++ {
		var str string
		fmt.Scan(&str)
		strs = append(strs, str)
	}

	for _, str := range strs {
		fmt.Println(solve(str))
	}
}

package main

import "fmt"

func f(s string) string {
	if len(s) == 1 {
		if s == "?" {
			return "a"
		}
		return s
	}
	// len >= 2
	ret := ""
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "?" {
			if i == 0 {
				if string(s[i + 1]) == "?" {
					ret += "a"
				} else {
					ret += string((s[i + 1] + 1 - "a"[0]) % 3 + "a"[0])
				}
			} else if i == len(s) - 1 {
				ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
			} else {
				if string(s[i + 1]) == "?" {
					ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
				} else {
					if "a" != string(s[i + 1]) && "a" != string(ret[i - 1]) {
						ret += "a"
					} else if "b" != string(s[i + 1]) && "b" != string(ret[i - 1]) {
						ret += "b"
					} else {
						ret += "c"
					}
				}
			}
		} else {
			ret += string(s[i])
		}
		if i > 0 && ret[i] == ret[i - 1] {
			return "-1"
		}
	}
	return ret
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		fmt.Println(f(s))
	}
}

package main

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

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var S []rune

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		S = ReadRuneSlice()

		solve()
	}
}

func solve() {
	// 1文字のケース
	if len(S) == 1 && S[0] != '?' {
		fmt.Println(string(S))
		return
	}
	if len(S) == 1 && S[0] == '?' {
		fmt.Println("a")
		return
	}

	// 以降は2文字以上

	// 可能かどうか
	pressed, nums := RunLengthEncoding(S)
	for i := 0; i < len(pressed); i++ {
		r := pressed[i]
		cnt := nums[i]

		if r != '?' && cnt > 1 {
			fmt.Println(-1)
			return
		}
	}

	for i := 0; i < len(S); i++ {
		// 決まっていたらパス
		if S[i] != '?' {
			continue
		}

		if i == 0 {
			// 次を見る
			next := S[i+1]
			S[i] = sub(next)
		} else if i == len(S)-1 {
			// 前を見る
			before := S[i-1]
			S[i] = sub(before)
		} else {
			// 前後を見る
			next, before := S[i+1], S[i-1]
			S[i] = subsub(next, before)
		}
	}

	fmt.Println(string(S))
}

// rはa, b, c, ?のいずれかで、r以外のa, b, cのいずれかを返す
// ?だったらaを返す
func sub(r rune) rune {
	if r == 'a' {
		return 'b'
	} else if r == 'b' {
		return 'c'
	} else if r == 'c' {
		return 'a'
	} else {
		return 'a'
	}
}

func subsub(r, s rune) rune {
	memo := make(map[rune]bool)
	memo[r] = true
	memo[s] = true

	isA := memo['a']
	isB := memo['b']
	isC := memo['c']

	if !isA {
		return 'a'
	} else if !isB {
		return 'b'
	} else if !isC {
		return 'c'
	}

	return 'a'
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []rune) ([]rune, []int) {
	runes := []rune{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []rune, L []int) []rune {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []rune{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

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

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

	defer writer.Flush()
	var nt int
	var s string

	fmt.Fscanf(reader, "%d\n", &nt)
	for t:=0; t < nt; t++ {
		fmt.Fscanf(reader, "%s\n", &s)
		var n = len(s)

		var results = make([] int, n)

		var could = true
		for i:=0; i < n; i++ {

			if i < n - 1 && s[i] != '?' && s[i + 1] == s[i] {
				could = false
				break
			}

			if s[i] == '?' {
				var tryValue = 0

				var ex1 = 0
				var ex2 = 0

				if i > 0 {
					ex1 = results[i - 1]
				}

				if i < n - 1 && s[i + 1] != '?' {
					ex2 = (int)(s[i + 1] - 'a')
				}

				for tryValue == ex1 || tryValue == ex2 {
					tryValue = (tryValue + 1) % 3
				}

				results[i] = tryValue
			} else {
				results[i] = (int)(s[i] - 'a')
			}
		}
		if !could {
			fmt.Fprintf(writer, "-1\n")
			continue
		}

		for i := 0; i < n; i++ {
			fmt.Fprintf(writer, "%c", results[i] + 'a')
		}
		fmt.Fprintf(writer, "\n")
	}
}

package main

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

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 gcd(a,b int)int{
	if b==0{
		return a
	}
	return gcd(b,a%b)
}

var s []byte

func ok(ind int, ch byte)bool{
	if(ind!=0&&s[ind-1]==ch){
		return false
	};
	if(ind!=len(s)-1&&s[ind+1]==ch){
		return false
	}
	return true
}

func main(){
	defer writer.Flush()
	var T int
	scanf("%d\n",&T)
	for cas:=1;cas<=T;cas++{
		scanf("%s\n",&s)
		boom:=false
		for i:=1;i<len(s);i++{
			if s[i]!='?' && s[i]==s[i-1]{
				boom=true;
				break
			}
		}
		if boom{
			printf("-1\n")
		}else{
			if len(s)!=1 {
				for i := 0; i < len(s); i++ {
					if s[i] == '?' {
						for ch:=byte('a');ch<='c';ch++{
							if(ok(i,ch)){
								s[i]=byte(ch)
								break
							}
						}
					}
				}
			}else{
				if s[0]=='?'{
					s[0]='a'
				}
			}
			printf("%s\n",s)
		}
	}
}

package main

import (
	"fmt"
)

func _1265A() {

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var s []byte
		fmt.Scan(&s)
		l := len(s)
		ok := true
		for k, c := range s {

			if c != '?' && k < l-1 && (c == s[k+1]) {
				ok = false
				break
			}

			if c == '?' {
				var ch = map[byte]struct{}{
					'a': struct{}{},
					'b': struct{}{},
					'c': struct{}{},
				}

				if k == 0 {
					switch l {
					case 1:
						c = 'a'
					default:
						delete(ch, s[k+1])
					}
				}

				if k > 0 && k < l-1 {
					delete(ch, s[k-1])
					delete(ch, s[k+1])
				}

				if k > 0 && k == l-1 {
					delete(ch, s[k-1])
				}

				for k := range ch {
					c = k
					break
				}

				s[k] = c

			}

		}
		if ok {
			fmt.Println(string(s))
		} else {
			fmt.Println(-1)
		}
	}
}

func main() {

	_1265A()
}

package main
import (
	"bufio"
	"fmt"
	"os"
)
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(r, &s)
		b := []byte(s)
		flag := false
		for i, c := range b {
			if i != 0 &&  b[i-1] == c{
				flag = true
				break
			}
			if c == '?' && i > 0 && i < len(b) - 1 {
				if b[i+1] == '?' {
					b[i] = rotABC(b[i-1])
				} else {
					b[i] = rotABC(b[i-1])
					for b[i] == b[i-1] || b[i] == b[i+1] {
						b[i] = rotABC(b[i])
					}
				}
			} else if c == '?' && i == 0 {
				if len(b) == 1 {
					b[0] = 'a'
				} else {
					b[0] = rotABC(b[1])
				}
			} else if c == '?' && i == len(b) - 1 {
				b[i] = rotABC(b[i-1])
			}

		}
		if flag {
			fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, string(b))
		}
	}
}

func rotABC(b byte) byte{
	return byte((b - 'a' + 1)%3 + 'a')
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)

	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		ls := len(s)
		newS := ""
		for j := 0; j < ls; j++ {
			if s[j] == '?' {
				if j-1 >= 0 && j+1 < ls {
					l := newS[j-1]
					r := s[j+1]
					if 'a' != l && 'a' != r {
						newS += "a"
					} else if 'b' != l && 'b' != r {
						newS += "b"
					} else if 'c' != l && 'c' != r {
						newS += "c"
					}
				} else if j-1 >= 0 {
					l := newS[j-1]
					if 'a' != l {
						newS += "a"
					} else if 'b' != l {
						newS += "b"
					} else if 'c' != l {
						newS += "c"
					}
				} else if j+1 < ls {
					r := s[j+1]
					if 'a' != r {
						newS += "a"
					} else if 'b' != r {
						newS += "b"
					} else if 'c' != r {
						newS += "c"
					}
				} else {
					newS += "a"
				}
			} else {
				newS += string(s[j])
				if j-1 >= 0 && j+1 < ls {
					if s[j] == s[j-1] || s[j] == s[j+1] {
						fmt.Println(-1)
						break
					}
				} else if j-1 >= 0 {
					if s[j] == s[j-1] {
						fmt.Println(-1)
						break
					}
				} else if j+1 < ls {
					if s[j] == s[j+1] {
						fmt.Println(-1)
						break
					}
				}
			}
		}
		if len(newS) == len(s) {
			fmt.Println(newS)
		}
	}
}

package main

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

func main() {
	var n, res int
	var s string
	ocr := bufio.NewReader(os.Stdin)
	// scr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(ocr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(ocr, &s)

		for u, v := range s {
			if u >= 1 && u < len(s)-1 {
				if (v == rune(s[u-1]) || v == rune(s[u+1])) && string(v) != "?" {
					res = 5
					break
				}
			}
		}

		res1 := make([]rune, 0)

		if res != 5 {
			for u, v := range s {
				if string(v) == "?" {
					m := make(map[string]bool)
					m["a"] = true
					m["b"] = true
					m["c"] = true

					if u > 1 {
						m[string(res1[u-1])] = false
					} else if u < len(s)-1 {
						m[string(s[u+1])] = false
					}

					for x, y := range m {
						if y == true {
							r := []rune(x)
							res1 = append(res1, r[0])
							break
						}
					}
				} else {
					res1 = append(res1, v)
				}
			}
		}

		if res == 5 {
			fmt.Println(-1)
		} else {
			fmt.Println(string(res1))
		}

		res = 0
	}

}

package main

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

func main() {
	var n, res int
	var s string
	ocr := bufio.NewReader(os.Stdin)
	// scr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(ocr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(ocr, &s)

		for u, v := range s {
			if u >= 1 && u < len(s)-1 {
				if (v == rune(s[u-1]) || v == rune(s[u+1])) && string(v) != "?" {
					res = 5
					break
				}
			}
		}

		res1 := make([]rune, 0)

		if res != 5 {
			for u, v := range s {
				if string(v) == "?" {
					m := make(map[string]bool)
					m["a"] = true
					m["b"] = true
					m["c"] = true

					if u >= 1 {
						m[string(res1[u-1])] = false
					}
					if u < len(s)-1 {
						m[string(s[u+1])] = false
					}
					fmt.Println(m)

					for x, y := range m {
						if y == true {
							r := []rune(x)
							res1 = append(res1, r[0])
							break
						}
					}
				} else {
					res1 = append(res1, v)
				}
			}
		}

		if res == 5 {
			fmt.Println(-1)
		} else {
			fmt.Println(string(res1))
		}

		res = 0
	}

}

package main

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

func main() {
	var n, res int
	var s string
	ocr := bufio.NewReader(os.Stdin)
	// scr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(ocr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(ocr, &s)

		for u, v := range s {
			if u >= 1 && u < len(s)-1 {
				if (v == rune(s[u-1]) || v == rune(s[u+1])) && string(v) != "?" {
					res = 5
					break
				}
			}
		}

		res1 := make([]rune, 0)

		if res != 5 {
			for u, v := range s {
				if string(v) == "?" {
					m := make(map[string]bool)
					m["a"] = true
					m["b"] = true
					m["c"] = true

					if u >= 1 {
						m[string(res1[u-1])] = false
					} else if u < len(s)-1 {
						m[string(s[u+1])] = false
					}

					for x, y := range m {
						if y == true {
							r := []rune(x)
							res1 = append(res1, r[0])
							break
						}
					}
				} else {
					res1 = append(res1, v)
				}
			}
		}

		if res == 5 {
			fmt.Println(-1)
		} else {
			fmt.Println(string(res1))
		}

		res = 0
	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s []byte
		fmt.Scan(&s)
		pre := s[0]
		l := len(s)
		flag := true
		for index, val := range s {
			if index == 0 {
				if val == '?' && l > 1 {
					s[index] = (s[index+1] + 1)%3 + 97
				} else {
					s[index] = 97
				}

				continue
			}
			if val == pre {
				fmt.Println(-1)
				flag = false
				break
			}
			if val == '?' {
				if index+1 < l && s[index+1] != '?' && s[index+1] != pre {
					a := 3*97 + 3 - uint32(pre) - uint32(s[index+1])
					s[index] = byte(a)
				} else {
					s[index] = byte((pre-96)%3 + 97)
				}
			}
			pre = s[index]
		}
		if flag {
			fmt.Println(string(s))
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s []byte
		fmt.Scan(&s)
		pre := s[0]
		l := len(s)
		flag := true
		for index, val := range s {
			if index == 0 {
				continue
			}
			if val == pre {
				fmt.Println(-1)
				flag = false
				break
			}
			if val == '?' {
				if index+1 < l && s[index+1] != '?' && s[index+1] != pre {
					a := 3*97 + 3 - uint32(pre) - uint32(s[index+1])
					s[index] = byte(a)
				} else {
					s[index] = byte((pre-96)%3 + 97)
				}
			}
			pre = s[index]
		}
		if flag {
			fmt.Println(string(s))
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s []byte
		fmt.Scan(&s)
		var pre byte
		l := len(s)
		flag := true
		for index, val := range s {
			if index == 0 {
				if val == '?' && l > 1 {
					s[index] = (s[index+1]+1)%3 + 97
				} else {
					s[index] = 97
				}
				pre = s[0]
				continue
			}
			if val == pre {
				fmt.Println(-1)
				flag = false
				break
			}
			if val == '?' {
				if index+1 < l && s[index+1] != '?' && s[index+1] != pre {
					a := 3*97 + 3 - uint32(pre) - uint32(s[index+1])
					s[index] = byte(a)
				} else {
					s[index] = byte((pre-96)%3 + 97)
				}
			}
			pre = s[index]
		}
		if flag {
			fmt.Println(string(s))
		}
	}
}

package main

import "fmt"

func f(s string) string {
	if len(s) == 1 {
		if s == "?" {
			return "a"
		}
		return s
	}
	// len >= 2
	ret := ""
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "?" {
			if i == 0 {
				if string(s[i + 1]) == "?" {
					ret += "a"
				} else {
					ret += string((s[i + 1] + 1 - "a"[0]) % 3 + "a"[0])
				}
			} else if i == len(s) - 1 {
				ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
			} else {
				if string(s[i + 1]) == "?" {
					ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
				} else {
					if "a" != string(s[i + 1]) && "a" != string(ret[i - 1]) {
						ret += "a"
					} else if "b" != string(s[i + 1]) && "b" != string(ret[i - 1]) {
						ret += "b"
					} else {
						ret += "c"
					}
				}
			}
		} else {
			ret += string(s[i])
		}
		if i > 0 && ret[i] == ret[i - 1] {
			return "-1"
		}
	}
	return ret
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Scanf("%s", &s)
		fmt.Println(s)
	}
}

package main

import "fmt"

func f(s string) string {
	if len(s) == 1 {
		if s == "?" {
			return "a"
		}
		return s
	}
	// len >= 2
	ret := ""
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "?" {
			if i == 0 {
				if string(s[i + 1]) == "?" {
					ret += "a"
				} else {
					ret += string((s[i + 1] + 1 - "a"[0]) % 3 + "a"[0])
				}
			} else if i == len(s) - 1 {
				ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
			} else {
				if string(s[i + 1]) == "?" {
					ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
				} else {
					if "a" != string(s[i + 1]) && "a" != string(ret[i - 1]) {
						ret += "a"
					} else if "b" != string(s[i + 1]) && "b" != string(ret[i - 1]) {
						ret += "b"
					} else {
						ret += "c"
					}
				}
			}
		} else {
			ret += string(s[i])
		}
		if i > 0 && ret[i] == ret[i - 1] {
			return "-1"
		}
	}
	return ret
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Scanf("%s", &s)
		ret := f(s)
		fmt.Println(ret)
	}
}

package main

import "fmt"

func f(s string) string {
	if len(s) == 1 {
		if s == "?" {
			return "a"
		}
		return s
	}
	// len >= 2
	ret := ""
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "?" {
			if i == 0 {
				if string(s[i + 1]) == "?" {
					ret += "a"
				} else {
					ret += string((s[i + 1] + 1 - "a"[0]) % 3 + "a"[0])
				}
			} else if i == len(s) - 1 {
				ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
			} else {
				if string(s[i + 1]) == "?" {
					ret += string((ret[i - 1] + 1 - "a"[0]) % 3 + "a"[0])
				} else {
					if "a" != string(s[i + 1]) && "a" != string(ret[i - 1]) {
						ret += "a"
					} else if "b" != string(s[i + 1]) && "b" != string(ret[i - 1]) {
						ret += "b"
					} else {
						ret += "c"
					}
				}
			}
		} else {
			ret += string(s[i])
		}
		if i > 0 && ret[i] == ret[i - 1] {
			return "-1"
		}
	}
	return ret
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	var ret []string
	for i := 0; i < t; i++ {
		var s string
		fmt.Scanf("%s", &s)
		ret = append(ret, f(s))
	}
	for _, s := range ret {
		fmt.Println(s)
	}
}

package main

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

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

	defer writer.Flush()
	var nt int
	var s string

	fmt.Fscanf(reader, "%d\n", &nt)
	for t:=0; t < nt; t++ {
		fmt.Fscanf(reader, "%s\n", &s)
		var n = len(s)

		var results = make([] int, n)

		var could = true
		for i:=0; i < n; i++ {

			if i < n - 1 && s[i] != '?' && s[i + 1] == s[i] {
				could = false
				break
			}

			if s[i] == '?' {
				var tryValue = 0

				var ex1 = 0
				var ex2 = 0

				if i > 0 {
					ex1 = results[i - 1]
				}

				if i < n - 1 && s[i + 1] != '?' {
					ex2 = (int)(s[i + 1] - 'a')
				}

				for tryValue == ex1 || tryValue == ex2 {
					tryValue = (tryValue + 1) % 3
				}

				results[i] = tryValue
			} else {
				results[i] = (int)(s[i] - 'a')
			}
		}
		if !could {
			fmt.Fprintf(writer, "-1\n")
			continue
		}

		for i := 0; i < n; i++ {
			fmt.Fprintf(writer, "%c", results[i] + 'a')
		}
	}
}

package main

import (
	"fmt"
)

func _1265A() {

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var s []byte
		fmt.Scan(&s)
		l := len(s)
		ok := true
		for k, c := range s {

			// '?' sequences can't invalidate a string
			// string can only be given in an invalid state
			// with two preexisting identical consecutive characters
			if c != '?' && k < l-1 && (c == s[k+1]) {
				ok = false
				break
			}

			if c == '?' {
				// Candidates for '?'
				var ch = map[byte]struct{}{
					'a': struct{}{},
					'b': struct{}{},
					'c': struct{}{},
				}

				// '?' first character - check only next character or set 'a' if len = 1
				if k == 0 {
					switch l {
					case 1:
						fmt.Println("a")
					default:
						delete(ch, s[k+1])
					}
				}

				// '?' neither last nor first character
				// check both neigbors, set c to whoever is available
				if k > 0 && k < l-1 {
					delete(ch, s[k-1])
					delete(ch, s[k+1])
				}

				if k > 0 && k == l-1 {
					delete(ch, s[k-1])
				}

				for k := range ch {
					c = k
					break
				}

				s[k] = c

			}

		}
		if ok {
			fmt.Println(string(s))
		} else {
			fmt.Println(-1)
		}
	}
}

func main() {

	_1265A()
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s", &s)
		ls := len(s)
		newS := ""
		for j := 0; j < ls; j++ {
			if s[j] == '?' {
				if j-1 >= 0 && j+1 < ls {
					l := newS[j-1]
					r := s[j+1]
					if 'a' != l && 'a' != r {
						newS += "a"
					} else if 'b' != l && 'b' != r {
						newS += "b"
					} else if 'c' != l && 'c' != r {
						newS += "c"
					}
				} else if j-1 >= 0 {
					l := newS[j-1]
					if 'a' != l {
						newS += "a"
					} else if 'b' != l {
						newS += "b"
					} else if 'c' != l {
						newS += "c"
					}
				} else if j+1 < ls {
					r := s[j+1]
					if 'a' != r {
						newS += "a"
					} else if 'b' != r {
						newS += "b"
					} else if 'c' != r {
						newS += "c"
					}
				} else {
					newS += "a"
				}
			} else {
				newS += string(s[j])
				if j-1 >= 0 && j+1 < ls {
					if s[j] == s[j-1] || s[j] == s[j+1] {
						fmt.Println(-1)
						break
					}
				} else if j-1 >= 0 {
					if s[j] == s[j-1] {
						fmt.Println(-1)
						break
					}
				} else if j+1 < ls {
					if s[j] == s[j+1] {
						fmt.Println(-1)
						break
					}
				}
			}
		}
		if len(newS) == len(s) {
			fmt.Println(newS)
		}
	}
}


// 253B-mic
package main

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

func main() {
	var T []int
	in, _ := os.Open("input.txt")
	defer in.Close()
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)
	ou, _ := os.Create("output.txt")
	defer ou.Close()
	wr := bufio.NewWriter(ou)
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	n := a
	for i := 0; i < n; i++ {
		sc.Scan()
		aa, _ := strconv.Atoi(sc.Text())
		T = append(T, aa)
	}
	sort.Sort(sort.IntSlice(T))
	r := n - 1
	j := 0
	for i := 0; i < n; i++ {
		for j < n && T[j] <= 2*T[i] {
			j++
		}
		r = int(math.Min(float64(r), float64(n-(j-i))))
	}
	wr.WriteString(strconv.Itoa(r))
	wr.WriteString("\n")
	wr.Flush()
}

package main

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

var fi, _ = os.Open("input.txt")
var fo, _ = os.Create("output.txt")

var in = bufio.NewScanner(fi)
var out = bufio.NewWriter(fo)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	var n int = NextInt()
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = NextInt()
	}

	sort.Ints(a)
	var ret int = n
	for i := 0; i < n; i++ {
		var lo, hi int = i, n
		for hi - lo > 1 {
			var m int = lo + (hi - lo) / 2
			if a[m] > 2 * a[i] {
				hi = m
			}else {
				lo = m
			}
		}

		// fmt.Fprintln(out, i, hi)

		var lret int = i + n - hi
		if ret > lret {
			ret = lret
		}
	}
	fmt.Fprintln(out, ret)
}

func Max(x, y int) int {
	if x < y {
		return y
	}
	return x
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func Next() string{
	if !in.Scan() {
		panic("Scan error")
	}
	return in.Text()
}

func NextInt() int{
	ret, _ := strconv.Atoi(Next())
	return ret
}

package main

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

func main() {
    input, _ := os.Open("input.txt")
    defer input.Close()
    output, _ := os.Create("output.txt")
    defer output.Close()

    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(output)

    ScanInts := func(a... *int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }

    var n,a int
    var cnt [5001]int
    ScanInts(&n)
    min, max := 5000, 1
    for i := 0; i < n; i++ {
        ScanInts(&a)
        cnt[a]++
        if min > a { min = a }
        if max < a { max = a }
    }
    for i := 2; i <= 5000; i++ {
        cnt[i] += cnt[i-1]
    }
    ans := 1000000000
    for y := min; y <= max; y++ {
        x := (y-1)/2
        u := cnt[x]+(cnt[5000]-cnt[y])
        if ans > u { ans = u }
    }
    writer.WriteString(strconv.Itoa(ans)+"\n")
    writer.Flush()
}

package main

import "os"
import "bufio"
import "strconv"
import "sort"

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

func main(){
	var n int
	inp, _ := os.Open("input.txt")
	defer inp.Close()
	r := bufio.NewScanner(inp)
	r.Split(bufio.ScanWords)
	out, _ := os.Create("output.txt")
	defer out.Close()
	w := bufio.NewWriter(out)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	c := make([]int, n)
	for i:=0; i<n; i++ {
		r.Scan()
		c[i], _ = strconv.Atoi(r.Text())
	}
	sort.Ints(c)
	s, k := 0, 0
	for i:=0; i<n; i++ {
		for s < n && c[s] <= 2*c[i] {
			s += 1
		}
		k = max(k, s-i)
	}
	w.WriteString(strconv.Itoa(n-k)+"\n")
	w.Flush()
}

package main

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

func main() {
    var n int
    var cn [5555]int
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)
    scanner.Scan()
    aa, _ := strconv.Atoi(scanner.Text())
    n=aa
    for i:=0;i<n;i++ {
    	var x int
    	scanner.Scan()
    	bb, _ := strconv.Atoi(scanner.Text())
    	x=bb
    	cn[x]++
    }
    s:=0
    ans:=1<<30
    for i:=0;i<=2500;i++ {
    	s2:=0
    	for j:=2*i+1;j<=5000;j++ {
    		s2+=cn[j]
    	}
    	if (s+s2)<ans {
    		ans=s+s2
    	}
    	s+=cn[i]
    }
    writer.WriteString(strconv.Itoa(ans))
    writer.WriteString("\n")
    writer.Flush()
}