You are given an array $$$a$$$ consisting of $$$n$$$ integers. Indices of the array start from zero (i. e. the first element is $$$a_0$$$, the second one is $$$a_1$$$, and so on).You can reverse at most one subarray (continuous subsegment) of this array. Recall that the subarray of $$$a$$$ with borders $$$l$$$ and $$$r$$$ is $$$a[l; r] = a_l, a_{l + 1}, \dots, a_{r}$$$.Your task is to reverse such a subarray that the sum of elements on even positions of the resulting array is maximized (i. e. the sum of elements $$$a_0, a_2, \dots, a_{2k}$$$ for integer $$$k = \lfloor\frac{n-1}{2}\rfloor$$$ should be maximum possible).You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_0, a_1, \dots, a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each test case, print the answer on the separate line — the maximum possible sum of elements on even positions after reversing at most one subarray (continuous subsegment) of $$$a$$$.

// --- In the name of Allah ---
package main
import(
	"fmt"
	"bufio"
	"os"
	"strconv"
)
func main(){
	t := InputInt();
	var answers []int64;
	for ;t>0;t--{
		n := InputInt();
		var array []int;
		var sum int64;
		for i:=0; i<n; i ++{
			x := InputInt();
			if i % 2 == 0{
				sum += int64(x);
			}
			array = append(array, x);
		}
		var cnt, ans int64 =0, sum;
		for i:=0; i < n-1; i += 2{
			cnt -= int64(array[i]);
			cnt += int64(array[i+1]);
			if cnt < 0{
				cnt = 0;
			}
			ans = max( ans, sum + cnt );
		}
		cnt = 0;
		for i:=1; i < n-1; i +=2 {
			cnt += int64(array[i]);
			cnt -= int64(array[i+1]);
			if( cnt < 0 ){
				cnt = 0;
			}
			ans = max( ans, sum + cnt);
		}
		answers = append(answers, ans);
	}
	for _, val := range answers{
		fmt.Println(val);
	}
}
func max( a int64, b int64)int64{
	if( a > b){
		return a;
	}else{
		return b;
	}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
var Scanner = bufio.NewScanner(os.Stdin);

func init(){
	//Scanner.Buffer(make([]byte,256), 1e6);
	Scanner.Split(bufio.ScanWords);
}
func Input() string{
	Scanner.Scan();
	return Scanner.Text();
}
func InputInt()int{
	i, err := strconv.Atoi(Input());
	if err != nil {
		panic(err);
	}
	return i;
}

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), " ")
		an := make([]int64, n)
		srcSum := int64(0)
		for j, ai := range ans {
			an[j], _ = strconv.ParseInt(ai, 10, 64)
			if j%2 == 0 {
				srcSum += an[j]
			}
		}
		if n == 1 {
			fmt.Println(an[0])
			continue
		}
		bn := make([]int64, n/2) // pairs
		cn := make([]int64, (n-1)/2)
		if n%2 == 0 {
			for i := int64(0); i < n; {
				bn[i/2] = an[i+1] - an[i]
				if i > 1 {
					cn[(i-1)/2] = an[i-1] - an[i]
				}
				i = i + 2
			}

		} else {
			start := int64(0)
			for ; start < n-1; {
				bn[start/2] = an[start+1] - an[start]
				start = start + 2
			}
			for start=1;start<n-1; {
				cn[(start-1)/2] = an[start] - an[start+1]
				start = start + 2
			}
		}
		// find max sum
		// fmt.Println(bn)
		// fmt.Println(cn)
		// fmt.Println(srcSum)
		max := findMax(bn)
		if max < 0 {
			max = 0
		}
		maxcn := findMax(cn)
		if maxcn > max {
			max = maxcn
		}

		fmt.Println(srcSum + max)
	}
}

func findMax(bn []int64) int64 {
	current := int64(0)
	max := int64(0)
	for j := 0; j < len(bn); j++ {
		current += bn[j]
		if current < 0 {
			current = 0
		} else if current > 0 {
			if current > max {
				max = current
			}
		}
	}
	return max
}

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
}

/*
URL:
https://codeforces.com/problemset/problem/1373/D
*/

package main

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

/********** 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 (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int64
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadInt64Slice(n)

		solve()
	}
}

func solve() {
	dp := make([][]int64, n+10)
	for i := 0; i <= n+5; i++ {
		dp[i] = make([]int64, 3)
	}
	A = append(A, 0)

	for i := 0; i < n; i++ {
		a := A[i]
		b := A[i+1]
		if i%2 == 0 {
			ChMax(&dp[i+1][0], dp[i][0]+a)

			ChMax(&dp[i+2][1], dp[i][0]+b)
			ChMax(&dp[i+2][1], dp[i][1]+b)

			// ChMax(&dp[i+1][2], dp[i][0]+a)
			ChMax(&dp[i+1][2], dp[i][1]+a)
			ChMax(&dp[i+1][2], dp[i][2]+a)
		} else {
			ChMax(&dp[i+1][0], dp[i][0])

			ChMax(&dp[i+2][1], dp[i][0]+a)
			ChMax(&dp[i+2][1], dp[i][1]+a)

			// ChMax(&dp[i+1][2], dp[i][0])
			ChMax(&dp[i+1][2], dp[i][1])
			ChMax(&dp[i+1][2], dp[i][2])
		}
	}

	fmt.Println(Max(dp[n][0], dp[n][1], dp[n][2]))
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int64) int64 {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int64, target int64) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/contest/1373/problem/D
*/

package main

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

/********** 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 (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int64
)

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadInt64Slice(n)

		solve()
	}
}

func solve() {
	B, C := []int64{}, []int64{}

	for i := 0; i+1 < n; i += 2 {
		val := A[i+1] - A[i]
		B = append(B, val)
	}
	for i := 1; i+1 < n; i += 2 {
		val := A[i] - A[i+1]
		C = append(C, val)
	}

	bpref := make([]int64, len(B)+1)
	cpref := make([]int64, len(C)+1)
	for i := 0; i < len(B); i++ {
		bpref[i+1] = bpref[i] + B[i]
	}
	for i := 0; i < len(C); i++ {
		cpref[i+1] = cpref[i] + C[i]
	}
	// PrintfDebug("bpref: %v\n", bpref)
	// PrintfDebug("cpref: %v\n", cpref)

	bb, cc := make([]int64, len(bpref)), make([]int64, len(cpref))
	mini := int64(0)
	for i := 1; i < len(bb); i++ {
		bb[i] = bpref[i] - mini
		ChMin(&mini, bpref[i])
	}
	mini = 0
	for i := 1; i < len(cc); i++ {
		cc[i] = cpref[i] - mini
		ChMin(&mini, cpref[i])
	}

	base := int64(0)
	for i := 0; i < n; i += 2 {
		base += A[i]
	}
	fmt.Println(base + Max(Max(cc...), Max(bb...)))
}

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int64, target int64) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// func solve() {
// 	dp := make([][]int64, n+10)
// 	for i := 0; i <= n+3; i++ {
// 		dp[i] = make([]int64, 3)
// 	}

// 	for i := 0; i < n; i++ {
// 		if i%2 == 0 {
// 			// A[i]は偶数番目
// 			ChMax(&dp[i+2][0], dp[i][0]+A[i])
// 			ChMax(&dp[i+2][2], dp[i][2]+A[i])
// 		} else {
// 			// A[i]は奇数番目
// 			ChMax(&dp[i+1][1], dp[i][0]+A[i])
// 			ChMax(&dp[i+2][1], dp[i][1]+A[i])
// 			ChMax(&dp[i+1][2], dp[i][1]+A[i])
// 		}
// 	}

// 	fmt.Println(Max(dp[n][2], dp[n+1][2], dp[n][0], dp[n+1][0]))
// }

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int64, target int64) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int64) int64 {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/1373/D
*/

package main

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

