This is an interactive problem!An arithmetic progression or arithmetic sequence is a sequence of integers such that the subtraction of element with its previous element ($$$x_i - x_{i - 1}$$$, where $$$i \ge 2$$$) is constant — such difference is called a common difference of the sequence.That is, an arithmetic progression is a sequence of form $$$x_i = x_1 + (i - 1) d$$$, where $$$d$$$ is a common difference of the sequence.There is a secret list of $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$.It is guaranteed that all elements $$$a_1, a_2, \ldots, a_n$$$ are between $$$0$$$ and $$$10^9$$$, inclusive.This list is special: if sorted in increasing order, it will form an arithmetic progression with positive common difference ($$$d > 0$$$). For example, the list $$$[14, 24, 9, 19]$$$ satisfies this requirement, after sorting it makes a list $$$[9, 14, 19, 24]$$$, which can be produced as $$$x_n = 9 + 5 \cdot (n - 1)$$$.Also you are also given a device, which has a quite discharged battery, thus you can only use it to perform at most $$$60$$$ queries of following two types: Given a value $$$i$$$ ($$$1 \le i \le n$$$), the device will show the value of the $$$a_i$$$. Given a value $$$x$$$ ($$$0 \le x \le 10^9$$$), the device will return $$$1$$$ if an element with a value strictly greater than $$$x$$$ exists, and it will return $$$0$$$ otherwise.Your can use this special device for at most $$$60$$$ queries. Could you please find out the smallest element and the common difference of the sequence? That is, values $$$x_1$$$ and $$$d$$$ in the definition of the arithmetic progression. Note that the array $$$a$$$ is not sorted.

NoteNote that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.The list in the example test is $$$[14, 24, 9, 19]$$$.

package main

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

const bufSize = 8192

var (
	stdin, stdout bytes.Buffer
	newlines      int
)

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

func scan(a interface{}) {
	for newlines == 0 {
		fileInfo, _ := os.Stdin.Stat()
		p := make([]byte, max(int(fileInfo.Size()), bufSize))
		_, err := os.Stdin.Read(p)
		if err != nil {
			break
		}

		stdin.Write(p)
		for _, b := range p {
			if b == '\n' {
				newlines++
			}
		}
	}

	fmt.Fscan(&stdin, a)
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

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

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		fmt.Scan(&y)

		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		fmt.Scan(&y)

		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}

package main

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

const bufSize = 8192

var (
	stdin, stdout bytes.Buffer
	newspaces     int
)

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

func scan(a interface{}) {
	_, err := fmt.Fscan(&stdin, a)
	if err != nil {
		for err = nil; err == nil; {
			fileInfo, _ := os.Stdin.Stat()
			p := make([]byte, max(int(fileInfo.Size()), bufSize))
			_, err = os.Stdin.Read(p)
		}

		fmt.Fscan(&stdin, a)
	}
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

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

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		fmt.Scan(&y)

		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		fmt.Scan(&y)

		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}

package main

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

const bufSize = 8192

var stdin, stdout bytes.Buffer

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

func scan(a interface{}) {
	for p, err := []byte{}, *new(error); err == nil; stdin.Write(p) {
		fileInfo, _ := os.Stdin.Stat()
		p := make([]byte, max(int(fileInfo.Size()), bufSize))
		_, err = os.Stdin.Read(p)
	}

	fmt.Fscan(&stdin, a)
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

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

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		fmt.Scan(&y)

		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		fmt.Scan(&y)

		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}

package main

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

const bufSize = 8192

var stdin, stdout bytes.Buffer

// func init() {
// 	fileInfo, _ := os.Stdin.Stat()
// 	p := make([]byte, int(fileInfo.Size())+1)
// 	os.Stdin.Read(p)
// 	stdin.Write(p)
// }

