In the $$$2022$$$ year, Mike found two binary integers $$$a$$$ and $$$b$$$ of length $$$n$$$ (both of them are written only by digits $$$0$$$ and $$$1$$$) that can have leading zeroes. In order not to forget them, he wanted to construct integer $$$d$$$ in the following way:   he creates an integer $$$c$$$ as a result of bitwise summing of $$$a$$$ and $$$b$$$ without transferring carry, so $$$c$$$ may have one or more $$$2$$$-s. For example, the result of bitwise summing of $$$0110$$$ and $$$1101$$$ is $$$1211$$$ or the sum of $$$011000$$$ and $$$011000$$$ is $$$022000$$$;  after that Mike replaces equal consecutive digits in $$$c$$$ by one digit, thus getting $$$d$$$. In the cases above after this operation, $$$1211$$$ becomes $$$121$$$ and $$$022000$$$ becomes $$$020$$$ (so, $$$d$$$ won't have equal consecutive digits). Unfortunately, Mike lost integer $$$a$$$ before he could calculate $$$d$$$ himself. Now, to cheer him up, you want to find any binary integer $$$a$$$ of length $$$n$$$ such that $$$d$$$ will be maximum possible as integer.Maximum possible as integer means that $$$102 > 21$$$, $$$012 < 101$$$, $$$021 = 21$$$ and so on.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the length of $$$a$$$ and $$$b$$$. The second line of each test case contains binary integer $$$b$$$ of length $$$n$$$. The integer $$$b$$$ consists only of digits $$$0$$$ and $$$1$$$. It is guaranteed that the total sum of $$$n$$$ over all $$$t$$$ test cases doesn't exceed $$$10^5$$$.

For each test case output one binary integer $$$a$$$ of length $$$n$$$. Note, that $$$a$$$ or $$$b$$$ may have leading zeroes but must have the same length $$$n$$$.

NoteIn the first test case, $$$b = 0$$$ and choosing $$$a = 1$$$ gives $$$d = 1$$$ as a result.In the second test case, $$$b = 011$$$ so:   if you choose $$$a = 000$$$, $$$c$$$ will be equal to $$$011$$$, so $$$d = 01$$$;  if you choose $$$a = 111$$$, $$$c$$$ will be equal to $$$122$$$, so $$$d = 12$$$;  if you choose $$$a = 010$$$, you'll get $$$d = 021$$$.  If you select $$$a = 110$$$, you'll get $$$d = 121$$$.  We can show that answer $$$a = 110$$$ is optimal and $$$d = 121$$$ is maximum possible.In the third test case, $$$b = 110$$$. If you choose $$$a = 100$$$, you'll get $$$d = 210$$$ and it's the maximum possible $$$d$$$.In the fourth test case, $$$b = 111000$$$. If you choose $$$a = 101101$$$, you'll get $$$d = 212101$$$ and it's maximum possible $$$d$$$.In the fifth test case, $$$b = 001011$$$. If you choose $$$a = 101110$$$, you'll get $$$d = 102121$$$ and it's maximum possible $$$d$$$.

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

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

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

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)
}


You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the maximum length of a simple path (a path in which each vertex appears at most once) between all pairs of vertices of this tree.Degree of a vertex is the number of edges incident to this vertex (i.e. for a vertex $$$u$$$ it is the number of edges $$$(u, v)$$$ that belong to the tree, where $$$v$$$ is any other vertex of a tree).

The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$).