/********** 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 (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int64
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadInt64Slice(n)

		solve()
	}
}

func solve() {
	dp := make([][]int64, n+10)
	for i := 0; i <= n+5; i++ {
		dp[i] = make([]int64, 3)
	}
	A = append(A, 0)

	for i := 0; i < n; i++ {
		a := A[i]
		b := A[i+1]
		if i%2 == 0 {
			ChMax(&dp[i+1][0], dp[i][0]+a)

			ChMax(&dp[i+2][1], dp[i][0]+b)
			ChMax(&dp[i+2][1], dp[i][1]+b)

			ChMax(&dp[i+1][2], dp[i][0]+a)
			ChMax(&dp[i+1][2], dp[i][1]+a)
			ChMax(&dp[i+1][2], dp[i][2]+a)
		} else {
			ChMax(&dp[i+1][0], dp[i][0])

			ChMax(&dp[i+2][1], dp[i][0]+a)
			ChMax(&dp[i+2][1], dp[i][1]+a)

			ChMax(&dp[i+1][2], dp[i][0])
			ChMax(&dp[i+1][2], dp[i][1])
			ChMax(&dp[i+1][2], dp[i][2])
		}
	}

	fmt.Println(Max(dp[n][0], dp[n][1], dp[n][2]))
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int64) int64 {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int64, target int64) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1373D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	max := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}
	f := func(a []int64) int64 {
		if len(a) == 0 {
			return 0
		}
		curS, maxS := a[0], a[0]
		for _, v := range a[1:] {
			curS = max(curS+v, v)
			maxS = max(maxS, curS)
		}
		return max(maxS, 0)
	}
	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		s := int64(0)
		a := make([]int64, n)
		var b, c []int64
		for i := range a {
			Fscan(in, &a[i])
			if i&1 == 0 {
				s += a[i]
				if i > 0 {
					c = append(c, a[i-1]-a[i])
				}
			} else {
				b = append(b, a[i]-a[i-1])
			}
		}
		Fprintln(out, s+max(f(b), f(c)))
	}
}

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

/**
https://codeforces.com/contest/1373/problem/D
**/

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line1, _ := reader.ReadString('\n')
	line1_arr := strings.Fields(line1)
	//fmt.Println(line1_arr)
	T, _ := strconv.Atoi(line1_arr[0])
	// fmt.Println("T:", T)
	for t := 0; t < T; t++ {
		line2, _ := reader.ReadString('\n')
		line2_arr := strings.Fields(line2)
		N, _ := strconv.Atoi(line2_arr[0])
		// fmt.Println("N: ", N)
		line3, _ := reader.ReadString('\n')
		//fmt.Println("line3: ", line3)
		line3_arr := strings.Fields(line3)
		A := make([]int64, N)
		for n := 0; n < N; n++ {
			v, _ := strconv.Atoi(line3_arr[n])
			A[n] = int64(v)
		}

		if N == 1 {
			fmt.Println(A[0])
			continue
		}
		//fmt.Println("A: ", A)

		// Approach as per
		// https://codeforces.com/blog/entry/79376
		dp_arr := make([][]int64, N)
		for i := 0; i < N; i++ {
			dp_arr[i] = make([]int64, 3)
		}
		dp_arr[0][0] = A[0] // even
		dp_arr[0][1] = 0 // even
		dp_arr[0][2] = A[0] // even

		dp_arr[1][0] = A[0] // even
		dp_arr[1][1] = A[1] // even
		dp_arr[1][2] = A[0] // even

		for j := 0; j < 3; j++ {
			for i := 2; i < N; i++ {
				max_1_2 := max(dp_arr[i-2][0], dp_arr[i-2][1])
				max_1_2_3 := max(max(dp_arr[i-1][0], dp_arr[i-1][1]), dp_arr[i-1][2])
				if i%2 == 0 {
					dp_arr[i][0] = dp_arr[i-1][0] + A[i]
					dp_arr[i][1] = max_1_2 + A[i-1]
					dp_arr[i][2] = max_1_2_3 + A[i]
				} else {
					dp_arr[i][0] = dp_arr[i-1][0]
					dp_arr[i][1] = max_1_2 + A[i]
					dp_arr[i][2] = max_1_2_3
				}
			}
		}

		//fmt.Println("dp_arr: ", dp_arr)

		max_sum := max(dp_arr[N-1][0], dp_arr[N-1][1])
		max_sum = max(max_sum, dp_arr[N-1][2])
		fmt.Println(max_sum)

	}
}

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

package main

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

var (
	inn = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()
	inn.Buffer([]byte{}, 10000000)
	inn.Split(bufio.ScanWords)
	//prep
	for tt := rd(); tt > 0; tt-- {
		n := rd()
		a := make([]int64, n)
		for i := range a {
			a[i] = rdint64()
		}
		var sum int64
		for i := 0; i < n; i += 2 {
			sum += a[i]
		}
		var cur, mx int64
		for i := 1; i < n; i += 2 {
			cur = maxint64(cur+a[i]-a[i-1], a[i]-a[i-1])
			mx = maxint64(mx, cur)
		}
		cur = 0
		for i := 2; i < n; i += 2 {
			cur = maxint64(cur+a[i-1]-a[i], a[i-1]-a[i])
			mx = maxint64(cur, mx)
		}
		Fprintln(out, sum+mx)
	}
}

//-------------------template------------------
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func maxint64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func minint64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	x, _ = strconv.Atoi(string(inn.Bytes()))
	return x
}
func rdint64() (x int64) {
	inn.Scan()
	x, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)
	return x
}
func rds() string {
	inn.Scan()
	return string(inn.Bytes())
}

package main

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

func main() {
	t := NextInt()
	for t > 0 {
		t--

		n := NextInt()
		a := make([]int64, n)

		sum := int64(0)
		for i := 0; i < n; i++ {
			a[i] = int64(NextInt())
			if i % 2 == 0 {
				sum += int64(a[i])
			}
		}

		s1 := int64(0)
		s2 := int64(0)
		minSum1 := int64(0)
		maxSum1 := int64(0)
		minSum2 := int64(0)
		maxSum2 := int64(0)
		for i := 1; i < n; i += 2 {
			if i + 1 < n {
				s1 += a[i] - a[i+1]
				if s1 - minSum1 > maxSum1 {
					maxSum1 = s1 - minSum1
				}
				if s1 < minSum1 {
					minSum1 = s1
				}
			}
			s2 += a[i] - a[i-1]
			if s2 - minSum2 > maxSum2 {
				maxSum2 = s2 - minSum2
			}
			if s2 < minSum2 {
				minSum2 = s2
			}
		}

		ans := sum + maxSum1
		if sum + maxSum2 > ans {
			ans = sum + maxSum2
		}
		fmt.Println(ans)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	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 NextDouble() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

// --- In the name of Allah ---
package main
import "fmt"

func max( a int64, b int64)int64{
	if( a > b){
		return a;
	}else{
		return b;
	}
}
func main(){
	var t int;
	fmt.Scanln(&t);
	for ;t>0;t--{
		var n int;
		fmt.Scanln(&n);
		var array []int;
		var sum int64;
		for i:=0; i<n; i ++{
			var x int;
			fmt.Scanln(&x," ");
			if i % 2 == 0{
				sum += int64(x);
			}
			array = append(array, x);
		}
		var cnt, ans int64 =0, sum;
		for i:=0; i < n-1; i += 2{
			cnt -= int64(array[i]);
			cnt += int64(array[i+1]);
			if cnt < 0{
				cnt = 0;
			}
			ans = max( ans, sum + cnt );
		}
		cnt = 0;
		for i:=1; i < n-1; i +=2 {
			cnt += int64(array[i]);
			cnt -= int64(array[i+1]);
			if( cnt < 0 ){
				cnt = 0;
			}
			ans = max( ans, sum + cnt);
		}
		fmt.Println(ans);
	}

}

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), " ")
		an := make([]int64, n)
		srcSum := int64(0)
		for j, ai := range ans {
			an[j], _ = strconv.ParseInt(ai, 10, 64)
			if j%2 == 0 {
				srcSum += an[j]
			}
		}
		if n == 1 {
			fmt.Println(an[0])
			continue
		}
		bn := make([]int64, n/2) // pairs
		cn := make([]int64, (n-1)/2)
		if n%2 == 0 {
			for i := int64(0); i < n; {
				bn[i/2] = an[i+1] - an[i]
				if i > 1 {
					cn[(i-1)/2] = an[i-1] - an[i]
				}
				i = i + 2
			}

		} else {
			start := int64(0)
			for ; start < n-1; {
				bn[start/2] = an[start+1] - an[start]
				if start > 1 {
					cn[(start-1) / 2] = an[start-1] - an[start]
				}
				start = start + 2
			}
		}
		// find max sum
		// fmt.Println(bn)
		max := findMax(bn)
		if n % 2 == 0 {
			maxcn := findMax(cn)
			if maxcn > max {
				max = maxcn
			}
		}
		fmt.Println(srcSum + max)
	}
}

func findMax(bn []int64) int64 {
	current := int64(0)
	max := int64(0)
	for j := 0; j < len(bn); j++ {
		current += bn[j]
		if current < 0 {
			current = 0
		} else if current > 0 {
			if current > max {
				max = current
			}
		}
	}
	return max
}

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"
	"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), " ")
		an := make([]int64, n)
		srcSum := int64(0)
		for j, ai := range ans {
			an[j], _ = strconv.ParseInt(ai, 10, 64)
			if j%2 == 0 {
				srcSum += an[j]
			}
		}
		// fmt.Println(n, an)
		if n == 1 {
			fmt.Println(an[0])
			continue
		}
		bn := make([]int64, n/2) // pairs
		cn := make([]int64, (n-1)/2)
		if n%2 == 0 {
			for i := int64(0); i < n; {
				bn[i/2] = an[i+1] - an[i]
				if i > 1 {
					cn[(i-1)/2] = an[i-1] - an[i]
				}
				i = i + 2
			}

		} else {
			start := int64(0)
			if an[n-1] > an[0] {
				start = 1
			}
			for ; start < n-1; {
				// fmt.Println(start)
				bn[start/2] = an[start+1] - an[start]
				start = start + 2
			}
		}
		// find max sum
		// fmt.Println(bn)
		max := findMax(bn)
		if n % 2 == 0 {
			maxcn := findMax(cn)
			if maxcn > max {
				max = maxcn
			}
		}
		fmt.Println(srcSum + max)
	}
}