func scan(a interface{}) {
	fmt.Fscan(os.Stdin, a)
	// for _, err := fmt.Fscan(&stdin, a); err != nil; _, err = fmt.Fscan(&stdin, a) {
	// 	p := make([]byte, int(bufSize))
	// 	os.Stdin.Read(p)
	// 	stdin.Write(p)
	// }
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func main() {
	var n int
	scan(&n)

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		scan(&y)
		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		scan(&y)
		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}

package main

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

const bufSize = 8192

var (
	stdin, stdout bytes.Buffer
	isBuffered    bool
)

func scan(a interface{}) {
	if !isBuffered {
		fileInfo, _ := os.Stdin.Stat()
		p := make([]byte, int(fileInfo.Size())+1)
		os.Stdin.Read(p)
		stdin.Write(p)

		isBuffered = true
	}

	fmt.Fscan(&stdin, a)
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func main() {
	var n int
	scan(&n)

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		isBuffered = false
		scan(&y)
		print(y)

		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		isBuffered = false
		scan(&y)

		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}

package main

import (
	"bytes"
	"fmt"
	"math/rand"
	"os"
	"time"
)

const bufSize = 8192

var (
	stdin, stdout bytes.Buffer
	isBuffered    bool
)

func scan(a interface{}) {
	if !isBuffered {
		fileInfo, _ := os.Stdin.Stat()
		p := make([]byte, int(fileInfo.Size())+1)
		os.Stdin.Read(p)
		stdin.Write(p)

		isBuffered = true
	}

	fmt.Fscan(&stdin, a)
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func main() {
	var n int
	scan(&n)

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		isBuffered = false
		time.Sleep(10 * time.Millisecond)
		scan(&y)
		print(y)

		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		isBuffered = false
		scan(&y)

		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}

package main

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

const bufSize = 8192

var (
	stdin, stdout bytes.Buffer
	isBuffered    bool
)

func scan(a interface{}) {
	if !isBuffered {
		p := make([]byte, 8192)
		os.Stdin.Read(p)
		stdin.Write(p)

		isBuffered = true
	}

	fmt.Fscan(&stdin, a)
}

func print(a ...interface{}) {
	fmt.Fprint(&stdout, a...)
}

func flush() {
	os.Stdout.Write(stdout.Bytes())
	stdout.Reset()
}

func abs(x int) int {
	if x > 0 {
		return x
	}

	return -x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func main() {
	var n int
	scan(&n)

	lo, hi := 0, 1000000000
	for lo < hi {
		mi := (lo + hi) / 2
		print("> ", mi)
		print("\n")
		flush()
		var y int
		isBuffered = false
		scan(&y)

		if y == 0 {
			hi = mi
		} else {
			lo = mi + 1
		}
	}

	x := []int{lo}
	for i := 0; i < 30; i++ {
		print("? ", rand.Intn(n)+1)
		print("\n")
		flush()

		var y int
		isBuffered = false
		scan(&y)

		x = append(x, y)
	}

	d := 0
	for _, y := range x {
		for _, z := range x {
			d = gcd(d, abs(y-z))
		}
	}

	print("! ", lo-(n-1)*d, d)
	print("\n")
	flush()
}


A PIN code is a string that consists of exactly $$$4$$$ digits. Examples of possible PIN codes: 7013, 0000 and 0990. Please note that the PIN code can begin with any digit, even with 0.Polycarp has $$$n$$$ ($$$2 \le n \le 10$$$) bank cards, the PIN code of the $$$i$$$-th card is $$$p_i$$$.Polycarp has recently read a recommendation that it is better to set different PIN codes on different cards. Thus he wants to change the minimal number of digits in the PIN codes of his cards so that all $$$n$$$ codes would become different.Formally, in one step, Polycarp picks $$$i$$$-th card ($$$1 \le i \le n$$$), then in its PIN code $$$p_i$$$ selects one position (from $$$1$$$ to $$$4$$$), and changes the digit in this position to any other. He needs to change the minimum number of digits so that all PIN codes become different.Polycarp quickly solved this problem. Can you solve it?

The first line contains integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then test cases follow. The first line of each of $$$t$$$ test sets contains a single integer $$$n$$$ ($$$2 \le n \le 10$$$) — the number of Polycarp's bank cards. The next $$$n$$$ lines contain the PIN codes $$$p_1, p_2, \dots, p_n$$$ — one per line. The length of each of them is $$$4$$$. All PIN codes consist of digits only.

Print the answers to $$$t$$$ test sets. The answer to each set should consist of a $$$n + 1$$$ lines In the first line print $$$k$$$ — the least number of changes to make all PIN codes different. In the next $$$n$$$ lines output the changed PIN codes in the order corresponding to their appearance in the input. If there are several optimal answers, print any of them.

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

// 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 *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// 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 *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

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

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

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

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

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

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

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

var t int
var n int
var P [][]rune

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		n = ReadInt()

		P = [][]rune{}
		for i := 0; i < n; i++ {
			row := ReadRuneSlice()
			P = append(P, row)
		}

		solve()
	}
}

var used [10]int

func solve() {
	num := 0
	used = [10]int{}

	for i := 0; i < n; i++ {
		used[P[i][3]-'0'] = 1
	}

	for i := 0; i < n; i++ {
		A := P[i]
		// 直前のものすべてと比較する
		// OUTER:
		for j := 0; j < i; j++ {
			B := P[j]
			// 等しいものがあればAの最上位桁を未使用のものに変更
			if isEqual(A, B) {
				// for i := 0; i < 10; i++ {
				// 	// 未使用のものを選ぶ
				// 	if used[i] == 0 {
				// 		A[3] = rune(i) + '0'
				// 		num++
				// 		used[i] = 1 // 使用済み
				// 		// break OUTER
				// 		break
				// 	}
				// }
				u := findMinUnused()
				A[3] = rune(u) + '0'
				num++
				used[u] = 1
				break
			} else {
				// 前のものと異なるなら何もしなくて良い
				continue
			}
		}

		// ループを抜けたときのAの最上位桁は必ず使用済み
		used[A[3]-'0'] = 1
	}

	fmt.Println(num)
	for i := 0; i < n; i++ {
		fmt.Println(string(P[i]))
	}
}

func findMinUnused() int {
	for i := 0; i < 10; i++ {
		if used[i] == 0 {
			return i
		}
	}
	return -1
}

func isEqual(a, b []rune) bool {
	for i := 0; i < 4; i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

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

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

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

// 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 *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// 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 *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

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

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

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

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

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

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

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

var t int
var n int
var P [][]rune

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		n = ReadInt()

		P = [][]rune{}
		for i := 0; i < n; i++ {
			row := ReadRuneSlice()
			P = append(P, row)
		}

		solve()
	}
}

var used [10]int

func solve() {
	num := 0
	used = [10]int{}

	for i := 0; i < n; i++ {
		used[P[i][3]-'0'] = 1
	}

	for i := 0; i < n; i++ {
		A := P[i]
		// 直前のものすべてと比較する
		// OUTER:
		for j := 0; j < i; j++ {
			B := P[j]
			// 等しいものがあればAの最上位桁を未使用のものに変更
			if isEqual(A, B) {
				// for i := 0; i < 10; i++ {
				// 	// 未使用のものを選ぶ
				// 	if used[i] == 0 {
				// 		A[3] = rune(i) + '0'
				// 		num++
				// 		used[i] = 1 // 使用済み
				// 		// break OUTER
				// 		break
				// 	}
				// }
				u := findMinUnused()
				A[3] = rune(u) + '0'
				num++
				used[u] = 1
				break
			} else {
				// 前のものと異なるなら何もしなくて良い
				continue
			}
		}

		// ループを抜けたときのAの最上位桁は必ず使用済み
		// used[A[3]-'0'] = 1
	}

	fmt.Println(num)
	for i := 0; i < n; i++ {
		fmt.Println(string(P[i]))
	}
}

func findMinUnused() int {
	for i := 0; i < 10; i++ {
		if used[i] == 0 {
			return i
		}
	}
	return -1
}

func isEqual(a, b []rune) bool {
	for i := 0; i < 4; i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

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

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

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for ; testCount > 0; testCount-- {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)

		fMap := make(map[string]int, n)
		arr := make([]string, n)

		for t := 0; t < n; t++ {
			pin := ""
			fmt.Fscanf(in, "%s\n", &pin)

			arr[t] = pin
			fMap[pin]++
		}

		PINCodes(arr, fMap)
	}
}

func PINCodes(arr []string, fMap map[string]int) {
	// print sum
	changeCount := 0
	for _, v := range fMap {
		changeCount += (v - 1)
	}
	fmt.Println(changeCount)

	// changed pin
	visited := make(map[string]bool)
	for i := 0; i < len(arr); i++ {
		if !visited[arr[i]] {
			fmt.Println(arr[i])
			visited[arr[i]] = true
		} else {
			newPin := arr[i]
			for fMap[newPin] > 0 {
				firstDigit, _ := strconv.Atoi(string(newPin[0]))
				firstDigit = (firstDigit + 1) % 10
				newPin = strconv.Itoa(firstDigit) + newPin[1:]
			}
			fMap[newPin]++
			fmt.Println(newPin)

		}
		//fMap[arr[i]]--
	}
}

package main

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

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

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

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

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

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

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return 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
}

func ReadStringSlice(n int) []string {
	b := make([]string, n)
	for i := 0; i < n; i++ {
		b[i] = ReadString()
		fMap[b[i]]++
	}
	return b
}

var t int
var n int
var arr []string
var fMap map[string]int
var output strings.Builder