If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can print edges and vertices connected by an edge in any order. If there are multiple answers, print any of them.1

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1003E(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type edge struct{ v, w int }
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var n, d, k int
	Fscan(in, &n, &d, &k)
	if d > n-1 || k == 1 && d > 1 {
		Fprint(out, "NO")
		return
	}
	es := []edge{}
	cur := d + 2
	var f func(v, l int)
	f = func(v, l int) {
		if l == 0 {
			return
		}
		i := 1
		if v <= d {
			i = 2
		}
		for ; i < k && len(es) < n-1; i++ {
			es = append(es, edge{v, cur})
			cur++
			f(cur-1, l-1)
		}
	}
	for i := 1; i <= d; i++ {
		es = append(es, edge{i, i + 1})
	}
	for i := 2; i <= d; i++ {
		f(i, min(i-1, d+1-i))
	}
	if len(es) < n-1 {
		Fprint(out, "NO")
		return
	}
	Fprintln(out, "YES")
	for _, e := range es {
		Fprintln(out, e.v, e.w)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1003E(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type edge struct{ v, w int }

	var n, d, maxDeg, maxD, u int
	Fscan(in, &n, &d, &maxDeg)
	es := []edge{}
	cur := 2
	var f1 func(int)
	f1 = func(v int) {
		next := []int{}
		mx := maxDeg
		if v > 1 {
			mx--
		}
		for i := 0; i < mx; i++ {
			es = append(es, edge{v, cur})
			if len(es) == n-1 {
				return
			}
			next = append(next, cur)
			cur++
		}
		for _, w := range next {
			f1(w)
			if len(es) == n-1 {
				return
			}
		}
	}
	f1(1)

	g := make([][]int, n+1)
	for _, e := range es {
		g[e.v] = append(g[e.v], e.w)
		g[e.w] = append(g[e.w], e.v)
	}
	var f func(v, fa, d int)
	f = func(v, fa, d int) {
		if d > maxD {
			maxD, u = d, v
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v, d+1)
			}
		}
	}
	maxD = -1
	f(1, 0, 0)
	maxD = -1
	f(u, -1, 0)
	if u > d {
		Fprint(out, "NO")
		return
	}
	Fprintln(out, "YES")
	for _, e := range es {
		Fprintln(out, e.v, e.w)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1003E(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type edge struct{ v, w int }

	var n, d, maxDeg, maxD, u int
	Fscan(in, &n, &d, &maxDeg)
	es := []edge{}
	cur := 2
	q := []int{1}
o:
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		mx := maxDeg
		if v > 1 {
			mx--
		}
		for i := 0; i < mx; i++ {
			es = append(es, edge{v, cur})
			if len(es) == n-1 {
				break o
			}
			q = append(q, cur)
			cur++
		}
	}

	g := make([][]int, n+1)
	for _, e := range es {
		g[e.v] = append(g[e.v], e.w)
		g[e.w] = append(g[e.w], e.v)
	}
	var f func(v, fa, d int)
	f = func(v, fa, d int) {
		if d > maxD {
			maxD, u = d, v
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v, d+1)
			}
		}
	}
	maxD = -1
	f(1, 0, 0)
	maxD = -1
	f(u, -1, 0)
	if maxD > d {
		Fprint(out, "NO")
		return
	}
	Fprintln(out, "YES")
	for _, e := range es {
		Fprintln(out, e.v, e.w)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1003E(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type edge struct{ v, w int }

	var n, d, k, maxD, u int
	Fscan(in, &n, &d, &k)
	es := []edge{}
	cur := 2
	var f1 func(int)
	f1 = func(v int) {
		next := []int{}
		for i := 0; i < k; i++ {
			es = append(es, edge{v, cur})
			if len(es) == n-1 {
				return
			}
			next = append(next, cur)
			cur++
		}
		for _, w := range next {
			f1(w)
			if len(es) == n-1 {
				return
			}
		}
	}
	f1(1)

	g := make([][]int, n+1)
	for _, e := range es {
		g[e.v] = append(g[e.v], e.w)
		g[e.w] = append(g[e.w], e.v)
	}
	var f func(v, fa, d int)
	f = func(v, fa, d int) {
		if d > maxD {
			maxD, u = d, v
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v, d+1)
			}
		}
	}
	maxD = -1
	f(1, 0, 0)
	maxD = -1
	f(u, -1, 0)
	if u > d {
		Fprint(out, "NO")
		return
	}
	Fprintln(out, "YES")
	for _, e := range es {
		Fprintln(out, e.v, e.w)
	}
}

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


You are given an array $$$a[0 \ldots 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 \le i \le n - 1$$$) the equality $$$i \bmod 2 = a[i] \bmod 2$$$ holds, where $$$x \bmod 2$$$ 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: $$$i \bmod 2 = 1 \bmod 2 = 1$$$, but $$$a[i] \bmod 2 = 4 \bmod 2 = 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.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 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 \le n \le 40$$$) — the length of the array $$$a$$$. The next line contains $$$n$$$ integers $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$0 \le a_i \le 1000$$$) — the initial array.

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.

NoteIn the first test case, in the first move, you can swap the elements with indices $$$0$$$ and $$$1$$$, and in the second move, you can swap the elements with indices $$$2$$$ and $$$3$$$.In the second test case, in the first move, you need to swap the elements with indices $$$0$$$ and $$$1$$$.In the third test case, you cannot make the array good.

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"

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 (
	"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 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) % 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))
}


William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $$$c_1, c_2, \dots, c_n$$$ where $$$c_i$$$ is the number of consecutive brackets "(" if $$$i$$$ is an odd number or the number of consecutive brackets ")" if $$$i$$$ is an even number.For example for a bracket sequence "((())()))" a corresponding sequence of numbers is $$$[3, 2, 1, 3]$$$.You need to find the total number of continuous subsequences (subsegments) $$$[l, r]$$$ ($$$l \le r$$$) of the original bracket sequence, which are regular bracket sequences.A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not.

The first line contains a single integer $$$n$$$ $$$(1 \le n \le 1000)$$$, the size of the compressed sequence. The second line contains a sequence of integers $$$c_1, c_2, \dots, c_n$$$ $$$(1 \le c_i \le 10^9)$$$, the compressed sequence.

Output a single integer — the total number of subsegments of the original bracket sequence, which are regular bracket sequences. It can be proved that the answer fits in the signed 64-bit integer data type.