func findMax(bn []int64) int64 {
	current := int64(0)
	max := int64(0)
	for j := 0; j < len(bn); j++ {
		current += bn[j]
		if current < 0 {
			current = 0
		} else if current > 0 {
			if current > max {
				max = current
			}
		}
	}
	return max
}

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"
	"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), " ")
		an := make([]int64, n)
		srcSum := int64(0)
		for j, ai := range ans {
			an[j], _ = strconv.ParseInt(ai, 10, 64)
			if j%2 == 0 {
				srcSum += an[j]
			}
		}
		if n == 1 {
			fmt.Println(an[0])
			continue
		}
		bn := make([]int64, n/2) // pairs
		cn := make([]int64, (n-1)/2)
		if n%2 == 0 {
			for i := int64(0); i < n; {
				bn[i/2] = an[i+1] - an[i]
				if i > 1 {
					cn[(i-1)/2] = an[i-1] - an[i]
				}
				i = i + 2
			}

		} else {
			start := int64(0)
			for ; start < n-1; {
				bn[start/2] = an[start+1] - an[start]
				if start > 1 {
					cn[(start-1)/2] = an[start-1] - an[start]
				}
				start = start + 2
			}
		}
		// find max sum
		// fmt.Println(bn)
		// fmt.Println(cn)
		// fmt.Println(srcSum)
		max := findMax(bn)
		maxcn := findMax(cn)
		if maxcn > max {
			max = maxcn
		}

		fmt.Println(srcSum + max)
	}
}

func findMax(bn []int64) int64 {
	current := int64(0)
	max := int64(0)
	for j := 0; j < len(bn); j++ {
		current += bn[j]
		if current < 0 {
			current = 0
		} else if current > 0 {
			if current > max {
				max = current
			}
		}
	}
	return max
}

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
}

/**
https://codeforces.com/contest/1373/problem/D
**/

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line1, _ := reader.ReadString('\n')
	line1_arr := strings.Fields(line1)
	//fmt.Println(line1_arr)
	T, _ := strconv.Atoi(line1_arr[0])
	// fmt.Println("T:", T)
	for t := 0; t < T; t++ {
		line2, _ := reader.ReadString('\n')
		line2_arr := strings.Fields(line2)
		N, _ := strconv.Atoi(line2_arr[0])
		// fmt.Println("N: ", N)
		line3, _ := reader.ReadString('\n')
		//fmt.Println("line3: ", line3)
		line3_arr := strings.Fields(line3)
		A := make([]int, N)
		for n := 0; n < N; n++ {
			v, _ := strconv.Atoi(line3_arr[n])
			A[n] = v
		}

		if N == 1 {
			fmt.Println(A[0])
			continue
		}
		//fmt.Println("A: ", A)

		// Approach as per
		// https://codeforces.com/blog/entry/79376
		dp_arr := make([][]int, N)
		for i := 0; i < N; i++ {
			dp_arr[i] = make([]int, 3)
		}
		dp_arr[0][0] = A[0] // even
		dp_arr[0][1] = 0 // even
		dp_arr[0][2] = A[0] // even

		dp_arr[1][0] = A[0] // even
		dp_arr[1][1] = A[1] // even
		dp_arr[1][2] = A[0] // even

		for j := 0; j < 3; j++ {
			for i := 2; i < N; i++ {
				max_1_2 := max(dp_arr[i-2][0], dp_arr[i-2][1])
				max_1_2_3 := max(max(dp_arr[i-1][0], dp_arr[i-1][1]), dp_arr[i-1][2])
				if i%2 == 0 {
					dp_arr[i][0] = dp_arr[i-1][0] + A[i]
					dp_arr[i][1] = max_1_2 + A[i-1]
					dp_arr[i][2] = max_1_2_3 + A[i]
				} else {
					dp_arr[i][0] = dp_arr[i-1][0]
					dp_arr[i][1] = max_1_2 + A[i]
					dp_arr[i][2] = max_1_2_3
				}
			}
		}

		//fmt.Println("dp_arr: ", dp_arr)

		max_sum := max(dp_arr[N-1][0], dp_arr[N-1][1])
		max_sum = max(max_sum, dp_arr[N-1][2])
		fmt.Println(max_sum)

	}
}

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


Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three digits.

The first line contains integer n (2 ≤ n ≤ 100) — amount of digits in the phone number. The second line contains n digits — the phone number to divide into groups.

Output any of divisions of the given phone number into groups of two or three digits. Separate groups by single character -. If the answer is not unique, output any.

package main

import (
	"fmt"
	"io/ioutil"
	"bytes"
	"os"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n", &n)
	fmt.Fscanf(reader, "%s\n", &s)

	digits := []byte(s)
	for ;; {
		if len(digits) <= 3 {
			fmt.Printf("%s", string(digits))
			return
		} else {
			fmt.Printf("%s-", string(digits[:2]))
			digits = digits[2:]
		}
	}
}

package main

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

func main(){
	var n int
	var num string
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	num = r.Text()
	for i:=0; i<n; i++ {
		w.WriteString(string(num[i]))
		if i%2 != 0 && i < n-(n%2)-2  {
			w.WriteString("-")
		}
	}
	w.WriteString("\n")
	w.Flush()
}

package main

import (
	"fmt"
)

func main() {

	var (
		lo, i     int32
		orig, ans string
	)

	fmt.Scan(&lo)
	fmt.Scan(&orig)
	if lo < 4 {
		ans = orig
	} else {
		if lo%2 > 0 {
			ans = orig[0:3]
			i = 3
		} else {
			ans = orig[0:2]
			i = 2
		}
		for i < lo {
			ans += "-"
			ans += orig[i : i+2]
			i += 2
		}
	}

	fmt.Println(ans)
}

package main

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

func main() {
	z := bufio.NewScanner(os.Stdin)
	z.Scan()
	z.Scan()
	s := z.Text()
	initial, recurrent := 0,0
	switch {
	case len(s)%3 == 0:
		initial, recurrent = 3, 3
		break
	case len(s)%2 == 0:
		initial, recurrent = 2, 2
		break
	default:
		initial, recurrent = 3, 2
		break
	}

	fmt.Print(s[0:initial])
	for i := initial; i < len(s); i+=recurrent {
		fmt.Print("-" + s[i:i+recurrent])
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	digitCount := 0
	if scanner.Scan() {
		line := scanner.Text()

		fmt.Sscanf(line, "%d", &digitCount)
	}

	if scanner.Scan() {
		line := scanner.Text()

		output := ""
		for i, r := range line {
			output += string(r)
			if i%2 == 1 && i != digitCount-2 && i != digitCount-1 {
				output += "-"
			}
		}
		fmt.Println(output)
	}
}

// 25B
package main

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

func main() {
	var i, n int
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	fmt.Scan(&n)
	s := make([]byte, n)
	in.Scan()
	s = in.Bytes()
	for i = 0; i < n; i++ {
		fmt.Print(string(s[i]))
		if i%2 != 0 && i < n-2 {
			fmt.Print("-")
		}
	}
}

// 25B-mic
package main

import (
	"fmt"
)

func main() {
	var s string
	var n, k, i, j int
	fmt.Scan(&n)
	fmt.Scan(&s)
	if n%2 == 0 {
		for i = 0; i < n; i++ {
			fmt.Print(string(s[i]))
			k++
			if k == 2 && i != n-1 {
				fmt.Print("-")
				k = 0
			}
		}
	} else {
		for i = 0; i < n-3; i++ {
			fmt.Print(string(s[i]))
			k++
			if k == 2 {
				fmt.Print("-")
				k = 0
			}
		}
		for j = i; j < n; j++ {
			fmt.Print(string(s[j]))

		}
	}
	fmt.Println()
}

package main

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

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

func main() {
        defer w.Flush()

        var n int
        var s string
        fmt.Fscanf(r, "%d\n", &n)
        fmt.Fscanf(r, "%s\n", &s)
        var ans strings.Builder
        var i int
        if n % 2 == 0 {
                ans.WriteString(s[:2])
                i = 2
        } else {
                ans.WriteString(s[:3])
                i = 3
        }
        for ; i < n - 1; i += 2 {
                ans.WriteString("-" + s[i:i+2])
        }
        fmt.Fprintf(w, "%v", ans.String())
}

package main

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

func dsuGet(p []int, v int) int {
	if v == p[v] {
		return v
	}
	p[v] = dsuGet(p, p[v])
	return p[v]
}

func dsuUnite(p []int, a, b int) {
	a = dsuGet(p, a)
	b = dsuGet(p, b)
	if rand.Int() & 1 == 1 {
		a, b = b, a
	}
	if a != b {
		p[a] = b
	}
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)

	var s string
	fmt.Fscanf(reader, "%s\n", &s)

	for len(s) > 0 {
		if len(s) % 3 == 2 || len(s) % 3 == 1 {
			fmt.Fprintf(writer, "%s", s[0:2])
			s = s[2:]
		} else {
			fmt.Fprintf(writer, "%s", s[0:3])
			s = s[3:]
		}
		if len(s) > 0 {
			fmt.Fprintf(writer, "-")
		}
	}

	writer.Flush()
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	digitCount := 0
	if scanner.Scan() {
		line := scanner.Text()

		fmt.Sscanf(line, "%d", &digitCount)
	}

	if scanner.Scan() {
		line := scanner.Text()

		output := ""
		for i, r := range line {
			output += string(r)
			if i%2 == 1 && i != digitCount-2 {
				output += "-"
			}
		}
		fmt.Println(output)
	}
}