func main() {
	t = ReadInt()

	for ; t > 0; t-- {
		n = ReadInt()
		fMap = nil
		fMap = make(map[string]int)

		arr = ReadStringSlice(n)

		solve()
	}
}

func solve() {
	output.Reset()
	output.Grow(10 * n)

	changeCount := 0
	for _, v := range fMap {
		changeCount += (v - 1)
	}
	output.WriteString(strconv.Itoa(changeCount) + "\n")

	// changed pin
	visited := make(map[string]bool)
	for i := 0; i < n; i++ {
		if !visited[arr[i]] {
			output.WriteString(arr[i] + "\n")
			visited[arr[i]] = true
		} else {
			newPin := arr[i]
			for fMap[newPin] > 0 {
				firstDigit, _ := strconv.Atoi(string(newPin[0]))
				firstDigit = (firstDigit + 1) % 10
				newPin = strconv.Itoa(firstDigit) + newPin[1:]
			}
			fMap[newPin]++
			output.WriteString(newPin + "\n")
		}
	}
	fmt.Println(output.String())
}

package main

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		fMap := make(map[string]int, n)
		arr := ReadStringSlice(n)
		for i := 0; i < n; i++ {
			fMap[arr[i]]++
		}
		solve(fMap, arr)

	}

	close(out)
	outWg.Wait()
}

func solve(fMap map[string]int, arr []string) {

	changeCount := 0
	for _, v := range fMap {
		changeCount += (v - 1)
	}
	out <- strconv.Itoa(changeCount)

	// changed pin
	visited := make(map[string]bool)
	for i := 0; i < len(arr); i++ {
		if !visited[arr[i]] {
			out <- arr[i]
			visited[arr[i]] = true
		} else {
			newPin := arr[i]
			for fMap[newPin] > 0 {
				firstDigit, _ := strconv.Atoi(string(newPin[0]))
				firstDigit = (firstDigit + 1) % 10
				newPin = strconv.Itoa(firstDigit) + newPin[1:]
			}
			fMap[newPin]++
			out <- newPin
		}
	}
}

/*********************** utility ***********************/

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	// set output
	out = make(chan string, 1024)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ReadString() string {
	in.Scan()
	return in.Text()
}

func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i], _ = strconv.Atoi(ReadString())
	}
	return arr
}

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

// 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 *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// 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 *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

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

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

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

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

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

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

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

var t int
var n int
var P [][]rune

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		n = ReadInt()

		P = [][]rune{}
		for i := 0; i < n; i++ {
			row := ReadRuneSlice()
			P = append(P, row)
		}

		solve()
	}
}

func solve() {
	num := 0
	used := [10]int{}

	// used[P[0][3]-'0'] = 1

	for i := 0; i < n; i++ {
		A := P[i]
		// 直前のものすべてと比較する
		// OUTER:
		for j := 0; j < i; j++ {
			B := P[j]
			// 等しいものがあればAの最上位桁を未使用のものに変更
			if isEqual(A, B) {
				for i := 0; i < 10; i++ {
					// 未使用のものを選ぶ
					if used[i] == 0 {
						A[3] = rune(i) + '0'
						num++
						used[i] = 1 // 使用済み
						// break OUTER
						break
					}
				}
				break
			} else {
				// 前のものと異なるなら何もしなくて良い
				continue
			}
		}

		// ループを抜けたときのAの最上位桁は必ず使用済み
		used[A[3]-'0'] = 1
	}

	fmt.Println(num)
	for i := 0; i < n; i++ {
		fmt.Println(string(P[i]))
	}
}

// func solve() {
// 	groups := make([]int, n)
// 	// 最初は自身が唯一のグループ
// 	for i := 0; i < n; i++ {
// 		groups[i] = i
// 	}
// 	for i := 0; i < n; i++ {
// 		for j := i + 1; j < n; j++ {
// 			if isEqual(P[i], P[j]) {
// 				groups[j] = groups[i]
// 			}
// 		}
// 	}
// 	// fmt.Println(groups)

// }

func isEqual(a, b []rune) bool {
	for i := 0; i < 4; i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

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

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

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)

		fMap := make(map[string]int, n)
		arr := make([]string, n)

		for t := 0; t < n; t++ {
			pin := ""
			fmt.Fscanf(in, "%s\n", &pin)

			arr[t] = pin
			fMap[pin]++
		}

		PINCodes(arr, fMap)
	}
}