NoteIn the first example a sequence (((()(()))( is described. This bracket sequence contains $$$5$$$ subsegments which form regular bracket sequences:  Subsequence from the $$$3$$$rd to $$$10$$$th character: (()(()))  Subsequence from the $$$4$$$th to $$$5$$$th character: ()  Subsequence from the $$$4$$$th to $$$9$$$th character: ()(())  Subsequence from the $$$6$$$th to $$$9$$$th character: (())  Subsequence from the $$$7$$$th to $$$8$$$th character: () In the second example a sequence ()))(()(()))) is described.In the third example a sequence ()()(()) is described.

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

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

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(v []int64) int64 {
	res := int64(0)
	for i := 0; i+1 < len(v); i += 2 {
		if v[i+1] > v[i] {
			res += v[i]
			continue
		} else {
			res += v[i+1]
		}

		free := v[i] - v[i+1]
		must := int64(0)
		for j := i + 2; j+1 < len(v); j += 2 {
			must += v[j]
			if v[j+1] < must {
				must -= v[j+1]
				continue
			}

			left := v[j+1] - must
			res += 1
			must = 0

			if left > free {
				res += free
				break
			}
			res += left
			free -= left
		}
	}
	return res
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	n := stdin.Int()
	v := stdin.Int64s(n)
	fmt.Println(solve(v))
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

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

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(v []int64) int64 {
	res := int64(0)
	for i := 0; i < len(v); i += 2 {
		lo, hi := int64(1), v[i]
		for j := i + 1; j < len(v); j++ {
			if j%2 == 0 {
				lo += v[j]
				hi += v[j]
			} else {
				if v[j] >= hi {
					res += hi - lo + 1
				} else {
					res += v[j] - lo + 1
				}

				lo -= v[j]
				hi -= v[j]
			}

			if lo < 0 {
				lo = 0
			}
			if hi < 0 {
				break
			}
		}
	}
	return res
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	n := stdin.Int()
	v := stdin.Int64s(n)
	fmt.Println(solve(v))
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

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

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(v []int) int64 {
	res := int64(0)
	for i := 0; i < len(v); i += 2 {
		lo, hi := 1, v[i]
		for j := i + 1; j < len(v); j++ {
			if j%2 == 0 {
				lo += v[j]
				hi += v[j]
			} else {
				if v[j] >= hi {
					res += int64(hi - lo + 1)
				} else {
					res += int64(v[j] - lo + 1)
				}

				lo -= v[j]
				hi -= v[j]
			}

			if lo < 0 {
				lo = 0
			}
			if hi < 0 {
				break
			}
		}
	}
	return res
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	n := stdin.Int()
	v := stdin.Ints(n)
	fmt.Println(solve(v))
}


You are given a tree with $$$n$$$ vertices. You are allowed to modify the structure of the tree through the following multi-step operation:  Choose three vertices $$$a$$$, $$$b$$$, and $$$c$$$ such that $$$b$$$ is adjacent to both $$$a$$$ and $$$c$$$.  For every vertex $$$d$$$ other than $$$b$$$ that is adjacent to $$$a$$$, remove the edge connecting $$$d$$$ and $$$a$$$ and add the edge connecting $$$d$$$ and $$$c$$$.  Delete the edge connecting $$$a$$$ and $$$b$$$ and add the edge connecting $$$a$$$ and $$$c$$$. As an example, consider the following tree:  The following diagram illustrates the sequence of steps that happen when we apply an operation to vertices $$$2$$$, $$$4$$$, and $$$5$$$:  It can be proven that after each operation, the resulting graph is still a tree.Find the minimum number of operations that must be performed to transform the tree into a star. A star is a tree with one vertex of degree $$$n - 1$$$, called its center, and $$$n - 1$$$ vertices of degree $$$1$$$.

The first line contains an integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$)  — the number of vertices in the tree. The $$$i$$$-th of the following $$$n - 1$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \neq v_i$$$) denoting that there exists an edge connecting vertices $$$u_i$$$ and $$$v_i$$$. It is guaranteed that the given edges form a tree.

Print a single integer  — the minimum number of operations needed to transform the tree into a star. It can be proven that under the given constraints, it is always possible to transform the tree into a star using at most $$$10^{18}$$$ operations.

NoteThe first test case corresponds to the tree shown in the statement. As we have seen before, we can transform the tree into a star with center at vertex $$$5$$$ by applying a single operation to vertices $$$2$$$, $$$4$$$, and $$$5$$$.In the second test case, the given tree is already a star with the center at vertex $$$4$$$, so no operations have to be performed.

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
}


A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace each character '?' with one of the three characters 'a', 'b' or 'c', such that the resulting string is beautiful. Please help him!More formally, after replacing all characters '?', the condition $$$s_i \neq s_{i+1}$$$ should be satisfied for all $$$1 \leq i \leq |s| - 1$$$, where $$$|s|$$$ is the length of the string $$$s$$$.

The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'.  It is guaranteed that in each test case a string $$$s$$$ has at least one character '?'. The sum of lengths of strings $$$s$$$ in all test cases does not exceed $$$10^5$$$.

For each test case given in the input print the answer in the following format:   If it is impossible to create a beautiful string, print "-1" (without quotes);  Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them.

NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful string, because the $$$4$$$-th and $$$5$$$-th characters will be always equal.In the third test case, the only answer is "acbac".

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 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 (
	"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)
		}
	}
}