// 25B
package main

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

func main() {
	var i, n int
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	fmt.Scan(&n)
	s := make([]byte, n)
	in.Scan()
	s = in.Bytes()
	for i = 0; i < n; i++ {
		fmt.Print(s[i])
		if i%2 != 0 && i < n-2 {
			fmt.Print("-")
		}
	}
}


You are given $$$n$$$ patterns $$$p_1, p_2, \dots, p_n$$$ and $$$m$$$ strings $$$s_1, s_2, \dots, s_m$$$. Each pattern $$$p_i$$$ consists of $$$k$$$ characters that are either lowercase Latin letters or wildcard characters (denoted by underscores). All patterns are pairwise distinct. Each string $$$s_j$$$ consists of $$$k$$$ lowercase Latin letters.A string $$$a$$$ matches a pattern $$$b$$$ if for each $$$i$$$ from $$$1$$$ to $$$k$$$ either $$$b_i$$$ is a wildcard character or $$$b_i=a_i$$$.You are asked to rearrange the patterns in such a way that the first pattern the $$$j$$$-th string matches is $$$p[mt_j]$$$. You are allowed to leave the order of the patterns unchanged.Can you perform such a rearrangement? If you can, then print any valid order.

The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \le n, m \le 10^5$$$, $$$1 \le k \le 4$$$) — the number of patterns, the number of strings and the length of each pattern and string. Each of the next $$$n$$$ lines contains a pattern — $$$k$$$ characters that are either lowercase Latin letters or underscores. All patterns are pairwise distinct. Each of the next $$$m$$$ lines contains a string — $$$k$$$ lowercase Latin letters, and an integer $$$mt$$$ ($$$1 \le mt \le n$$$) — the index of the first pattern the corresponding string should match.

Print "NO" if there is no way to rearrange the patterns in such a way that the first pattern that the $$$j$$$-th string matches is $$$p[mt_j]$$$. Otherwise, print "YES" in the first line. The second line should contain $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ — the order of the patterns. If there are multiple answers, print any of them.

5 3 4
_b_d
__b_
aaaa
ab__
_bcd
abcd 4
abba 2
dbcd 5

NoteThe order of patterns after the rearrangement in the first example is the following:   aaaa  __b_  ab__  _bcd  _b_d Thus, the first string matches patterns ab__, _bcd, _b_d in that order, the first of them is ab__, that is indeed $$$p[4]$$$. The second string matches __b_ and ab__, the first of them is __b_, that is $$$p[2]$$$. The last string matches _bcd and _b_d, the first of them is _bcd, that is $$$p[5]$$$.The answer to that test is not unique, other valid orders also exist.In the second example cba doesn't match __c, thus, no valid order exists.In the third example the order (a_, _b) makes both strings match pattern $$$1$$$ first and the order (_b, a_) makes both strings match pattern $$$2$$$ first. Thus, there is no order that produces the result $$$1$$$ and $$$2$$$.

package main

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

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

	var buf bytes.Buffer

	n, m, k := readThreeNums(reader)

	P := make([]string, n)
	for i := 0; i < n; i++ {
		P[i], _ = reader.ReadString('\n')
		P[i] = P[i][:k]
	}

	S := make([]string, m)
	T := make([]int, m)

	for i := 0; i < m; i++ {
		s, _ := reader.ReadBytes('\n')
		S[i] = string(s[:k])
		readInt(s, k+1, &T[i])
	}

	res := solve(k, P, S, T)

	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	buf.WriteString("YES\n")
	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	buf.WriteByte('\n')

	fmt.Print(buf.String())
}

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(k int, P []string, S []string, T []int) []int {
	K := 1 << k
	ii := make([]*Node, K)

	for i := 0; i < K; i++ {
		ii[i] = new(Node)
	}
	var buf bytes.Buffer
	for i := 0; i < len(P); i++ {
		cur := P[i]
		var mask int
		for j := 0; j < k; j++ {
			if cur[j] == '_' {
				mask |= 1 << j
			} else {
				buf.WriteByte(cur[j])
			}
		}
		AddString(ii[mask], buf.String(), i)
		buf.Reset()
	}

	n := len(P)
	que := make([]int, n)
	// at most K * n edges, when each mask contains all node
	var all int

	for i := 0; i < len(S); i++ {
		// lets enumerate the masks
		var p int
		for mask := 0; mask < K; mask++ {
			for j := 0; j < k; j++ {
				if (mask>>j)&1 == 0 {
					//should be same
					buf.WriteByte(S[i][j])
				}
			}
			res := Search(ii[mask], buf.String())
			buf.Reset()
			if len(res) > 0 {
				copy(que[p:], res)
				p += len(res)
			}
		}
		if p == 0 {
			return nil
		}
		all += p - 1
	}

	g := NewGraph(n, all)

	for i := 0; i < len(S); i++ {
		// lets enumerate the masks
		var p int
		for mask := 0; mask < K; mask++ {
			for j := 0; j < k; j++ {
				if (mask>>j)&1 == 0 {
					//should be same
					buf.WriteByte(S[i][j])
				}
			}
			res := Search(ii[mask], buf.String())
			buf.Reset()
			if len(res) > 0 {
				copy(que[p:], res)
				p += len(res)
			}
		}

		// if not found T[i] return nil
		pivot := -1
		for j := 0; j < p; j++ {
			if que[j] == T[i]-1 {
				pivot = j
				break
			}
		}
		if pivot < 0 {
			return nil
		}
		for j := 0; j < p; j++ {
			if j == pivot {
				continue
			}
			g.AddEdge(que[pivot], que[j])
		}
	}
	vis := make([]int, n)
	res := make([]int, 0, n)
	var topo func(u int) bool
	topo = func(u int) bool {
		if vis[u] == 1 {
			return false
		}
		vis[u]++

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if vis[v] == 2 {
				continue
			}
			if !topo(v) {
				return false
			}
		}
		vis[u]++
		res = append(res, u+1)
		return true
	}

	for i := 0; i < n; i++ {
		if vis[i] == 0 {
			if !topo(i) {
				return nil
			}
		}
	}

	reverse(res)

	return res
}

func reverse(arr []int) {
	for i, j := 0, len(arr)-1; i < j; i, j = i+1, j-1 {
		arr[i], arr[j] = arr[j], arr[i]
	}
}

type Graph struct {
	nodes []int
	next  []int
	to    []int
	cur   int
}

func NewGraph(n int, e int) *Graph {
	nodes := make([]int, n)
	next := make([]int, e+10)
	to := make([]int, e+10)
	cur := 1
	return &Graph{nodes, next, to, cur}
}

func (g *Graph) AddEdge(u, v int) {
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
}

type Node struct {
	children [26]*Node
	pos      []int
}

func AddString(root *Node, s string, p int) {
	node := root
	for i := 0; i < len(s); i++ {
		x := int(s[i] - 'a')
		if node.children[x] == nil {
			node.children[x] = new(Node)
		}
		node = node.children[x]
	}
	if node.pos == nil {
		node.pos = make([]int, 0, 2)
	}
	node.pos = append(node.pos, p)
}