func PINCodes(arr []string, fMap map[string]int) {
	// print sum
	changeCount := 0
	for _, v := range fMap {
		changeCount += (v - 1)
	}
	fmt.Println(changeCount)

	// changed pin
	visited := make(map[string]bool)
	for i := 0; i < len(arr); i++ {
		if !visited[arr[i]] {
			fmt.Println(arr[i])
			visited[arr[i]] = true
		} else {
			newPin := arr[i]
			for fMap[newPin] > 0 {
				firstDigit, _ := strconv.Atoi(string(newPin[0]))
				firstDigit = (firstDigit + 1) % 10
				newPin = strconv.Itoa(firstDigit) + newPin[1:]
			}
			fMap[newPin]++
			fmt.Println(newPin)

		}
		fMap[arr[i]]--
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var rows int

	fmt.Fscanln(os.Stdin, &rows)

	for i := 0; i < rows; i++ {
		var n int
		fmt.Fscanln(os.Stdin, &n)

		m := map[[4]byte]struct{}{}
		r := make([][4]byte, 0, n)
		c := 0
		for j := 0; j < n; j++ {
			var b string

			fmt.Fscanln(os.Stdin, &b)

			pin := [4]byte{b[0] - 48, b[1] - 48, b[2] - 48, b[3] - 48}
			if _, ok := m[pin]; ok {
				p := pin
				for {
					p[0]++
					for w := 0; w < 4; w++ {
						if p[w] >= 10 {
							p[w] = 0

							if w < 3 {
								p[w+1]++
							}
						}
					}

					if _, ok1 := m[p]; !ok1 {
						m[p] = struct{}{}
						r = append(r, p)

						for w := 0; w < 4; w++ {
							if p[w] != pin[w] {
								c++
							}
						}
						break
					}
				}
			} else {
				m[pin] = struct{}{}
				r = append(r, pin)
			}
		}

		fmt.Fprintln(os.Stdout, c)
		for _, pin := range r {
			fmt.Fprintf(os.Stdout, "%d%d%d%d\n", pin[0], pin[1], pin[2], pin[3])
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var rows int

	fmt.Fscanln(os.Stdin, &rows)

	for i := 0; i < rows; i++ {
		var n int
		fmt.Fscanln(os.Stdin, &n)

		m := map[[4]byte]int{}
		in := make([][4]byte, 0, n)
		r := make([][4]byte, 0, n)
		c := 0
		for j := 0; j < n; j++ {
			var b string

			fmt.Fscanln(os.Stdin, &b)

			pin := [4]byte{b[0] - 48, b[1] - 48, b[2] - 48, b[3] - 48}
			in = append(in, pin)
			m[pin]++
		}

		for _, pin := range in {
			m[pin]--
			if m[pin] > 0 {
				p := pin
				for {
					p[0]++
					for w := 0; w < 4; w++ {
						if p[w] >= 10 {
							p[w] = 0

							if w < 3 {
								p[w+1]++
							}
						}
					}

					if _, ok1 := m[p]; !ok1 {
						m[p] = 0
						r = append(r, p)

						for w := 0; w < 4; w++ {
							if p[w] != pin[w] {
								c++
							}
						}
						break
					}
				}
			} else {
				r = append(r, pin)
			}
		}

		fmt.Fprintln(os.Stdout, c)
		for _, pin := range r {
			fmt.Fprintf(os.Stdout, "%d%d%d%d\n", pin[0], pin[1], pin[2], pin[3])
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var rows int

	fmt.Fscanln(os.Stdin, &rows)

	for i := 0; i < rows; i++ {
		var n int
		fmt.Fscanln(os.Stdin, &n)

		m := map[[4]byte]int{}
		in := make([][4]byte, 0, n)
		r := make([][4]byte, 0, n)
		c := 0
		for j := 0; j < n; j++ {
			var b string

			fmt.Fscanln(os.Stdin, &b)

			pin := [4]byte{b[0] - 48, b[1] - 48, b[2] - 48, b[3] - 48}
			in = append(in, pin)
			m[pin]++
		}

		for _, pin := range in {
			m[pin]--
			if m[pin] > 0 {
				p := pin
				for {
					p[0]++
					for w := 0; w < 4; w++ {
						if p[w] >= 10 {
							p[w] = 0

							if w < 3 {
								p[w+1]++
							}
						}
					}

					if _, ok1 := m[p]; !ok1 {
						r = append(r, p)

						for w := 0; w < 4; w++ {
							if p[w] != pin[w] {
								c++
							}
						}
						break
					}
				}
			} else {
				r = append(r, pin)
			}
		}

		fmt.Fprintln(os.Stdout, c)
		for _, pin := range r {
			fmt.Fprintf(os.Stdout, "%d%d%d%d\n", pin[0], pin[1], pin[2], pin[3])
		}
	}
}


You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i < j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly one vertex in common.

First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq 3 \cdot 10^5)$$$. Next $$$m$$$ lines describe paths. Each line describes a path by it's two endpoints $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$. The given path is all the vertices on the shortest path from $$$u$$$ to $$$v$$$ (including $$$u$$$ and $$$v$$$).

Output a single integer — the number of pairs of paths that intersect at exactly one vertex.

NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example with two additional paths. Pairs $$$(1,4)$$$, $$$(1,5)$$$, $$$(2,5)$$$, $$$(3,4)$$$, $$$(3,5)$$$, $$$(3,6)$$$ and $$$(5,6)$$$ intersect at one vertex.

package main

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

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

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

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
}

const H = 20

func solve(n int, E [][]int, paths [][]int) int64 {
	g := NewGraph(n+1, len(E)*2)

	for _, e := range E {
		u, v := e[0], e[1]
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	P := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		P[i] = make([]int, H)
	}
	D := make([]int, n+1)
	var orient func(p, u int)
	orient = func(p, u int) {
		D[u] = D[p] + 1
		P[u][0] = p

		for i := 1; i < H && P[u][i-1] > 0; i++ {
			P[u][i] = P[P[u][i-1]][i-1]
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				orient(u, v)
			}
		}
	}

	orient(0, 1)

	var ans int64

	var find func(u int)

	S1 := make([]int, n+1)
	S2 := make([]int, n+1)
	Q := make([][]Pair, n+1)

	find = func(u int) {
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if v != P[u][0] {
				find(v)
				S1[u] += S1[v]
				S2[u] += S2[v]
			}
		}
		mem := make(map[Pair]int)
		var sum = S2[u]
		for _, p := range Q[u] {
			sum--
			ans += int64(sum)

			x := getSub(D, P, p.first, u)
			y := getSub(D, P, p.second, u)

			if x != -1 {
				S1[x]--
				ans -= int64(S1[x])
			}
			if y != -1 {
				S1[y]--
				ans -= int64(S1[y])
			}
			if x != -1 && y != -1 {
				ans += int64(mem[Pair{x, y}])
				mem[Pair{x, y}]++
				mem[Pair{y, x}]++
			}
		}
	}

	for i := 0; i < len(paths); i++ {
		u, v := paths[i][0], paths[i][1]
		l := lca(D, P, u, v)
		S1[u]++
		S1[v]++
		S1[l] -= 2
		S2[u]++
		S2[v]++
		S2[l]--
		S2[P[l][0]]--
		if len(Q[l]) == 0 {
			Q[l] = make([]Pair, 0, 2)
		}
		Q[l] = append(Q[l], Pair{u, v})
	}

	find(1)

	return ans
}

type Pair struct {
	first, second int
}

func lca(D []int, P [][]int, u, v int) int {
	if D[u] > D[v] {
		u, v = v, u
	}
	for i := H - 1; i >= 0; i-- {
		if D[v]-(1<<i) >= D[u] {
			v = P[v][i]
		}
	}
	if v == u {
		return u
	}

	for i := H - 1; i >= 0; i-- {
		if P[u][i] != P[v][i] {
			u = P[u][i]
			v = P[v][i]
		}
	}
	return P[u][0]
}

func getSub(D []int, P [][]int, u int, p int) int {
	if u == p {
		return -1
	}
	d := D[u] - D[p] - 1
	for i := H - 1; i >= 0; i-- {
		if (d>>i)&1 == 1 {
			u = P[u][i]
		}
	}
	return u
}

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)
	return &Graph{nodes, next, to, 0}
}

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
}

package main

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

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

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

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
}

const H = 20

func solve(n int, E [][]int, paths [][]int) int64 {
	g := NewGraph(n, len(E)*2)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	P := make([][]int, n)
	for i := 0; i < n; i++ {
		P[i] = make([]int, H)
	}
	D := make([]int, n)
	var orient func(p, u int)
	orient = func(p, u int) {
		P[u][0] = p

		for i := 1; i < H; i++ {
			P[u][i] = P[P[u][i-1]][i-1]
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				D[v] = D[u] + 1
				orient(u, v)
			}
		}
	}
	orient(0, 0)

	sameLca := make([]map[Pair][]int, n)
	byLca := make([][]int, n)
	vertex := make([][]int, n)

	for i := 0; i < n; i++ {
		sameLca[i] = make(map[Pair][]int)
		byLca[i] = make([]int, 0, 2)
		vertex[i] = make([]int, 0, 2)
	}

	for i := 0; i < len(paths); i++ {
		u, v := paths[i][0], paths[i][1]
		u--
		v--
		l := lca(D, P, u, v)
		sons := Pair{getSubtree(D, P, u, l), getSubtree(D, P, v, l)}
		if sons.first > sons.second {
			sons = Pair{sons.second, sons.first}
		}

		if _, found := sameLca[l][sons]; !found {
			sameLca[l][sons] = make([]int, 0, 2)
		}
		sameLca[l][sons] = append(sameLca[l][sons], i)

		byLca[l] = append(byLca[l], i)
		vertex[u] = append(vertex[u], i)
		vertex[v] = append(vertex[v], i)
	}

	sets := make([]map[int]bool, n)
	link := make([]int, n)
	for i := 0; i < n; i++ {
		link[i] = i
		sets[i] = make(map[int]bool)
	}

	at := func(v int) map[int]bool {
		return sets[link[v]]
	}

	get := func(mem map[int]int, k int) int64 {
		return int64(mem[k])
	}

	sz := func(arr []int) int64 {
		return int64(len(arr))
	}

	var ans int64
	var process func(p, u int)

	process = func(p, u int) {
		big := -1
		vert := make(map[int]int)
		here := make(map[int]int)

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				process(u, v)
				vert[v] = len(at(v))
				if big < 0 || vert[big] < vert[v] {
					big = v
				}
			}
		}

		for son, edges := range sameLca[u] {
			vert[son.first] -= len(edges)
			vert[son.second] -= len(edges)
			here[son.first] += len(edges)
			here[son.second] += len(edges)
		}

		delete(vert, -1)
		delete(here, -1)

		if big != -1 {
			link[u] = link[big]
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if v != big {
				pp := at(v)
				for path := range pp {
					at(u)[path] = true
				}
			}
		}

		for _, path := range vertex[u] {
			at(u)[path] = true
		}
		hr := int64(len(byLca[u]))
		vertical := int64(len(at(u))) - hr
		ans += vertical*hr + hr*(hr-1)/2
		var add1, add2 int64

		for son, edges := range sameLca[u] {
			add1 += sz(edges) * (get(vert, son.first) + get(vert, son.second))
			if son.first >= 0 {
				add2 += sz(edges) * (get(here, son.first) + get(here, son.second))
				add2 -= (sz(edges) * (sz(edges) + 1) / 2) * 2
			} else if son.second >= 0 {
				add2 += sz(edges) * get(here, son.second)
				add2 -= sz(edges)
			}
		}

		ans -= add1 + add2/2
		for _, path := range byLca[u] {
			delete(at(u), path)
		}
	}

	process(-1, 0)

	return ans
}

type Pair struct {
	first, second int
}

func lca(D []int, P [][]int, u, v int) int {
	if D[u] > D[v] {
		u, v = v, u
	}
	for i := 0; i < H; i++ {
		if D[v]-(1<<i) >= D[u] {
			v = P[v][i]
		}
	}
	if v == u {
		return u
	}

	for i := H - 1; i >= 0; i-- {
		if P[u][i] != P[v][i] {
			u = P[u][i]
			v = P[v][i]
		}
	}
	return P[u][0]
}

func getUp(P [][]int, v int, d int) int {
	for i := 0; i < H; i++ {
		if (d>>i)&1 == 1 {
			v = P[v][i]
		}
	}
	return v
}

func getSubtree(D []int, P [][]int, u int, p int) int {
	if u == p {
		return -1
	}
	return getUp(P, u, D[u]-D[p]-1)
}

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)
	return &Graph{nodes, next, to, 0}
}

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
}

package main

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

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

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

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
}

const H = 20

func solve(n int, E [][]int, paths [][]int) int64 {
	g := NewGraph(n, len(E)*2)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	P := make([][]int, n)
	for i := 0; i < n; i++ {
		P[i] = make([]int, H)
	}
	D := make([]int, n)
	var orient func(p, u int)
	orient = func(p, u int) {
		P[u][0] = p

		for i := 1; i < H; i++ {
			P[u][i] = P[P[u][i-1]][i-1]
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				D[v] = D[u] + 1
				orient(u, v)
			}
		}
	}
	orient(0, 0)

	sameLca := make([]map[Pair][]int, n)
	byLca := make([]map[int]bool, n)
	vertex := make([]map[int]bool, n)

	for i := 0; i < n; i++ {
		sameLca[i] = make(map[Pair][]int)
		byLca[i] = make(map[int]bool)
		vertex[i] = make(map[int]bool)
	}

	for i := 0; i < len(paths); i++ {
		paths[i][0]--
		paths[i][1]--
		u, v := paths[i][0], paths[i][1]
		l := lca(D, P, u, v)
		sones := Pair{getSubtree(D, P, u, l), getSubtree(D, P, v, l)}
		if sones.first > sones.second {
			sones = Pair{sones.second, sones.first}
		}

		if _, found := sameLca[l][sones]; !found {
			sameLca[l][sones] = make([]int, 0, 2)
		}
		sameLca[l][sones] = append(sameLca[l][sones], i)

		byLca[l][i] = true
		vertex[u][i] = true
		vertex[v][i] = true
	}

	sets := make([]map[int]bool, n)
	link := make([]int, n)
	for i := 0; i < n; i++ {
		link[i] = i
		sets[i] = make(map[int]bool)
	}

	at := func(v int) map[int]bool {
		return sets[link[v]]
	}

	get := func(mem map[int]int, k int) int64 {
		return int64(mem[k])
	}

	sz := func(arr []int) int64 {
		return int64(len(arr))
	}

	var ans int64
	var process func(p, u int)

	process = func(p, u int) {
		big := -1
		vert := make(map[int]int)
		here := make(map[int]int)

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				process(u, v)
				vert[v] = len(at(v))
				if big < 0 || vert[big] < vert[v] {
					big = v
				}
			}
		}

		for son, edges := range sameLca[u] {
			vert[son.first] -= len(edges)
			vert[son.second] -= len(edges)
			here[son.first] += len(edges)
			here[son.second] += len(edges)
		}

		delete(vert, -1)
		delete(here, -1)

		if big != -1 {
			link[u] = link[big]
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if v != big {
				pp := at(v)
				for path := range pp {
					at(u)[path] = true
				}
			}
		}

		for path := range vertex[u] {
			at(u)[path] = true
		}
		hr := int64(len(byLca[u]))
		vertical := int64(len(at(u))) - hr
		ans += vertical*hr + hr*(hr-1)/2
		var add1, add2 int64

		for son, edges := range sameLca[u] {
			add1 += sz(edges) * (get(vert, son.first) + get(vert, son.second))
			if son.first >= 0 {
				add2 += sz(edges) * (get(here, son.first) + get(here, son.second))
				add2 -= (sz(edges) * (sz(edges) + 1) / 2) * 2
			} else if son.second >= 0 {
				add2 += sz(edges) * get(here, son.second)
				add2 -= sz(edges)
			}
		}

		ans -= add1 + add2/2
		for path := range byLca[u] {
			delete(at(u), path)
		}
	}

	process(-1, 0)

	return ans
}