func Search(root *Node, s string) []int {
	node := root
	for i := 0; i < len(s); i++ {
		x := int(s[i] - 'a')
		if node.children[x] == nil {
			return nil
		}
		node = node.children[x]
	}
	return node.pos
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1476E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v int
	Fscan(in, &n, &m, &k)
	mp := make(map[string]int, n)
	for i := 1; i <= n; i++ {
		var s string
		Fscan(in, &s)
		mp[s] = i
	}

	var s []byte
	var ids []int
	var f func(p int)
	f = func(p int) {
		if p == k {
			if id := mp[string(s)]; id > 0 {
				ids = append(ids, id-1)
			}
			return
		}
		f(p + 1)
		tmp := s[p]
		s[p] = '_'
		f(p + 1)
		s[p] = tmp
	}

	g := make([][]int, n)
	deg := make([]int, n)
o:
	for i := 0; i < m; i++ {
		Fscan(in, &s, &v)
		v--
		ids = []int{}
		f(0)
		for _, id := range ids {
			if id == v {
				for _, w := range ids {
					if w != v {
						g[v] = append(g[v], w)
						deg[w]++
					}
				}
				continue o
			}
		}
		Fprintln(out, "NO")
		return
	}

	ans := []int{}
	q := []int{}
	for i, d := range deg {
		if d == 0 {
			q = append(q, i)
		}
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		ans = append(ans, v)
		for _, w := range g[v] {
			if deg[w]--; deg[w] == 0 {
				q = append(q, w)
			}
		}
	}

	if len(ans) < n {
		Fprint(out, "NO")
		return
	}
	Fprintln(out, "YES")
	for _, v := range ans {
		Fprint(out, v+1, " ")
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
type trieNode struct {
	son    [27]*trieNode
	val    int
}

type trie struct{ root *trieNode }

func (*trie) ord(c byte) byte { return c - 'a' }

func (t *trie) put(s []byte, val int) {
	o := t.root
	for _, c := range s {
		c = t.ord(c)
		if o.son[c] == nil {
			o.son[c] = &trieNode{}
		}
		o = o.son[c]
	}
	o.val = val
}

func (t *trie) get(s []byte) *trieNode {
	o := t.root
	for _, c := range s {
		o = o.son[t.ord(c)]
		if o == nil {
			return nil
		}
	}
	return o
}

func newTrie() *trie {
	return &trie{&trieNode{}}
}

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

	var n, m, k, mt int
	var s []byte
	Fscan(in, &n, &m, &k)
	t := newTrie()
	for i := 0; i < n; i++ {
		Fscan(in, &s)
		s = bytes.ReplaceAll(s, []byte{'_'}, []byte{'z' + 1})
		t.put(s, i)
	}

	var ids []int
	var f func(p int)
	f = func(p int) {
		if p == k {
			o := t.get(s)
			if o != nil {
				ids = append(ids, o.val)
			}
			return
		}
		f(p + 1)
		tmp := s[p]
		s[p] = 'z' + 1
		f(p + 1)
		s[p] = tmp
	}

	g := make([][]int, n)
	deg := make([]int, n)

	for i := 0; i < m; i++ {
		Fscan(in, &s, &mt)
		mt--

		ids = []int{}
		f(0)
		find := false
		for _, id := range ids {
			if id == mt {
				find = true
				break
			}
		}
		if !find {
			Fprintln(out, "NO")
			return
		}
		for _, id := range ids {
			if id != mt {
				g[mt] = append(g[mt], id)
				deg[id]++
			}
		}
	}

	orders := []int{}
	q := []int{}
	for i, d := range deg {
		if d == 0 {
			q = append(q, i)
		}
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		orders = append(orders, v)
		for _, w := range g[v] {
			if deg[w]--; deg[w] == 0 {
				q = append(q, w)
			}
		}
	}

	if len(orders) < n {
		Fprintln(out, "NO")
		return
	}
	Fprintln(out, "YES")

	for _, v := range orders {
		Fprint(out, v+1, " ")
	}
}

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


Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as pi. For all pairs of distinct integers i, j between 1 and n, he wrote the number ai, j = min(pi, pj). He writes ai, i = 0 for all integer i from 1 to n.Bob gave you all the values of ai, j that he wrote down. Your job is to reconstruct any permutation that could have generated these values. The input will be formed so that it is guaranteed that there is at least one solution that is consistent with the information given.

The first line of the input will contain a single integer n (2 ≤ n ≤ 50). The next n lines will contain the values of ai, j. The j-th number on the i-th line will represent ai, j. The i-th number on the i-th line will be 0. It's guaranteed that ai, j = aj, i and there is at least one solution consistent with the information given.

Print n space separated integers, which represents a permutation that could have generated these values. If there are multiple possible solutions, print any of them.

NoteIn the first case, the answer can be {1, 2} or {2, 1}.In the second case, another possible answer is {2, 4, 5, 1, 3}.

// Турба го в Го
package main

import (
	"fmt"
)

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

func main() {
	var (
		n, i, j, minp int
		p             [50]int
		f             bool
	)
	fmt.Scanf("%d", &n)
	for i = 0; i < n; i++ {
		for p[i], j = 0, 0; j < n; j++ {
			fmt.Scan(&minp)
			p[i] = max(p[i], minp)
		}

	}
	for i, f = 0, true; i < n; i++ {
		if p[i] == n-1 && f {
			p[i], f = p[i]+1, false
		}
		fmt.Printf("%d ", p[i])
	}
	fmt.Printf("\n")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, n)
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}
	res := make([]int, n)
	for c := 1; c < n - 1; c++ {
		for i := range a {
			if res[i] != 0 {
				continue
			}
			good := true
			for _, v := range a[i] {
				if v > c {
					good = false
					break
				}
			}
			if good {
				res[i] = c
				break
			}
		}
	}
	next := n - 1
	for i := range res {
		if res[i] == 0 {
			res[i] = next
			next++
		}
	}
	for i := range res {
		fmt.Print(res[i])
		if i+1 == n {
			fmt.Println()
		} else {
			fmt.Print(" ")
		}
	}
}

package main

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

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

func main() {
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	a := make([][]int, n)
	for i, _ := range a {
		a[i] = make([]int, n)
		for j, _ := range a[i] {
			fmt.Fscan(in, &a[i][j])
		}
	}
	ans := make([]int, n)
	nPos := 0
	for i, _ := range a {
		for x := 1; x <= n; x++ {
			xCount := 0
			for j, _ := range a[i] {
				if a[i][j] == x {
					xCount++
				}
			}
			if xCount == n-x {
				ans[i] = x
				if x == n-1 {
					nPos = i
				}
				break
			}
		}
	}
	ans[nPos] = n
	for i, x := range ans {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x)
	}
	fmt.Fprintln(out)
}

// Турба го в Го
package main

import (
	"fmt"
)

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

func main() {
	var (
		n, i, j, minp int
		p             [50]int
		f             bool
	)
	fmt.Scanf("%d", &n)
	for i = 0; i < n; i++ {
		for p[i], j = 0, 0; j < n; j++ {
			fmt.Scanf("%d", &minp)
			p[i] = max(p[i], minp)
		}
	}
	for i, f = 0, true; i < n; i++ {
		if p[i] == n-1 && f {
			p[i], f = p[i]+1, false
		}
		fmt.Printf("%d ", p[i])
	}
	fmt.Printf("\n")
}

package main

import (
	"bufio"
	"os"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int64 {
	if !in.Scan() {
		panic(in.Err())
	}
	res := int64(0)
	for _, b := range in.Bytes() {
		res = res*10 + int64(b-'0')
	}
	return res
}

func readString() string {
	if !in.Scan() {
		panic(in.Err())
	}
	return in.Text()
}

func main() {
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
}


Iahubina is tired of so many complicated languages, so she decided to invent a new, simple language. She already made a dictionary consisting of n 3-words. A 3-word is a sequence of exactly 3 lowercase letters of the first 24 letters of the English alphabet (a to x). She decided that some of the letters are vowels, and all the others are consonants. The whole language is based on a simple rule: any word that contains at least one vowel is correct.Iahubina forgot which letters are the vowels, and wants to find some possible correct sets of vowels. She asks Iahub questions. In each question, she will give Iahub a set of letters considered vowels (in this question). For each question she wants to know how many words of the dictionary are correct, considering the given set of vowels.Iahubina wants to know the xor of the squared answers to all the possible questions. There are 224 different questions, they are all subsets of the set of the first 24 letters of the English alphabet. Help Iahub find that number.

The first line contains one integer, n (1 ≤ n ≤ 104). Each of the next n lines contains a 3-word consisting of 3 lowercase letters. There will be no two identical 3-words.

Print one number, the xor of the squared answers to the queries.

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
)

func ToBit(s string) (b int) {
	for _, c := range s {
		b |= 1 << uint(c-'a')
	}
	return
}

func main() {
	const m = 1 << 24
	var (
		n   int
		ans int
		f   = make([]int, m)
	)

	fmt.Fscan(reader, &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(reader, &s)
		b := ToBit(s)
		f[b]++
	}

	for j := 2; j <= m; j *= 2 {
		sub := j / 2
		for i := 0; i < m; i += j {
			for k := 0; k < sub; k++ {
				f[i+k+sub] += f[i+k]
			}
		}
	}

	for i := 0; i < m; i++ {
		x := (n - f[i])
		ans ^= x * x
	}
	fmt.Println(ans)
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
)