type Pair struct {
	first, second int
}

func lca(D []int, P [][]int, u, v int) int {
	if D[u] > D[v] {
		u, v = v, u
	}
	for i := 0; i < H; i++ {
		if D[v]-(1<<i) >= D[u] {
			v = P[v][i]
		}
	}
	if v == u {
		return u
	}

	for i := H - 1; i >= 0; i-- {
		if P[u][i] != P[v][i] {
			u = P[u][i]
			v = P[v][i]
		}
	}
	return P[u][0]
}

func getUp(P [][]int, v int, d int) int {
	for i := 0; i < H; i++ {
		if (d>>i)&1 == 1 {
			v = P[v][i]
		}
	}
	return v
}

func getSubtree(D []int, P [][]int, u int, p int) int {
	if u == p {
		return -1
	}
	return getUp(P, u, D[u]-D[p]-1)
}

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)
	return &Graph{nodes, next, to, 0}
}

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
}


Alicia has an array, $$$a_1, a_2, \ldots, a_n$$$, of non-negative integers. For each $$$1 \leq i \leq n$$$, she has found a non-negative integer $$$x_i = max(0, a_1, \ldots, a_{i-1})$$$. Note that for $$$i=1$$$, $$$x_i = 0$$$.For example, if Alicia had the array $$$a = \{0, 1, 2, 0, 3\}$$$, then $$$x = \{0, 0, 1, 2, 2\}$$$.Then, she calculated an array, $$$b_1, b_2, \ldots, b_n$$$: $$$b_i = a_i - x_i$$$.For example, if Alicia had the array $$$a = \{0, 1, 2, 0, 3\}$$$, $$$b = \{0-0, 1-0, 2-1, 0-2, 3-2\} = \{0, 1, 1, -2, 1\}$$$.Alicia gives you the values $$$b_1, b_2, \ldots, b_n$$$ and asks you to restore the values $$$a_1, a_2, \ldots, a_n$$$. Can you help her solve the problem?

The first line contains one integer $$$n$$$ ($$$3 \leq n \leq 200\,000$$$) – the number of elements in Alicia's array. The next line contains $$$n$$$ integers, $$$b_1, b_2, \ldots, b_n$$$ ($$$-10^9 \leq b_i \leq 10^9$$$). It is guaranteed that for the given array $$$b$$$ there is a solution $$$a_1, a_2, \ldots, a_n$$$, for all elements of which the following is true: $$$0 \leq a_i \leq 10^9$$$.

Print $$$n$$$ integers, $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq 10^9$$$), such that if you calculate $$$x$$$ according to the statement, $$$b_1$$$ will be equal to $$$a_1 - x_1$$$, $$$b_2$$$ will be equal to $$$a_2 - x_2$$$, ..., and $$$b_n$$$ will be equal to $$$a_n - x_n$$$. It is guaranteed that there exists at least one solution for the given tests. It can be shown that the solution is unique.

package main

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

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

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

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

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

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

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

	n := readNum(reader)

	s, _ := reader.ReadBytes('\n')

	B := make([]int, n)

	fillNNums(s, n, B)

	A := solve(n, B)

	for i := 0; i < n; i++ {
		if i < n-1 {
			fmt.Printf("%d ", A[i])
		} else {
			fmt.Printf("%d\n", A[i])
		}
	}
}

func solve(n int, B []int) []int {
	A := make([]int, n)

	A[0] = B[0]

	x := max(0, A[0])

	for i := 1; i < n; i++ {
		A[i] = B[i] + x
		x = max(x, A[i])
	}

	return A
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &b[i])
	}
	fmt.Fscanf(in, "\n")
	maxN := int64(0)
	a := make([]int64, n)
	a[0] = b[0]
	maxN = max(a[0], maxN)
	for i := 1; i < n; i++ {
		a[i] = b[i] + maxN
		maxN = max(maxN, a[i])
	}
	fmt.Fprintf(out, "%d", a[0])
	for i := 1; i < n; i++ {
		fmt.Fprintf(out, " %d", a[i])
	}
	fmt.Fprintf(out, "\n")
	return
}

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

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n := NextInt()
	a := make([]int, n)
	curmax := 0
	for i := 0; i < n; i++ {
		b := NextInt()
		a[i] = b + curmax
		if a[i] > curmax {
			curmax = a[i]
		}
		fmt.Fprint(out, a[i], " ")
	}
}

package main

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

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

func scanf(format string, a ...interface{})  { fmt.Fscanf(in, format, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(out, format, a...) }
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	defer out.Flush()
	var n int
	scanf("%d\n", &n)
	b := make([]int, n)
	for i := range b {
		scanf("%d", &b[i])
	}

	x := 0
	for i := 0; i < n; i++ {
		a := b[i] + x
		printf("%d ", a)
		x = max(x, a)
	}

}

package main

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

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

	 defer out.Flush()

	fmt.Fscanf(in,"%d\n",&n)

	a := make([]int ,n)

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

	b := make([]int,n)
	maxx := 0

	for i := 0 ; i < n ; i ++ {
		b[i] = maxx + a[i]
		if  maxx + a[i] > maxx{
			maxx = maxx + a[i]
		}
	}

	for i := 0 ; i < n ; i ++ {
		fmt.Fprintf(out,"%d ",b[i])
	}
	fmt.Fprintf(out,"\n")
}

package main

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

const (
	maxn = int(1e5 + 50)
	mod  = int(1e9 + 7)
	eps  = 1e-8
	inf  = int(0x3f3f3f3f)
)

var n int
var b []int
var a []int

func main() {
	scanInt(&n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		scanInt(&b[i])
	}
	a = make([]int, n)
	a[0] = b[0]
	mx := a[0]
	for i := 1; i < n; i++ {
		a[i] = mx + b[i]
		mx = max(mx, a[i])
	}
	printIntSlice(a, true)
	close(channelType)
	oWg.Wait()
	out.Flush()
}

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

var channelType chan string
var in *bufio.Scanner
var out = bufio.NewWriter(os.Stdout)
var oWg *sync.WaitGroup

// string and slice are the return value
func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)
	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range channelType {
			writer.WriteString(line + "\n")
		}
	}()
}
func scanString() string { in.Scan(); return in.Text() }
func scanInt(a *int)     { *a, _ = strconv.Atoi(scanString()) }
func scanInts(a ...*int) {
	for i := range a {
		*a[i], _ = strconv.Atoi(scanString())
	}
}
func scanInt64(a *int64) { *a, _ = strconv.ParseInt(scanString(), 10, 64) }
func scanInt64s(a ...*int64) {
	for i := range a {
		*a[i], _ = strconv.ParseInt(scanString(), 10, 64)
	}
}
func scanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = scanString()
	}
	return s
}
func scanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		scanInt(&arr[i])
	}
	return arr
}
func scanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		scanInt64(&arr[i])
	}
	return arr
}
func printlnInts(args ...int) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printlnInt64s(args ...int64) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printIntSlice(a []int, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func printInt64Slice(a []int64, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func printRuneSlice(a []rune, flag bool) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
	if flag { fmt.Fprintln(out) }
}
func putchar(a ...rune) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
}
func printString(s string) { fmt.Fprintln(out, s) }

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string { return fmt.Sprintf("%v", v) }
func spaceSeperatedStringFromArray(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func spaceSeperatedStringFromArray64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func minMaxFromArray(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64         { return a / gcdCalculation(a, b) * b }
func gcdCalculation(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return gcdCalculation(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func absoluteValue(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func same(x, y double) bool { return math.Abs(float64(x-y)) < eps }
func popcount(x int) (res int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			res++
		}
	}
	return
}
func qp(a, n int64) (res int64) {
	for ; n > 0; n >>= 1 {
		if (n & 1) == 1 {
			res = res * a % int64(mod)
		}
		a = a * a % int64(mod)
	}
	return
}
func divUp(a, b int64) int64 {
	if a % b == 0 { return a / b } else { return a / b + 1 }
}
// [l, r)
func reverse(a *[]rune, l, r int) {
	for i, j := l, r - 1; i < j; i, j = i + 1, j - 1 {
		(*a)[i], (*a)[j] = (*a)[j], (*a)[i]
	}
}

/*********************** Structs ***********************/
type pair struct{ X, Y int }
type double float64
type pairSlice []pair

func (p pairSlice) Len() int { return len(p) }
func (p pairSlice) Less(i, j int) bool {
	if p[i].X != p[j].X {
		return p[i].X < p[j].X
	} else {
		return p[i].Y < p[j].Y
	}
}
func (p pairSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

package main

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

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

	var n, v, max int
	for Fscan(in, &n); n > 0; n-- {
		Fscan(in, &v)
		v += max
		Fprint(out, v, " ")
		if v > max {
			max = v
		}
	}
}

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

package main

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

func main() {
	n := ScanInt()
	b := ScanIntSlice(n)

	mx := b[0]
	xi := mx
	O <- S(b[0]) + " "
	for i := 1; i < n; i++ {
		ai := b[i] + xi
		xi = Mx(xi, (ai))
		O <- S(ai) + " "
	}
	O <- "\n"

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line)
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int   { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int   { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64 { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

const N int = 200005

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

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

func main() {
	var a, b [N] int
	var n int
	//fmt.Scanf("%d\n", &n)
	scanf("%d\n",&n)
	for i:=0; i < n; i++ {
		//fmt.Scanf("%d", &b[i])
		scanf("%d ", &b[i])
	}
	var mx = 0
	a[0] = b[0] + mx
	fmt.Printf("%d",a[0])
	//printf("%d", a[0])
	for i:=1; i < n; i++ {
		mx = max(a[i-1], mx)
		a[i] = b[i] + mx
		//fmt.Printf("%d=%d+%d\n", a[i], b[i], mx)
		fmt.Printf(" %d",a[i])
		//printf(" %d", a[i])
	}
	fmt.Printf("\n")
	//printf("\n")
}

package main

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

func solve(b []int64) []int64 {
	var max int64
	for i := range b {
		b[i] += max
		if b[i] > max {
			max = b[i]
		}
	}
	return b
}

func main() {
	toInt := func(buf []byte) int64 {
		var n int64
		var d int64 = 1
		for _, v := range buf {
			if v == '-' {
				d = -1
				continue
			}
			n = n*10 + int64(v-'0')
		}
		return d * n
	}

	var n int64

	fmt.Scan(&n)
	b := make([]int64, n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range b {
		scanner.Scan()
		b[i] = toInt(scanner.Bytes())
	}

	a := solve(b)
	for _, x := range a {
		fmt.Print(x, " ")
	}
	fmt.Println()
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextInt64Array()
	B := make([]int64, N)

	B[0] = A[0]

	mx := max(0, A[0])
	for i := 1; i < N; i++ {
		mx = max(mx, B[i-1])
		B[i] = A[i] + mx
	}

	PrintI(B...)
}

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

func mapToString(arr []int64) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.FormatInt(arr[i], 10)
	}
	return ret
}

func PrintI(args ...int64) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main
import (
	"fmt"
	"bufio"
	"os"
)

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

	var n, max int
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(r, &x)
		fmt.Fprintf(w, "%d ", x + max)
		if max + x > max {
			max += x
		}

	}
}

// У Алисии есть массив неотрицательных целых чисел a1,a2,…,an. Для всех 1≤i≤n, она нашла число xi=max(0,a1,…,ai−1).
// Обратите внимание, что для i=1, xi=0
// Например, если у Алисии был массив a={0,1,2,0,3}, то x={0,0,1,2,2}
// Затем она вычислила значения массива b1,b2,…,bn: bi=ai−xi.
// Например, если у Алисии был массив a={0,1,2,0,3}, то b={0−0,1−0,2−1,0−2,3−2}={0,1,1,−2,1}.
// Алисия дала вам массив b1,b2,…,bn и попросила восстановить массив a1,a2,…,an.
// Можете ли вы помочь ей с этой задачей?

// Входные данные
// В первой строке записано одно целое число n (3≤ n≤ 200000) — количество элементов в массиве Алисии.
// Во второй строке записаны n целых чисел, b1,b2,…,bn (−109≤bi≤109).
// Гарантируется, что для заданного массива b существует решение a1,a2,…,an, для всех элементов которого верно: 0≤ai≤109.

// Выходные данные
// Выведите n целых чисел, a1,a2,…,an (0≤ai≤109), таких, что если вы посчитаете x согласно условию, b1 будет равно
// a1−x1, b2 будет равно a2−x2, ..., и bn будет равно an−xn.
// Гарантируется, что на всех данных тестах есть хотя бы одно решение. Можно показать, что в таком случае решение единственно.
package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
)

type Decoder struct {
	maxItem int64
}

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

func (d *Decoder) Decode(newItem int64) int64 {
	result := d.maxItem + newItem
	d.maxItem = max(d.maxItem, result)
	return result
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	var n, i uint64
	var t int64
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriterSize(os.Stdout, 1024 * 1024 * 10)
	decoder := Decoder{}
	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		fmt.Printf("err1: %v", err.Error())
		os.Exit(1)
	}
	for i = 0; i < n; i++ {
		_, err := fmt.Fscanf(reader, "%d", &t)
		if err != nil {
			fmt.Printf("err2: %v", err.Error())
			os.Exit(1)
		}

		fmt.Fprintf(writer, "%d ", decoder.Decode(t))
	}
	writer.Flush()
}

// У Алисии есть массив неотрицательных целых чисел a1,a2,…,an. Для всех 1≤i≤n, она нашла число xi=max(0,a1,…,ai−1).
// Обратите внимание, что для i=1, xi=0
// Например, если у Алисии был массив a={0,1,2,0,3}, то x={0,0,1,2,2}
// Затем она вычислила значения массива b1,b2,…,bn: bi=ai−xi.
// Например, если у Алисии был массив a={0,1,2,0,3}, то b={0−0,1−0,2−1,0−2,3−2}={0,1,1,−2,1}.
// Алисия дала вам массив b1,b2,…,bn и попросила восстановить массив a1,a2,…,an.
// Можете ли вы помочь ей с этой задачей?

// Входные данные
// В первой строке записано одно целое число n (3≤ n≤ 200000) — количество элементов в массиве Алисии.
// Во второй строке записаны n целых чисел, b1,b2,…,bn (−109≤bi≤109).
// Гарантируется, что для заданного массива b существует решение a1,a2,…,an, для всех элементов которого верно: 0≤ai≤109.

// Выходные данные
// Выведите n целых чисел, a1,a2,…,an (0≤ai≤109), таких, что если вы посчитаете x согласно условию, b1 будет равно
// a1−x1, b2 будет равно a2−x2, ..., и bn будет равно an−xn.
// Гарантируется, что на всех данных тестах есть хотя бы одно решение. Можно показать, что в таком случае решение единственно.
package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
)