func ToBit(s string) (b int) {
	for _, c := range s {
		b |= 1 << uint(c-'a')
	}
	return
}

func main() {
	const m = 1 << 24
	var (
		n   int
		ans int
		f   = make([]int, m)
	)

	fmt.Fscan(reader, &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(reader, &s)
		b := ToBit(s)
		f[b]++
	}

	var k int
	for j := 2; j <= m; j *= 2 {
		sub := j / 2
		for i := 0; i < m; i += j {
			for k = 0; k < sub; k++ {
				f[i+k+sub] += f[i+k]
			}
		}
	}

	for i := 0; i < m; i++ {
		x := (n - f[i])
		ans ^= x * x
	}
	fmt.Println(ans)
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
)

func ToBit(s string) (b int) {
	for _, c := range s {
		b |= 1 << uint(c-'a')
	}
	return
}

func main() {
	var (
		n   int
		ans int
		f   = make([]int, 1<<24)
	)

	fmt.Fscan(reader, &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(reader, &s)
		b := ToBit(s)

		for j := b; j > 0; j = (j - 1) & b {
			if ones := strings.Count(strconv.FormatInt(int64(j), 2), "1"); ones%2 == 1 {
				f[j]++
			} else {
				f[j]--
			}
		}
	}

	for j := uint(0); j < 24; j++ {
		for i := 1; i < (1 << 24); i++ {
			if i>>j&1 != 0 {
				f[i] += f[i-(1<<j)]
			}
		}
	}

	for i := 1; i < (1 << 24); i++ {
		ans ^= f[i] * f[i]
	}
	fmt.Println(ans)
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
)

func ToBit(s string) (b int) {
	for _, c := range s {
		b |= 1 << uint(c-'a')
	}
	return
}

func main() {
	var (
		n int
	)

	fmt.Fscan(reader, &n)
	dict := make([]int, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(reader, &s)
		dict[i] = ToBit(s)
	}

	ans := 0
	for i := 0; i < (1 << 24); i++ {
		s := 0
		for _, j := range dict {
			if (i & j) != 0 {
				s++
			}
		}
		ans ^= s
	}
	fmt.Println(ans)
}


Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her hand one or several camomiles and tears off the petals one by one. After each petal she pronounces alternatively "Loves" and "Doesn't love", at that Marina always starts with "Loves". There are n camomiles growing in the field, possessing the numbers of petals equal to a1, a2, ... an. Marina wants to pick a bouquet with the maximal possible total number of petals so that the result would still be "Loves". Help her do that; find the maximal number of petals possible in the bouquet.

The first line contains an integer n (1 ≤ n ≤ 100), which is the number of flowers growing in the field. The second line contains n integers ai (1 ≤ ai ≤ 100) which represent the number of petals on a given i-th camomile.

Print a single number which is the maximal number of petals in the bouquet, the fortune telling on which would result in "Loves". If there are no such bouquet, print 0 instead. The bouquet may consist of a single flower.

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	result := 0
	arr := make([]int, n)
	for i := range arr {
		arr[i] = scanInt(scanner)
		result += arr[i]
	}
	if result%2 == 0 {
		sort.Ints(arr)
		for _, x := range arr {
			if x%2 == 1 {
				result -= x
				break
			}
		}
	}
	if result%2 == 1 {
		writer.WriteString(fmt.Sprintf("%d\n", result))
	} else {
		writer.WriteString("0\n")
	}
}


Recently Vladik discovered a new entertainment — coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them.At first, he need to download t chats. Vladik coded a script which should have downloaded the chats, however, something went wrong. In particular, some of the messages have no information of their sender. It is known that if a person sends several messages in a row, they all are merged into a single message. It means that there could not be two or more messages in a row with the same sender. Moreover, a sender never mention himself in his messages.Vladik wants to recover senders of all the messages so that each two neighboring messages will have different senders and no sender will mention himself in his messages.He has no idea of how to do this, and asks you for help. Help Vladik to recover senders in each of the chats!

The first line contains single integer t (1 ≤ t ≤ 10) — the number of chats. The t chats follow. Each chat is given in the following format. The first line of each chat description contains single integer n (1 ≤ n ≤ 100) — the number of users in the chat. The next line contains n space-separated distinct usernames. Each username consists of lowercase and uppercase English letters and digits. The usernames can't start with a digit. Two usernames are different even if they differ only with letters' case. The length of username is positive and doesn't exceed 10 characters. The next line contains single integer m (1 ≤ m ≤ 100) — the number of messages in the chat. The next m line contain the messages in the following formats, one per line:    <username>:<text> — the format of a message with known sender. The username should appear in the list of usernames of the chat.  <?>:<text> — the format of a message with unknown sender.  The text of a message can consist of lowercase and uppercase English letter, digits, characters '.' (dot), ',' (comma), '!' (exclamation mark), '?' (question mark) and ' ' (space). The text doesn't contain trailing spaces. The length of the text is positive and doesn't exceed 100 characters. We say that a text mention a user if his username appears in the text as a word. In other words, the username appears in a such a position that the two characters before and after its appearance either do not exist or are not English letters or digits. For example, the text "Vasya, masha13 and Kate!" can mention users "Vasya", "masha13", "and" and "Kate", but not "masha". It is guaranteed that in each chat no known sender mention himself in his messages and there are no two neighboring messages with the same known sender.

Print the information about the t chats in the following format: If it is not possible to recover senders, print single line "Impossible" for this chat. Otherwise print m messages in the following format: <username>:<text> If there are multiple answers, print any of them.

1
2
Vladik netman
2
?: Hello, Vladik!
?: Hi

1
2
netman vladik
3
netman:how are you?
?:wrong message
vladik:im fine

2
3
netman vladik Fedosik
2
?: users are netman, vladik, Fedosik
vladik: something wrong with this chat
4
netman tigerrrrr banany2001 klinchuh
4
?: tigerrrrr, banany2001, klinchuh, my favourite team ever, are you ready?
klinchuh: yes, coach!
?: yes, netman
banany2001: yes of course.

Impossible
netman: tigerrrrr, banany2001, klinchuh, my favourite team ever, are you ready?
klinchuh: yes, coach!
tigerrrrr: yes, netman
banany2001: yes of course.

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	id := 0
	people := make(map[string]int)
	for _, v := range strings.Split(readString(), " ") {
		people[v] = id
		id++
	}
	cnt := readInt()
	messages := make([]message, cnt)
	re := regexp.MustCompile("[ ,!\\?\\.]+")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range re.Split(p[1], -1) {
			if _, ok := people[v]; ok {
				users[v] = true
			}
		}
		messages[j] = message{p[0], p[1], users}
	}
	for i := 0; i < len(people); i++ {
		for j := 0; j < len(messages); j++ {
			if messages[j].from == "?" {
				if j-1 >= 0 && messages[j-1].from != "?" {
					u := messages[j-1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
					}
				}
				if j+1 < len(messages) && messages[j+1].from != "?" {
					u := messages[j+1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
					}
				}

				if len(messages[j].users) >= len(people) {
					fmt.Println("Impossible")
					return
				}
				if len(messages[j].users)+1 == len(people) {
					for p := range people {
						if _, ok := messages[j].users[p]; !ok {
							messages[j].from = p
							break
						}
					}
				}
			} else {
				if j-1 >= 0 && messages[j-1].from == messages[j].from {
					fmt.Println("Impossible")
					return
				}
				if j+1 < len(messages) && messages[j+1].from == messages[j].from {
					fmt.Println("Impossible")
					return
				}
				if _, ok := messages[j].users[messages[j].from]; ok {
					fmt.Println("Impossible")
					return
				}
			}
		}
	}
	for i := 0; i < len(messages); i++ {
		if messages[i].from == "?" {
			for p := range people {
				if _, ok := messages[i].users[p]; !ok {
					messages[i].from = p
					if i+1 < len(messages) {
						messages[i+1].users[p] = true
					}
					break
				}
			}
		}
	}
	for _, v := range messages {
		fmt.Printf("%s:%s\n", v.from, v.text)
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	id := 0
	people := make(map[string]int)
	for _, v := range strings.Split(readString(), " ") {
		people[v] = id
		id++
	}
	cnt := readInt()
	messages := make([]message, cnt)
	re := regexp.MustCompile("[ ,!\\?\\.]+")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range re.Split(p[1], -1) {
			if _, ok := people[v]; ok {
				users[v] = true
			}
		}
		messages[j] = message{p[0], p[1], users}
	}
	for {
		changes := 0
		for j := 0; j < len(messages); j++ {
			if messages[j].from == "?" {
				if j-1 >= 0 && messages[j-1].from != "?" {
					u := messages[j-1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
						changes++
					}
				}
				if j+1 < len(messages) && messages[j+1].from != "?" {
					u := messages[j+1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
						changes++
					}
				}

				if len(messages[j].users) >= len(people) {
					fmt.Println("Impossible")
					return
				}
				if len(messages[j].users)+1 == len(people) {
					for p := range people {
						if _, ok := messages[j].users[p]; !ok {
							messages[j].from = p
							changes++
							break
						}
					}
				}
			} else {
				if j-1 >= 0 && messages[j-1].from == messages[j].from {
					fmt.Println("Impossible")
					return
				}
				if j+1 < len(messages) && messages[j+1].from == messages[j].from {
					fmt.Println("Impossible")
					return
				}
				if _, ok := messages[j].users[messages[j].from]; ok {
					fmt.Println("Impossible")
					return
				}
			}
		}

		if changes == 0 {
			break
		}
	}
	for i := 0; i < len(messages); i++ {
		if messages[i].from == "?" {
			for p := range people {
				if _, ok := messages[i].users[p]; !ok {
					messages[i].from = p
					break
				}
			}
		}
	}
	for _, v := range messages {
		fmt.Printf("%s:%s\n", v.from, v.text)
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	re := regexp.MustCompile("^([^:]+):(.*)$")
	readInt()
	people := strings.Split(readString(), " ")
	cnt := readInt()
	messages := make([]message, cnt)
	reP := regexp.MustCompile("(" + strings.Join(people, ")|(") + ")")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := re.FindStringSubmatch(line)
		users := make(map[string]bool)
		for _, v := range reP.FindAllString(p[2], -1) {
			users[v] = true
		}
		messages[j] = message{p[1], p[2], users}
	}
	for {
		changes := 0
		for j := 0; j < len(messages)-1; j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j+1].users[messages[j].from]; !ok {
					messages[j+1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j := 1; j < len(messages); j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j-1].users[messages[j].from]; !ok {
					messages[j-1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j, v := range messages {
			if v.from == "?" && len(v.users)+1 == len(people) {
				for _, p := range people {
					if _, ok := v.users[p]; !ok {
						messages[j].from = p
						changes++
						break
					}
				}
			}
		}
		if changes == 0 {
			break
		}
	}
	ok := true
	for _, v := range messages {
		if v.from == "?" {
			ok = false
			break
		}
	}
	if ok {
		for _, v := range messages {
			fmt.Printf("%s:%s\n", v.from, v.text)
		}
	} else {
		fmt.Println("Impossible")
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	people := make(map[string]bool)
	for _, v := range strings.Split(readString(), " ") {
		people[v] = true
	}
	cnt := readInt()
	messages := make([]message, cnt)
	re := regexp.MustCompile("[\\s?!,.]+")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range re.Split(p[1], -1) {
			if _, ok := people[v]; ok {
				users[v] = true
			}
		}
		messages[j] = message{p[0], p[1], users}
	}
	for {
		changes := 0
		for j := 0; j < len(messages)-1; j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j+1].users[messages[j].from]; !ok {
					messages[j+1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j := 1; j < len(messages); j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j-1].users[messages[j].from]; !ok {
					messages[j-1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j, v := range messages {
			if v.from == "?" && len(v.users)+1 == len(people) {
				for p := range people {
					if _, ok := v.users[p]; !ok {
						messages[j].from = p
						changes++
						break
					}
				}
			}
		}
		if changes == 0 {
			break
		}
	}
	ok := true
	for _, v := range messages {
		if v.from == "?" {
			ok = false
			break
		}
	}
	if ok {
		for _, v := range messages {
			fmt.Printf("%s:%s\n", v.from, v.text)
		}
	} else {
		fmt.Println("Impossible")
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	id := 0
	people := make(map[string]int)
	for _, v := range strings.Split(readString(), " ") {
		people[v] = id
		id++
	}
	cnt := readInt()
	messages := make([]message, cnt)
	re := regexp.MustCompile("[ ,!\\?\\.]+")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range re.Split(p[1], -1) {
			if _, ok := people[v]; ok {
				users[v] = true
			}
		}
		messages[j] = message{p[0], p[1], users}
	}
	for i := 0; i < len(people); i++ {
		for j := 0; j < len(messages); j++ {
			if messages[j].from == "?" {
				if j-1 >= 0 && messages[j-1].from != "?" {
					u := messages[j-1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
					}
				}
				if j+1 < len(messages) && messages[j+1].from != "?" {
					u := messages[j+1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
					}
				}

				if len(messages[j].users) >= len(people) {
					fmt.Println("Impossible")
					return
				}
				if len(messages[j].users)+1 == len(people) {
					for p := range people {
						if _, ok := messages[j].users[p]; !ok {
							messages[j].from = p
							break
						}
					}
				}
			} else {
				if j-1 >= 0 && messages[j-1].from == messages[j].from {
					fmt.Println("Impossible")
					return
				}
				if j+1 < len(messages) && messages[j+1].from == messages[j].from {
					fmt.Println("Impossible")
					return
				}
				if _, ok := messages[j].users[messages[j].from]; ok {
					fmt.Println("Impossible")
					return
				}
			}
		}
	}
	for i := 0; i < len(messages); i++ {
		if messages[i].from == "?" {
			for p := range people {
				if _, ok := messages[i].users[p]; !ok {
					messages[i].from = p
					break
				}
			}
		}
	}
	for _, v := range messages {
		fmt.Printf("%s:%s\n", v.from, v.text)
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	people := make(map[string]bool)
	for _, v := range strings.Split(readString(), " ") {
		people[v] = true
	}
	cnt := readInt()
	messages := make([]message, cnt)
	re := regexp.MustCompile("[ ,!\\?\\.]+")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range re.Split(p[1], -1) {
			if _, ok := people[v]; ok {
				users[v] = true
			}
		}
		messages[j] = message{p[0], p[1], users}
	}
	for {
		changes := 0
		for j := 0; j < len(messages)-1; j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j+1].users[messages[j].from]; !ok {
					messages[j+1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j := 1; j < len(messages); j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j-1].users[messages[j].from]; !ok {
					messages[j-1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j, v := range messages {
			if v.from == "?" && len(v.users)+1 == len(people) {
				for p := range people {
					if _, ok := v.users[p]; !ok {
						messages[j].from = p
						changes++
						break
					}
				}
			}
		}
		if changes == 0 {
			break
		}
	}
	ok := true
	for _, v := range messages {
		if v.from == "?" {
			ok = false
			break
		}
	}
	if ok {
		for _, v := range messages {
			fmt.Printf("%s:%s\n", v.from, v.text)
		}
	} else {
		fmt.Println("Impossible")
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	id := 0
	people := make(map[string]int)
	for _, v := range strings.Split(readString(), " ") {
		people[v] = id
		id++
	}
	cnt := readInt()
	messages := make([]message, cnt)
	re := regexp.MustCompile("[ ,!\\?\\.]+")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range re.Split(p[1], -1) {
			if _, ok := people[v]; ok {
				users[v] = true
			}
		}
		messages[j] = message{p[0], p[1], users}
	}
	for {
		changes := 0
		for j := 0; j < len(messages); j++ {
			if messages[j].from == "?" {
				if j-1 >= 0 && messages[j-1].from != "?" {
					u := messages[j-1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
						changes++
					}
				}
				if j+1 < len(messages) && messages[j+1].from != "?" {
					u := messages[j+1].from
					if _, ok := messages[j].users[u]; !ok {
						messages[j].users[u] = true
						changes++
					}
				}
			}
		}
		for j, v := range messages {
			if v.from == "?" && len(v.users)+1 == len(people) {
				for p := range people {
					if _, ok := v.users[p]; !ok {
						messages[j].from = p
						changes++
						break
					}
				}
			}
		}
		if changes == 0 {
			break
		}
	}
	ok := true
	for _, v := range messages {
		if v.from == "?" {
			ok = false
			break
		}
	}
	if ok {
		for _, v := range messages {
			fmt.Printf("%s:%s\n", v.from, v.text)
		}
	} else {
		fmt.Println("Impossible")
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type message struct {
	from  string
	text  string
	users map[string]bool
}

var scanner *bufio.Scanner

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveTest()
	}
}

func solveTest() {
	readInt()
	people := strings.Split(readString(), " ")
	cnt := readInt()
	messages := make([]message, cnt)
	reP := regexp.MustCompile("(" + strings.Join(people, ")|(") + ")")
	for j := 0; j < cnt; j++ {
		line := readString()
		p := strings.SplitN(line, ":", 2)
		users := make(map[string]bool)
		for _, v := range reP.FindAllString(p[1], -1) {
			users[v] = true
		}
		messages[j] = message{p[0], p[1], users}
	}
	for {
		changes := 0
		for j := 0; j < len(messages)-1; j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j+1].users[messages[j].from]; !ok {
					messages[j+1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j := 1; j < len(messages); j++ {
			if messages[j].from != "?" {
				if _, ok := messages[j-1].users[messages[j].from]; !ok {
					messages[j-1].users[messages[j].from] = true
					changes++
				}
			}
		}
		for j, v := range messages {
			if v.from == "?" && len(v.users)+1 == len(people) {
				for _, p := range people {
					if _, ok := v.users[p]; !ok {
						messages[j].from = p
						changes++
						break
					}
				}
			}
		}
		if changes == 0 {
			break
		}
	}
	ok := true
	for _, v := range messages {
		if v.from == "?" {
			ok = false
			break
		}
	}
	if ok {
		for _, v := range messages {
			fmt.Printf("%s:%s\n", v.from, v.text)
		}
	} else {
		fmt.Println("Impossible")
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	//	scanner.Split(bufio.ScanWords)
	solve()
}

//
// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}


Alice got a new doll these days. It can even walk!Alice has built a maze for the doll and wants to test it. The maze is a grid with $$$n$$$ rows and $$$m$$$ columns. There are $$$k$$$ obstacles, the $$$i$$$-th of them is on the cell $$$(x_i, y_i)$$$, which means the cell in the intersection of the $$$x_i$$$-th row and the $$$y_i$$$-th column.However, the doll is clumsy in some ways. It can only walk straight or turn right at most once in the same cell (including the start cell). It cannot get into a cell with an obstacle or get out of the maze.More formally, there exist $$$4$$$ directions, in which the doll can look:  The doll looks in the direction along the row from the first cell to the last. While moving looking in this direction the doll will move from the cell $$$(x, y)$$$ into the cell $$$(x, y + 1)$$$;  The doll looks in the direction along the column from the first cell to the last. While moving looking in this direction the doll will move from the cell $$$(x, y)$$$ into the cell $$$(x + 1, y)$$$;  The doll looks in the direction along the row from the last cell to first. While moving looking in this direction the doll will move from the cell $$$(x, y)$$$ into the cell $$$(x, y - 1)$$$;  The doll looks in the direction along the column from the last cell to the first. While moving looking in this direction the doll will move from the cell $$$(x, y)$$$ into the cell $$$(x - 1, y)$$$. .Standing in some cell the doll can move into the cell in the direction it looks or it can turn right once. Turning right once, the doll switches it's direction by the following rules: $$$1 \to 2$$$, $$$2 \to 3$$$, $$$3 \to 4$$$, $$$4 \to 1$$$. Standing in one cell, the doll can make at most one turn right.Now Alice is controlling the doll's moves. She puts the doll in of the cell $$$(1, 1)$$$ (the upper-left cell of the maze). Initially, the doll looks to the direction $$$1$$$, so along the row from the first cell to the last. She wants to let the doll walk across all the cells without obstacles exactly once and end in any place. Can it be achieved?

The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$, separated by spaces ($$$1 \leq n,m \leq 10^5, 0 \leq k \leq 10^5$$$) — the size of the maze and the number of obstacles. Next $$$k$$$ lines describes the obstacles, the $$$i$$$-th line contains two integer numbers $$$x_i$$$ and $$$y_i$$$, separated by spaces ($$$1 \leq x_i \leq n,1 \leq y_i \leq m$$$), which describes the position of the $$$i$$$-th obstacle. It is guaranteed that no two obstacles are in the same cell and no obstacle is in cell $$$(1, 1)$$$.

Print 'Yes' (without quotes) if the doll can walk across all the cells without obstacles exactly once by the rules, described in the statement. If it is impossible to walk across the maze by these rules print 'No' (without quotes).

NoteHere is the picture of maze described in the first example:    In the first example, the doll can walk in this way:  The doll is in the cell $$$(1, 1)$$$, looks to the direction $$$1$$$. Move straight;  The doll is in the cell $$$(1, 2)$$$, looks to the direction $$$1$$$. Move straight;  The doll is in the cell $$$(1, 3)$$$, looks to the direction $$$1$$$. Turn right;  The doll is in the cell $$$(1, 3)$$$, looks to the direction $$$2$$$. Move straight;  The doll is in the cell $$$(2, 3)$$$, looks to the direction $$$2$$$. Move straight;  The doll is in the cell $$$(3, 3)$$$, looks to the direction $$$2$$$. Turn right;  The doll is in the cell $$$(3, 3)$$$, looks to the direction $$$3$$$. Move straight;  The doll is in the cell $$$(3, 2)$$$, looks to the direction $$$3$$$. Move straight;  The doll is in the cell $$$(3, 1)$$$, looks to the direction $$$3$$$. The goal is achieved, all cells of the maze without obstacles passed exactly once.

package main

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

var n, m, k, nn, mm int
var a map[int]map[int]bool = make(map[int]map[int]bool)
var b map[int]map[int]bool = make(map[int]map[int]bool)

func culc1(x, y int) (ok, end bool, xx, yy int) {
	if m < mm {
		return true, true, 0, 0
	}
	if haveA, have := a[x]; have {
		miny := m + 1
		num := 0
		for ay, _ := range haveA {
			if ay >= mm && ay <= m {
				miny = min(ay, miny)
				num++
			}
		}

		if num+miny != m+1 {
			return false, true, 0, 0
		}

		for i := miny; i <= m; i++ {
			numx := 0
			for ax, _ := range b[i] {
				if ax >= nn && ax <= n {
					numx++
				}
			}
			if numx+nn != n+1 {
				return false, true, 0, 0
			}
		}
		return true, false, x, miny - 1
	}

	return true, false, x, m
}

func culc2(x, y int) (ok, end bool, xx, yy int) {
	if n < nn {
		return true, true, 0, 0
	}

	if haveA, have := b[y]; have {
		minx := n + 1
		numx := 0
		for ax, _ := range haveA {
			if ax >= x && ax <= n {
				minx = min(ax, minx)
				numx++
			}
		}

		if numx+minx != n+1 {
			return false, true, 0, 0
		}

		for i := minx; i <= n; i++ {
			numy := 0
			for ay, _ := range a[i] {
				if ay >= mm && ay <= m {
					numy++
				}
			}
			if numy+mm != m+1 {
				return false, true, 0, 0
			}
		}
		return true, false, minx - 1, y
	}

	return true, false, n, m
}

func culc3(x, y int) (ok, end bool, xx, yy int) {
	if m < mm {
		return true, true, 0, 0
	}

	if haveA, have := a[x]; have {
		maxy := mm - 1
		num := 0
		for ay, _ := range haveA {
			if ay >= mm && ay <= m {
				maxy = max(ay, maxy)
				num++
			}
		}

		if maxy+1 != mm+num {
			return false, true, 0, 0
		}

		for i := mm; i <= maxy; i++ {
			numx := 0
			for ax, _ := range b[i] {
				if ax >= nn && ax <= n {
					numx++
				}
			}
			if numx+nn != n+1 {
				return false, true, 0, 0
			}
		}
		return true, false, x, maxy + 1
	}

	return true, false, n, mm
}

func culc4(x, y int) (ok, end bool, xx, yy int) {
	if n < nn {
		return true, true, 0, 0
	}

	if haveA, have := b[y]; have {
		maxx := nn - 1
		num := 0
		for ax, _ := range haveA {
			if ax >= nn && ax <= n {
				maxx = max(ax, maxx)
				num++
			}
		}

		if maxx+1 != nn+num {
			return false, true, 0, 0
		}

		for i := nn; i <= maxx; i++ {
			numy := 0
			for ay, _ := range a[i] {
				if ay >= mm && ay <= m {
					numy++
				}
			}
			if numy+mm != m+1 {
				return false, true, 0, 0
			}
		}
		return true, false, maxx + 1, y
	}

	return true, false, nn, y
}

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

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

func main() {

	reader := bufio.NewReader(os.Stdin)

	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &k)

	var x, y int
	for i := 1; i <= k; i++ {
		fmt.Fscanf(reader, "%d %d\n", &x, &y)
		if _, ok := a[x]; !ok {
			a[x] = make(map[int]bool)
		}

		if _, ok := b[y]; !ok {
			b[y] = make(map[int]bool)
		}

		a[x][y] = true
		b[y][x] = true
	}

	x = 1
	y = 1
	nn = 1
	mm = 1
	ok := true
	end := false
	for ok && !end {
		ok, end, x, y = culc1(x, y)
		//fmt.Println("culc1", ok, end, x, y)
		if !ok || end {
			break
		}
		m = y
		nn++

		ok, end, x, y = culc2(x, y)
		//fmt.Println("culc2", ok, end, x, y)
		if !ok || end {
			break
		}

		m--
		n = x

		ok, end, x, y = culc3(x, y)
		//fmt.Println("culc3", ok, end, x, y)
		if !ok || end {
			break
		}

		n--
		mm = y

		ok, end, x, y = culc4(x, y)
		//fmt.Println("culc4", ok, end, x, y)
		if !ok || end {
			break
		}

		mm++
		nn = x
	}

	if ok {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}