type Decoder struct {
	maxItem int64
}

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

func (d *Decoder) Decode(newItem int64) int64 {
	result := d.maxItem + newItem
	d.maxItem = max(d.maxItem, result)
	return result
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	var n, i uint64
	var t int64
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	decoder := Decoder{}
	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		fmt.Printf("err1: %v", err.Error())
		os.Exit(1)
	}
	for i = 0; i < n; i++ {
		_, err := fmt.Fscanf(reader, "%d", &t)
		if err != nil {
			fmt.Printf("err2: %v", err.Error())
			os.Exit(1)
		}

		fmt.Fprintf(writer, "%d ", decoder.Decode(t))
	}
	writer.Flush()
}

package main

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

var (
	reader Reader = NewReader()
	writer Writer = NewWriter()
)

type Reader interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type Writer interface {
	Printf(format string, a ...interface{})
	Flush()
}

type readerImpl struct {
	*bufio.Scanner
}

func NewReader() Reader {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &readerImpl{Scanner: s}
}

func (i *readerImpl) NextInt() int {
	i.Scan()
	ret, _ := strconv.Atoi(i.Text())
	return ret
}

func (i *readerImpl) NextInt64() int64 {
	i.Scan()
	ret, _ := strconv.ParseInt(i.Text(), 10, 64)
	return ret
}

func (i *readerImpl) NextString() string {
	i.Scan()
	return i.Text()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter() Writer {
	return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

func (i *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(i.Writer, f, a...)
}

func (i *writerImpl) Flush() {
	i.Writer.Flush()
}

func main() {
	defer writer.Flush()
	n := reader.NextInt64()
	prevA := int64(0)
	prevX := int64(0)
	for ; n > 0; n-- {
		b := reader.NextInt64()
		x := max(prevA, prevX)
		a := x + b
		writer.Printf("%d ", a)
		prevA = a
		prevX = x
	}
}

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

package main

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

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

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

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

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

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

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

	n := readNum(reader)

	s, _ := reader.ReadBytes('\n')

	B := make([]int, n)

	fillNNums(s, n, B)

	A := solve(n, B)

	for i := 0; i < n; i++ {
		if i < n-1 {
			fmt.Printf("%d ", A[i])
		} else {
			fmt.Printf("%d\n", A[i])
		}
	}
}

func solve(n int, B []int) []int {
	A := make([]int, n)

	A[0] = B[0]

	x := max(0, A[0])

	for i := 1; i < n; i++ {
		A[i] = B[i] + x
		x = max(x, A[i])
	}

	return A
}

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

package main

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

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

	 defer out.Flush()

	fmt.Fscanf(in,"%d\n",&n)

	a := make([]int ,n)

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

	b := make([]int,n)
	maxx := 0
	summ := 0
	for i := 0 ; i + 1 < n ; i ++ {
		summ += a[i]
		b[i] = summ
		if b[i] > maxx{
			maxx = b[i]
		}
	}

	b[n-1] = maxx + a[n-1]

	for i := 0 ; i < n ; i ++ {
		fmt.Fprintf(out,"%d ",b[i])
	}
	fmt.Fprintf(out,"\n")
}

package main

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

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

	 defer out.Flush()

	fmt.Fscanf(in,"%d\n",&n)

	a := make([]int ,n)

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

	b := make([]int,n)

	summ := 0
	for i := 0 ; i < n ; i ++ {
		summ += a[i]
		b[i] = summ
	}
	for i := 0 ; i < n ; i ++ {
		fmt.Fprintf(out,"%d ",b[i])
	}
	fmt.Fprintf(out,"\n")
}

package main

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

const N int = 200005

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

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

func main() {
	var a, b [N] int
	var n int
	//fmt.Scanf("%d\n", &n)
	scanf("%d\n",&n)
	for i:=0; i < n; i++ {
		//fmt.Scanf("%d", &b[i])
		scanf("%d ", &b[i])
	}
	var mx = 0
	a[0] = b[0] + mx
	//fmt.Printf("%d",a[0])
	printf("%d", a[0])
	for i:=1; i < n; i++ {
		mx = max(a[i-1], mx)
		a[i] = b[i] + mx
		//fmt.Printf("%d=%d+%d\n", a[i], b[i], mx)
		//fmt.Printf(" %d",a[i])
		printf(" %d", a[i])
	}
	//fmt.Printf("\n")
	printf("\n")
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextInt64Array()
	B := make([]int64, N)

	B[0] = A[0]

	for i := 1; i < N; i++ {
		B[i] = B[i-1] + A[i]
	}

	PrintI(B...)
}

func mapToString(arr []int64) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.FormatInt(arr[i], 10)
	}
	return ret
}

func PrintI(args ...int64) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}