package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	fmt.Scan(&res)
	return res
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip(l int) int {
	var res int
	var a int
	fmt.Scan(&res)
	for i:=1; i<l; i++ {
		fmt.Scan(&a)
	}
	return res
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip(l)
		fmt.Println(l)
	}
}

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadSlice('\n')
	nStr = bytes.ReplaceAll(nStr, []byte{'\r'}, []byte{})
	nStr = bytes.ReplaceAll(nStr, []byte{'\n'}, []byte{})
	n, _ := strconv.Atoi(string(nStr))
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadSlice('\n')
	line = bytes.ReplaceAll(line, []byte{'\r'}, []byte{})
	line = bytes.ReplaceAll(line, []byte{'\n'}, []byte{})
	numbs := strings.Split(string(line), " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func main() {
	in := bufio.NewReaderSize(os.Stdin, 1024)
	var total int
	//var l int
	var data []int

	total = readInt(in)

	for i:=0; i<total; i++ {
		_ = readInt(in)
		data = readArrInt(in)
		fmt.Println(data[0])
	}
}

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadSlice('\n')
	nStr = bytes.ReplaceAll(nStr, []byte{'\r'}, []byte{})
	nStr = bytes.ReplaceAll(nStr, []byte{'\n'}, []byte{})
	n, _ := strconv.Atoi(string(nStr))
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadSlice('\n')
	line = bytes.ReplaceAll(line, []byte{'\r'}, []byte{})
	line = bytes.ReplaceAll(line, []byte{'\n'}, []byte{})
	numbs := strings.Split(string(line), " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var total int
	//var l int
	var data []int

	total = readInt(in)

	for i:=0; i<total; i++ {
		_ = readInt(in)
		data = readArrInt(in)
		fmt.Println(data[0])
	}
}

package main

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

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

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var total int
	//var l int
	var data []int

	total = readInt(in)

	for i:=0; i<total; i++ {
		_ = readInt(in)
		data = readArrInt(in)
		fmt.Println(data[0])
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0] == ' ' {
			continue
		}
		if b[0] == '\n' {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	var res int
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readIntSkip()

	for i:=0; i<total; i++ {
		l = readIntSkip()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	var res int
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readIntSkip()

	for i:=0; i<total; i++ {
		l = readIntSkip()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
)

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func readIntP(res *int) {
	fmt.Scan(res)
}

func readIntSlice(l int) []int {
	res := make([]int, l)
	for i:=0; i<l; i++ {
		fmt.Scan(&res[i])
	}
	return res
}

func readIntSliceP(res []int) {
	for i:=0; i<len(res); i++ {
		fmt.Scan(&res[i])
	}
}

func readSkip(l int) {
	var a int
	for i:=0; i<l; i++ {
		fmt.Scan(&a)
	}
}

func main() {
	var total int
	var l int
	var res int
	var j int

	fmt.Scan(&total)

	for i:=0; i<total; i++ {
		fmt.Scan(&l)
		fmt.Scan(&res)
		fmt.Println(res)
		for j=1; j<l; j++ {
			fmt.Scan(&res)
		}
	}
}

package main

import (
	"fmt"
)

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func readIntP(res *int) {
	fmt.Scan(res)
}

func readIntSlice(l int) []int {
	res := make([]int, l)
	for i:=0; i<l; i++ {
		fmt.Scan(&res[i])
	}
	return res
}

func readIntSliceP(res []int) {
	for i:=0; i<len(res); i++ {
		fmt.Scan(&res[i])
	}
}

func readSkip(l int) {
	var a int
	for i:=0; i<l; i++ {
		fmt.Scan(&a)
	}
}

func main() {
	total := readInt()
	var l int
	var res int

	for i:=0; i<total; i++ {
		readIntP(&l)
		readIntP(&res)
		fmt.Println(res)
		readSkip(l-1)
	}
}

package main

import (
	"fmt"
)

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func readIntSlice(l int) []int {
	res := make([]int, l)
	for i:=0; i<l; i++ {
		fmt.Scan(&res[i])
	}
	return res
}

func readIntSliceP(res []int) {
	for i:=0; i<len(res); i++ {
		fmt.Scan(&res[i])
	}
}

func readSkip(l int) {
	var a int
	for i:=0; i<l; i++ {
		fmt.Scan(&a)
	}
}

func main() {
	total := readInt()

	for i:=0; i<total; i++ {
		l := readInt()
		fmt.Println(readInt())
		readSkip(l-1)
	}
}
//
//func process(data []int) int {
//	for i:=0; i<len(data); i++ {
//		res := 0
//		for j:=0; j<len(data); j++ {
//			if j == i {
//				continue
//			}
//			res = res ^ data[j]
//		}
//		if res == data[i] {
//			return data[i]
//		}
//	}
//
//	return 0
//}

package main

import (
	"fmt"
)

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func readIntSlice(l int) []int {
	res := make([]int, l)
	for i:=0; i<l; i++ {
		fmt.Scan(&res[i])
	}
	return res
}

func main() {
	total := readInt()

	for i:=0; i<total; i++ {
		l := readInt()
		data := readIntSlice(l)
		fmt.Println(data[0])
	}
}
//
//func process(data []int) int {
//	for i:=0; i<len(data); i++ {
//		res := 0
//		for j:=0; j<len(data); j++ {
//			if j == i {
//				continue
//			}
//			res = res ^ data[j]
//		}
//		if res == data[i] {
//			return data[i]
//		}
//	}
//
//	return 0
//}

package main

import (
	"fmt"
)

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func readIntSlice(l int) []int {
	res := make([]int, l)
	for i:=0; i<l; i++ {
		fmt.Scan(&res[i])
	}
	return res
}

func main() {
	total := readInt()
	datas := make([][]int, total)

	for i:=0; i<total; i++ {
		l := readInt()
		datas[i] = readIntSlice(l)
	}

	for _, data := range datas {
		fmt.Println(data[0])
	}
}
//
//func process(data []int) int {
//	for i:=0; i<len(data); i++ {
//		res := 0
//		for j:=0; j<len(data); j++ {
//			if j == i {
//				continue
//			}
//			res = res ^ data[j]
//		}
//		if res == data[i] {
//			return data[i]
//		}
//	}
//
//	return 0
//}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	n = readInt(in)
	for i := 0; i < n; i++ {
		_ = readInt(in)
		arr := readArrInt(in)
		fmt.Println(arr[0])
	}
}

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

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var t int
	fmt.Fscan(os.Stdin, &t)
	for t != 0 {
		var n int
		fmt.Fscan(os.Stdin, &n)
		arr := make([]int, n)
		for i := range arr {
			fmt.Fscan(os.Stdin, &arr[i])
		}
		fmt.Println(arr[0])
		t -= 1
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n, a int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)

	}
	fmt.Println(a)
	//fmt.Println("here is the num" + strconv.Itoa(a))
}

func main() {

	T := 0
	fmt.Scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	fmt.Fprintln(w, nums[0])
}

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

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var x int
		for j:=0;j<n;j++{
			fmt.Fscan(in,&x)
		}
		fmt.Fprintln(out,x)
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}
	printf("%d\n", a[0])
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	t, n, a int
)

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a)
		}
		fmt.Println(a)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; return res }

func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}

func ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi();
	for tt:=1;tt<=T;tt++ { N := gi(); A := gis(N); fmt.Fprintln(wrtr,A[0]) }
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1698A
Date: 9/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1698/A
Problem: CF1698A
**/
func (in *CF1698A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		ans := 0
		len := in.NextInt()
		for i := 0; i < len; i++ {
			 ans = in.NextInt()
		}
		fmt.Println(ans)
	}
}

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

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

package main

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

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

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

	var T int
	var n int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		for i := 0; i < n; i++ {
			Fscan(in, &x)
		}
		Fprintln(out, x)
	}
}

package main

import "fmt"

func main() {
	fmt.Println()
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
		}
		fmt.Println(a[0])
	}
}

package main

import "fmt"

const maxn int = 10000

func main() {
	var T int
	fmt.Scan(&T)
	var a [maxn]int
	for ; T > 0; T-- {
		var n int
		sum := 0
		fmt.Scan(&n)
		for i := 0; i < n; i++ {
			var x int
			fmt.Scan(&x)
			a[i] = x
			sum ^= x
		}
		for i := 0; i < n; i++ {
			if sum^a[i] == a[i] {
				fmt.Printf("%d\n", a[i])
				break
			}
		}

	}

}

package main

import (
	"fmt"
)

// var in = bufio.NewReader(os.Stdin)

// func readInt() int {
// 	res := 0
// 	for c, _ := in.ReadByte(); c >= '0' && c <= '9'; c, _ = in.ReadByte() {
// 		res = res*10 + int(c-'0')
// 	}
// 	return res
// }

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)
		var x int
		for i := 0; i < n; i++ {
			fmt.Scan(&x)
		}
		fmt.Println(x)
	}
}

package main

import (
	"fmt"
	//"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	for k := 0; k < n; k++ {
		var t int
		fmt.Scan(&t)
		ar := make([]int, t)
		for i := 0; i < t; i++ {
			fmt.Scan(&ar[i])
		}
		fmt.Println(ar[0])
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		for i := 0; i < n; i++ {
			var x int
			for j := 0; j < n; j++ {
				if i == j {
					continue
				}
				x ^= aa[j]
			}

			if x^aa[i] == 0 {
				fmt.Fprintln(out, x)
				break
			}
		}
	}
}

package main

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

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

func solve() {
	var n int
	fmt.Fscan(r, &n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Fscan(r, &arr[i])
	}
	fmt.Fprintln(w, arr[0])
}
func main() {
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0] == ' ' {
			continue
		}
		if b[0] == '\n' {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	var res int
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()
	fmt.Println(total)

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0] == ' ' {
			continue
		}
		if b[0] == '\n' {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	var res int
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	var res int
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readIntSkip()
	fmt.Println(total)
	l = readIntSkip()
	fmt.Println(l)
	l = readIntSkip()
	fmt.Println(l)
	fmt.Println(100)
	return

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	var res int
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()
	fmt.Println(total)
	l = readInt()
	fmt.Println(l)
	l = readIntSkip()
	fmt.Println(l)
	fmt.Println(100)
	return

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip(l int) int {
	var res int
	var a int
	fmt.Scan(&res)
	for i:=1; i<l; i++ {
		fmt.Scan(&a)
	}
	return res
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip(l)
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	res := 0
	var n int
	for {
		n, _ = os.Stdin.Read(b)
		if n == 0 {
			return res
		}
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

import (
	"fmt"
	"os"
)

var (
	b = make([]byte, 1)
)

func readInt() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0]<48 || b[0]>57 {
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func readIntSkip() int {
	res := 0
	for {
		os.Stdin.Read(b)
		if b[0] == '\n' {
			break
		}
		if b[0]<48 || b[0]>57 {
			for b[0] != '\n' {
				os.Stdin.Read(b)
			}
			break
		}
		res = res * 10 + int(b[0]) - 48
	}

	return res
}

func main() {
	var total int
	var l int

	total = readInt()

	for i:=0; i<total; i++ {
		l = readInt()
		l = readIntSkip()
		fmt.Println(l)
	}
}

package main

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

type reader struct {
	reader *bufio.Reader
}
func (r *reader) readInt() int {
	str, _ := r.reader.ReadString('\n')
	val, _ := strconv.Atoi(strings.Trim(str, "\n"))
	return val
}
func (r *reader) readIntSlice(l int) []int {
	data, _ := r.reader.ReadString('\n')
	res := make([]int, 0, l)
	for _, s := range strings.Split(strings.Trim(data, "\n"), " ") {
		v, _ := strconv.Atoi(s)
		res = append(res, v)
	}

	return res
}

func main() {
	var reader = &reader{
		reader: bufio.NewReader(os.Stdin),
	}
	total := reader.readInt()
	datas := make([][]int, total)

	for i:=0; i<total; i++ {
		l := reader.readInt()
		datas[i] = reader.readIntSlice(l)
	}

	for _, data := range datas {
		fmt.Println(data[0])
		//fmt.Println(process(data))
		//fmt.Println("res", data, process(data))
	}
}

func process(data []int) int {
	for i:=0; i<len(data); i++ {
		res := 0
		for j:=0; j<len(data); j++ {
			if j == i {
				continue
			}
			res = res ^ data[j]
		}
		if res == data[i] {
			return data[i]
		}
	}

	return 0
}

package main

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

type reader struct {
	reader *bufio.Reader
}
func (r *reader) readInt() int {
	str, _ := r.reader.ReadString('\n')
	val, _ := strconv.Atoi(strings.Trim(str, "\n"))
	return val
}
func (r *reader) readIntSlice(l int) []int {
	data, _ := r.reader.ReadString('\n')
	res := make([]int, 0, l)
	for _, s := range strings.Split(strings.Trim(data, "\n"), " ") {
		v, _ := strconv.Atoi(s)
		res = append(res, v)
	}

	return res
}

func main() {
	var reader = &reader{
		reader: bufio.NewReader(os.Stdin),
	}
	total := reader.readInt()
	datas := make([][]int, total)

	for i:=0; i<total; i++ {
		l := reader.readInt()
		datas[i] = reader.readIntSlice(l)
	}

	for _, data := range datas {
		fmt.Println(process(data))
		//fmt.Println("res", data, process(data))
	}
}

func process(data []int) int {
	for i:=0; i<len(data); i++ {
		res := 0
		for j:=0; j<len(data); j++ {
			if j == i {
				continue
			}
			res = res ^ data[j]
		}
		if res == data[i] {
			return data[i]
		}
	}

	return 0
}

package main

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

type reader struct {
	reader *bufio.Reader
}
func (r *reader) readInt() int {
	str, _ := r.reader.ReadString('\n')
	val, _ := strconv.Atoi(strings.Trim(str, "\n"))
	return val
}
func (r *reader) readIntSlice(l int) []int {
	data, _ := r.reader.ReadString('\n')
	res := make([]int, l)
	for i, s := range strings.Split(strings.Trim(data, "\n"), " ") {
		v, _ := strconv.Atoi(s)
		res[i] = v
	}

	return res
}

func main() {
	var reader = &reader{
		reader: bufio.NewReader(os.Stdin),
	}
	total := reader.readInt()
	datas := make([][]int, total)

	for i:=0; i<total; i++ {
		l := reader.readInt()
		datas[i] = reader.readIntSlice(l)
	}

	for _, data := range datas {
		fmt.Println(process(data))
		//fmt.Println("res", data, process(data))
	}
}

func process(data []int) int {
	for i:=0; i<len(data); i++ {
		res := 0
		for j:=0; j<len(data); j++ {
			if j == i {
				continue
			}
			res = res ^ data[j]
		}
		if res == data[i] {
			return data[i]
		}
	}

	return 0
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Println("Total cases: ", n)
	for i := 0; i < n; i++ {
		var t int
		fmt.Scanf("%d", &t)
		fmt.Println("Length: ", t)
		var answer int
		fmt.Scanf("%d", &answer)
		fmt.Println("Answer: ", answer)
		for j := 1; j < t; j++ {
			var bg int
			fmt.Scanf("%d", &bg)
		}
	}
}

package main

import (
	"fmt"
)

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	left, right := 1, n
	for left < right{
		m := left + right
		m /= 2
		fmt.Fprintf(w, "? %d %d\n", left, m)
		w.Flush()
		cnt := 0
		for i:=left;i<=m;i++ {
			var a int
			fmt.Fscan(r, &a)
			if a <= m && a >= left {
				cnt++
			}
		}
		if cnt % 2 == 0 {
			left = m + 1
		} else {
			right = m
		}
	}
	fmt.Fprintln(w, left)
}

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


package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		tree := make([][]int, n)
		dp := make([]node, n)

		for i := 0; i < n; i++ {
			tree[i] = make([]int, 0)

			dp[i] = node{calc: false}
			_, _ = fmt.Fscan(in, &dp[i].left, &dp[i].right)
		}

		for i := 1; i < n; i++ {
			var u, v int
			_, _ = fmt.Fscan(in, &u, &v)

			u--
			v--

			tree[u] = append(tree[u], v)
			tree[v] = append(tree[v], u)
		}

		dfs(tree, dp, 0, -1)

		ans := dp[0].ldp
		if ans < dp[0].rdp {
			ans = dp[0].rdp
		}

		fmt.Println(ans)
	}
}

func dfs(tree [][]int, dp []node, n int, p int) {
	if dp[n].calc {
		return
	}

	for _, m := range tree[n] {
		if m == p {
			continue
		}

		dfs(tree, dp, m, n)

		if dp[m].ldp+abs(dp[n].left-dp[m].left) > dp[m].rdp+abs(dp[n].left-dp[m].right) {
			dp[n].ldp += dp[m].ldp + abs(dp[n].left-dp[m].left)
		} else {
			dp[n].ldp += dp[m].rdp + abs(dp[n].left-dp[m].right)
		}

		if dp[m].ldp+abs(dp[n].right-dp[m].left) > dp[m].rdp+abs(dp[n].right-dp[m].right) {
			dp[n].rdp += dp[m].ldp + abs(dp[n].right-dp[m].left)
		} else {
			dp[n].rdp += dp[m].rdp + abs(dp[n].right-dp[m].right)
		}
	}
}

func abs(x int64) int64 {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

type node struct {
	calc bool

	left  int64
	right int64

	ldp int64
	rdp int64
}

package main

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

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

func Read() int {
	in.Scan()
	r := 0
	for _, v := range in.Bytes() {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<12), MaxInt)
	in.Split(bufio.ScanWords)
}

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

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

const N = 100100

var (
	a [N][2]int
	g [N][]int
)

func dfs(v, p int) (int64, int64) {
	var r0, r1 int64
	for _, to := range g[v] {
		if to == p {
			continue
		}
		t0, t1 := dfs(to, v)
		r0 += max(t0 + abs(int64(a[v][0] - a[to][0])), t1 + abs(int64(a[v][0] - a[to][1])))
		r1 += max(t0 + abs(int64(a[v][1] - a[to][0])), t1 + abs(int64(a[v][1] - a[to][1])))
	}
	return r0, r1
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		for i := 0; i < n; i++ {
			a[i], g[i] = [2]int{Read(), Read()}, []int{}
		}
		for i := 1; i < n; i++ {
			u, v := Read() - 1, Read() - 1
			g[u] = append(g[u], v)
			g[v] = append(g[v], u)
		}
		Fprintln(out, max(dfs(0, -1)));
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)
func CF1528A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n, v, w int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]struct{ l, r int }, n)
		for i := range a {
			Fscan(in, &a[i].l, &a[i].r)
		}
		type nb struct{ to, wt int }
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}
		var f func(v, fa int) (s0, s1 int64)
		f = func(v, fa int) (s0, s1 int64) {
			for _, w := range g[v] {
				if w != fa {
					p, q := f(w, v)
					s0 += max(abs(a[v].l-a[w].l)+p, abs(a[v].l-a[w].r)+q)
					s1 += max(abs(a[v].r-a[w].l)+p, abs(a[v].r-a[w].r)+q)
				}
			}
			return
		}
		Fprintln(out, max(f(0, -1)))
	}
}

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

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

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

package main

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

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

	var T, n, v, w int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]struct{ l, r int }, n)
		for i := range a {
			Fscan(in, &a[i].l, &a[i].r)
		}
		type nb struct{ to, wt int }
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}
		var f func(v, fa int) (s0, s1 int64)
		f = func(v, fa int) (s0, s1 int64) {
			for _, w := range g[v] {
				if w != fa {
					p, q := f(w, v)
					s0 += max(abs(a[v].l-a[w].l)+p, abs(a[v].l-a[w].r)+q)
					s1 += max(abs(a[v].r-a[w].l)+p, abs(a[v].r-a[w].r)+q)
				}
			}
			return
		}
		Fprintln(out, max(f(0, -1)))
	}
}

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

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

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

package main

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

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}
func (s *Scanner) Next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}
func (s *Scanner) NextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt()
	}
	return res
}
func (s *Scanner) NextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt64()
	}
	return res
}
func Min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}
func Max(nums ...int64) int64 {
	ans := int64(math.MinInt64)
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func InitInts1D(n int, val int64) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = val
	}
	return res
}
func InitInts2D(n, m int, val int64) [][]int64 {
	res := make([][]int64, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts1D(m, val)
	}
	return res
}

type StepState struct {
	step, dist int
}
type PriorityQueue []*StepState

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].step != pq[j].step {
		return pq[i].step < pq[j].step
	}
	return pq[i].dist < pq[j].dist
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*StepState)
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

type span struct {
	l, r int64
}

var (
	spans []span
	edge  [][]int
)

func Abs(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}

var (
	dp [][]int64
)

func f(now, par, parSel int) int64 {
	if dp[now][parSel] == -1 {
		res := int64(0)
		parVal := int64(0)
		if now != 0 {
			if parSel == 0 {
				parVal = spans[par].l
			} else {
				parVal = spans[par].r
			}
		}

		notSelRes := int64(0)
		selRes := int64(0)
		if now != 0 {
			notSelRes = Abs(spans[now].l - parVal)
			selRes = Abs(spans[now].r - parVal)
		}
		for _, next := range edge[now] {
			if next == par {
				continue
			}

			notSelRes += f(next, now, 0)
			selRes += f(next, now, 1)
		}
		res = Max(notSelRes, selRes)
		dp[now][parSel] = res
	}
	return dp[now][parSel]
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.NextInt()
	for tc := 0; tc < TC; tc++ {
		N := sc.NextInt()
		spans = make([]span, 0)
		for i := 0; i < N; i++ {
			spans = append(spans, span{l: sc.NextInt64(), r: sc.NextInt64()})
		}

		edge = make([][]int, N)
		for i := 0; i < N-1; i++ {
			x := sc.NextInt()
			y := sc.NextInt()
			x--
			y--
			edge[x] = append(edge[x], y)
			edge[y] = append(edge[y], x)
		}
		dp = InitInts2D(N, 2, -1)
		fmt.Fprintln(wr, f(0, -1, 0))
	}

}

package main

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

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

	var T, n, v, w int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([][2]int, n)
		for i := range a {
			Fscan(in, &a[i][0], &a[i][1])
		}
		type nb struct{ to, wt int }
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}

		dp := make([][2]int64, n)
		for i := range dp {
			dp[i] = [2]int64{-1, -1}
		}
		var f func(v, fa, x int) int64
		f = func(v, fa, x int) (s int64) {
			if dp[v][x] >= 0 {
				return dp[v][x]
			}
			for _, w := range g[v] {
				if w != fa {
					s += max(int64(abs(a[v][x]-a[w][0]))+f(w, v, 0), int64(abs(a[v][x]-a[w][1]))+f(w, v, 1))
				}
			}
			dp[v][x] = s
			return
		}
		Fprintln(out, max(f(0, -1, 0), f(0, -1, 0)))
	}
}

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

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

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


package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n, m := scanInt(scanner), scanInt(scanner)
	count := make([][]int, n)
	for r, _ := range count {
		count[r] = make([]int, n)
	}
	dr := []int{-1, -1, -1, 0, 0, 0, 1, 1, 1}
	dc := []int{-1, 0, 1, -1, 0, 1, -1, 0, 1}
	for i := 0; i != m; i++ {
		x, y := scanInt(scanner)-1, scanInt(scanner)-1
		for j := 0; j < 9; j++ {
			r := x+dr[j]
			if r == -1 || r == n {
				continue
			}
			c := y+dc[j]
			if c == -1 || c == n {
				continue
			}
			count[r][c] += 1
			if count[r][c] == 9 {
				writer.WriteString(fmt.Sprintf("%d\n", i+1))
				return
			}
		}
	}
	writer.WriteString("-1\n")
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n, m := scanInt(scanner), scanInt(scanner)
	g := make([][]bool, n)
	for r, _ := range g {
		g[r] = make([]bool, n)
	}
	result := -1
	for i := 0; i != m; i++ {
		x, y := scanInt(scanner)-1, scanInt(scanner)-1
		g[x][y] = true
		found := false
		loop9:
		for r := x-2; r <= x; r++ {
			for c := y-2; c <= y; c++ {
				found = true
				loop3:
				for R := r; R < r+3; R++ {
					for C := c; C < c+3; C++ {
						if R < 0 || R >= n || C < 0 || C >= n || !g[R][C] {
							found = false
							break loop3
						}
					}
				}
				if found {
					break loop9
				}
			}
		}
		if found && result == -1 {
			result = i+1
		}
	}
	writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

import (
    "fmt"
    )

func main() {
    var n, i uint
    fmt.Scan(&n)

    find := false
    for i = 0; i < n; i++ {
        var a uint
        fmt.Scan(&a)
        if a == 1 {
            find = true
        }
    }

    if find {
        fmt.Println("-1")
    } else {
        fmt.Println("1")
    }
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()

	for i := 0; i < n; i++ {
		a := nextInt()
		if a == 1 {
			println(-1)
			return
		}
	}

	println(1)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

func main() {
	z := bufio.NewScanner(os.Stdin)
	z.Split(bufio.ScanWords)
	z.Scan()
	n, _ := strconv.Atoi(z.Text())
	for i := 0; i < n; i++  {
		z.Scan()
		a, _ := strconv.Atoi(z.Text())
		if a == 1 {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(1)
}

package main

import (
     "fmt"
)

func main() {
        var n, i, a int
        var ok bool
        ok = false
        fmt.Scan(&n)
        for i = 0; i < n; i++ {
            fmt.Scan(&a)
            if a == 1 {
               ok = true
             }
        }
        if ok {
           fmt.Println("-1")
        }else{
           fmt.Println("1")
        }
}

package main

import "fmt"

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

	v := 0
	ok := false
	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		if v == 1 {
			ok = true
		}
	}

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

}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var res bool = false
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &m)
		if m == 1 {
			res = true
		}
	}
	if res == true {
		fmt.Println("-1")
	} else {
		fmt.Println(1)
	}
}

package main

import (
    "fmt"
)

func main() {
    var n, m int
    var res bool = false
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&m)
        if m == 1 {
            res = true
        }
    }
    if res == true {
        fmt.Println("-1")
    } else {
        fmt.Println("1")
    }
}

package main

import (
    "fmt"
    )

func main() {
    var n, i, sum uint
    fmt.Scan(&n)

    find := false
    for i = 0; i < n; i++ {
        var a uint
        fmt.Scan(&a)
        if a == 1 {
            find = true
        } else {
            sum += a
        }
    }

    if find {
        fmt.Println("-1")
    } else {
        fmt.Println(sum-1)
    }
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var res bool = false
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &m)
		if m == 1 {
			res = true
		}
	}
	if res {
		fmt.Println(-1)
	} else {
		fmt.Println(1)
	}
}

package main

import (
    "fmt"
)

func main() {
    var n, m int
    var res bool = false
    fmt.Scanf("%d", &n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &m)
        if m == 1 {
            res = true
        }
    }
    if res == true {
        fmt.Println("-1")
    } else {
        fmt.Println("1")
    }
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var res bool = false
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &m)
		if m == 1 {
			res = true
		}
	}
	if res == true {
		fmt.Println("-1")
	} else {
		fmt.Println(1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var res bool = false
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &m)
		if m == 1 {
			res = true
		}
	}
	if res == true {
		fmt.Println(-1)
	} else {
		fmt.Println(1)
	}
}


package main

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

func main() {
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

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

	var n, m int
	var sky [1000][1000]byte
	Fscan(in, &n, &m)
	for i := 0; i < n; i++ {
		var s string
		Fscan(in, &s)
		copy(sky[i][:], s)
	}

	var marks [1000][1000]bool
	var maxLen [1000][1000]int

	valid := func(i, j, len int) bool {
		left := j+len < m && sky[i][j+len] == '*'
		right := j-len >= 0 && sky[i][j-len] == '*'

		top := i-len >= 0 && sky[i-len][j] == '*'
		down := i+len < n && sky[i+len][j] == '*'

		return left && right && top && down
	}

	findRightLen := func(i, j int) int {
		if !marks[i][j-1] {
			return 0
		}
		for k := j - 1; k >= 1; k-- {
			if sky[i][k] != '*' {
				return 0
			}
			l := maxLen[i][k]
			if l > 0 {
				return max(0, l-(j-k))
			}
		}
		return 0
	}

	findDownLen := func(i, j int) int {
		if !marks[i-1][j] {
			return 0
		}
		for k := i - 1; k >= 1; k-- {
			if sky[k][j] != '*' {
				return 0
			}
			l := maxLen[k][j]
			if l > 0 {
				return max(0, l-(i-k))
			}
		}
		return 0
	}

	mark := func(x, y, len int) {
		for j := y - len; j <= y+len; j++ {
			marks[x][j] = true
		}
		for i := x - len; i <= x+len; i++ {
			marks[i][y] = true
		}
	}

	var ans []int
	for i := 1; i < n-1; i++ {
		for j := 1; j < m-1; j++ {
			if sky[i][j] == '*' {
				rightLen := findRightLen(i, j)
				downLen := findDownLen(i, j)

				l := min(rightLen, downLen)

				for ; valid(i, j, l+1); l++ {
				}

				if l > 0 {
					maxLen[i][j] = l
					mark(i, j, l)
					ans = append(ans, i,j,l)
				}

			}
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if sky[i][j] == '*' && !marks[i][j] {
				Fprintln(out, -1)
				return
			}
		}
	}

	l := len(ans)
	Fprintln(out, l/3)
	for i := 0; i < l; i+=3 {
		Fprintln(out, ans[i]+1, ans[i+1]+1, ans[i+2])
	}
}

package main

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

const (
	N = 1024
	M = 1024
)

type star struct {
	i, j int
	len  int
}

var n, m int
var pic [N][M]byte
var res [N][M]byte
var maxRay, h, v, left, right, up, down [N][M]int
var stars []star

func min(args ... int) int {
	m := args[0]
	for _, v := range args[1:] {
		if v < m {
			m = v
		}
	}
	return m
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Fscanf(buf, "%c", &pic[i][j])
		}
		fmt.Fscanf(buf, "\n")
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if pic[i][j] == '*' {
				up[i][j]++
				left[i][j]++
				if i > 0 {
					up[i][j] += up[i-1][j]
				}
				if j > 0 {
					left[i][j] += left[i][j-1]
				}
			}
		}
	}

	for i := n - 1; i >= 0; i-- {
		for j := m - 1; j >= 0; j-- {
			if pic[i][j] == '*' {
				down[i][j]++
				right[i][j]++
				if i < n-1 {
					down[i][j] += down[i+1][j]
				}
				if j < m-1 {
					right[i][j] += right[i][j+1]
				}
			}
		}
	}

	stars = make([]star, 0)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			mray := min(up[i][j], down[i][j], left[i][j], right[i][j]) - 1
			if mray > 0 {
				stars = append(stars, star{i, j, mray})
			}
		}
	}

	for i := 0; i < len(stars); i++ {
		x := stars[i].i
		y := stars[i].j
		l := stars[i].len
		v[x - l][y]++
		v[x + l + 1][y]--
		h[x][y - l]++
		h[x][y + l + 1]--
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if i > 0 {
				v[i][j] += v[i - 1][j]
			}
			if j > 0 {
				h[i][j] += h[i][j - 1]
			}
		}
	}

	//for i := 0; i < n; i++ {
	//	for j := 0; j < m; j++ {
	//		fmt.Printf("%d ", v[i][j])
	//	}
	//	fmt.Println()
	//}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if v[i][j] > 0 || h[i][j] > 0 {
				res[i][j] = '*'
			} else {
				res[i][j] = '.'
			}
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	if res == pic {
		fmt.Fprintln(writer, len(stars))
		for i := 0; i < len(stars); i++ {
			fmt.Fprintln(writer, stars[i].i + 1, stars[i].j + 1, stars[i].len)
		}
	} else {
		fmt.Fprintln(writer, -1)
	}
	writer.Flush()

}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]bool, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]bool, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			if s[j] == '*' {
				starts[i][j] = true
			}
		}
	}

	result := make([]int, 0)

	for x := 1; x < n - 1; x++ {

		for y := 1; y < m - 1; y++ {

			if starts[x][y] {

				length := 1

				for {

					if x - length < 0 || x + length >= n {
						break
					}
					if y - length < 0 || y + length >= m {
						break
					}

					f := true

					if !starts[x + length][y] {
						f = false
					}
					if !starts[x - length][y] {
						f = false
					}
					if !starts[x][y + length] {
						f = false
					}
					if !starts[x][y - length] {
						f = false
					}
					if !f {
						break
					}

					used[x][y] = true
					used[x + length][y] = true
					used[x - length][y] = true
					used[x][y + length] = true
					used[x][y - length] = true

					if length == 1 {
						result = append(result, x)
						result = append(result, y)
						result = append(result, length)
					} else {
						result[len(result) - 1] = length
					}

					length++

				}

			}

		}

	}

	check := true
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if starts[i][j] && !used[i][j] {
				check = false
				break
			}
		}
	}

	if !check {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

package main

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

func main() {
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

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

	var n, m int
	var sky [1000][1000]byte
	Fscan(in, &n, &m)
	for i := 0; i < n; i++ {
		var s string
		Fscan(in, &s)
		copy(sky[i][:], s)
	}

	var marks [1000][1000]bool
	var maxLen [1000][1000]int

	valid := func(i, j, len int) bool {
		left := j+len < m && sky[i][j+len] == '*'
		right := j-len >= 0 && sky[i][j-len] == '*'

		top := i-len >= 0 && sky[i-len][j] == '*'
		down := i+len < n && sky[i+len][j] == '*'

		return left && right && top && down
	}

	findRightLen := func(i, j int) int {
		if !marks[i][j-1] {
			return 0
		}
		for k := j - 1; k >= 1; k-- {
			if sky[i][k] != '*' {
				return 0
			}
			l := maxLen[i][k]
			if l > 0 {
				return max(0, l-(j-k))
			}
		}
		return 0
	}

	findDownLen := func(i, j int) int {
		if !marks[i-1][j] {
			return 0
		}
		for k := i - 1; k >= 1; k-- {
			if sky[k][j] != '*' {
				return 0
			}
			l := maxLen[k][j]
			if l > 0 {
				return max(0, l-(i-k))
			}
		}
		return 0
	}

	mark := func(x, y, len int) {
		for j := y - len; j <= y+len; j++ {
			marks[x][j] = true
		}
		for i := x - len; i <= x+len; i++ {
			marks[i][y] = true
		}
	}

	var ans []int
	for i := 1; i < n-1; i++ {
		for j := 1; j < m-1; j++ {
			if sky[i][j] == '*' {
				rightLen := findRightLen(i, j)
				downLen := findDownLen(i, j)

				l := min(rightLen, downLen)

				for ; valid(i, j, l+1); l++ {
				}

				if l > 0 {
					maxLen[i][j] = l
					mark(i, j, l)
					ans = append(ans, i, j, l)
				}
			}
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if sky[i][j] == '*' && !marks[i][j] {
				Fprintln(out, -1)
				return
			}
		}
	}
	Fprintln(out, len(ans)/3)
	for i := 0; i < len(ans); i += 3 {
		Fprintln(out, ans[i]+1, ans[i+1]+1, ans[i+2])
	}
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]byte, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]byte, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			starts[i][j] = s[j]
		}
	}

	result := make([]int, 0)

	for x := 0; x < n; x++ {
		for y := 0; y < m; y++ {
			if starts[x][y] == '*' {
				length := 1
				for findStart(starts, x, y, length) {
					used[x][y] = true
					for i := 1; i <= length; i++ {
						used[x + i][y] = true
						used[x - i][y] = true
						used[x][y + i] = true
						used[x][y - i] = true
					}
					result = append(result, x)
					result = append(result, y)
					result = append(result, length)
					length++
				}
			}
		}
	}

	if !check(starts, used) {
		fmt.Fprintln(out, "NO")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

func findStart(starts [][]byte, x, y int, length int) bool{

	defer func() {
		_ = recover()
	}()

	f := true
	for i := 1; i <= length; i++ {
		if starts[x + i][y] != '*' {
			f = false
			break
		}
		if starts[x - i][y] != '*' {
			f = false
			break
		}
		if starts[x][y + i] != '*' {
			f = false
			break
		}
		if starts[x][y - i] != '*' {
			f = false
			break
		}
	}

	return f

}

func check(starts [][]byte, used [][]bool) bool {
	f := true
	for i := 0; i < len(starts); i++ {
		for j := 0; j < len(starts[i]); j++ {
			if starts[i][j] == '*' && !used[i][j] {
				f = false
				break
			}
		}
	}
	return f
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]byte, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]byte, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			starts[i][j] = s[j]
		}
	}

	result := make([]int, 0)

	for x := 0; x < n; x++ {
		for y := 0; y < m; y++ {
			if starts[x][y] == '*' {
				length := 1
				for findStart(starts, x, y, length) {
					for i := 1; i <= length; i++ {
						used[x + i][y] = true
						used[x - i][y] = true
						used[x][y + i] = true
						used[x][y - i] = true
					}
					result = append(result, x)
					result = append(result, y)
					result = append(result, length)
					length++
				}
			}
		}
	}

	if check(starts, used) {
		fmt.Fprintln(out, "NO")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

func findStart(starts [][]byte, x, y int, length int) bool{

	defer func() {
		_ = recover()
	}()

	f := true
	for i := 1; i <= length; i++ {
		if starts[x + i][y] != '*' {
			f = false
			break
		}
		if starts[x - i][y] != '*' {
			f = false
			break
		}
		if starts[x][y + i] != '*' {
			f = false
			break
		}
		if starts[x][y - i] != '*' {
			f = false
			break
		}
	}

	return f

}

func check(starts [][]byte, used [][]bool) bool {
	f := true
	for i := 0; i < len(starts); i++ {
		for j := 0; j < len(starts[i]); j++ {
			if starts[i][j] == '*' && !used[i][j] {
				f = false
				break
			}
		}
	}
	return f
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]byte, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]byte, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			starts[i][j] = s[j]
		}
	}

	result := make([]int, 0)

	for x := 0; x < n; x++ {
		for y := 0; y < m; y++ {
			if starts[x][y] == '*' {
				length := 1
				for findStart(starts, x, y, length) {
					used[x][y] = true
					for i := 1; i <= length; i++ {
						used[x + i][y] = true
						used[x - i][y] = true
						used[x][y + i] = true
						used[x][y - i] = true
					}
					result = append(result, x)
					result = append(result, y)
					result = append(result, length)
					length++
				}
			}
		}
	}

	if !check(starts, used) || len(result) == 0 {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

func findStart(starts [][]byte, x, y int, length int) bool{

	defer func() {
		_ = recover()
	}()

	f := true
	for i := 1; i <= length; i++ {
		if starts[x + i][y] != '*' {
			f = false
			break
		}
		if starts[x - i][y] != '*' {
			f = false
			break
		}
		if starts[x][y + i] != '*' {
			f = false
			break
		}
		if starts[x][y - i] != '*' {
			f = false
			break
		}
	}

	return f

}

func check(starts [][]byte, used [][]bool) bool {
	f := true
	for i := 0; i < len(starts); i++ {
		for j := 0; j < len(starts[i]); j++ {
			if starts[i][j] == '*' && !used[i][j] {
				f = false
				break
			}
		}
	}
	return f
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]byte, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]byte, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			starts[i][j] = s[j]
		}
	}

	result := make([]int, 0)

	for x := 0; x < n; x++ {
		for y := 0; y < m; y++ {

			if starts[x][y] == '*' {

				length := 1

				for findStart(starts, x, y, length) {

					used[x][y] = true
					used[x + length][y] = true
					used[x - length][y] = true
					used[x][y + length] = true
					used[x][y - length] = true

					result = append(result, x)
					result = append(result, y)
					result = append(result, length)

					length++
				}

			}

		}
	}

	if !check(starts, used) {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

func findStart(starts [][]byte, x, y int, length int) bool{

	defer func() {
		_ = recover()
	}()

	if x - length < 0 || x + length >= len(starts) {
		return false
	}
	if y - length < 0 || y + length >= len(starts[0]) {
		return false
	}

	f := true
	for i := 1; i <= length; i++ {
		if starts[x + i][y] != '*' {
			f = false
			break
		}
		if starts[x - i][y] != '*' {
			f = false
			break
		}
		if starts[x][y + i] != '*' {
			f = false
			break
		}
		if starts[x][y - i] != '*' {
			f = false
			break
		}
	}

	return f

}

func check(starts [][]byte, used [][]bool) bool {
	f := true
	for i := 0; i < len(starts); i++ {
		for j := 0; j < len(starts[i]); j++ {
			if starts[i][j] == '*' && !used[i][j] {
				f = false
				break
			}
		}
	}
	return f
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]byte, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]byte, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			starts[i][j] = s[j]
		}
	}

	result := make([]int, 0)

	for x := 0; x < n; x++ {
		for y := 0; y < m; y++ {
			if starts[x][y] == '*' {
				length := 1
				for findStart(starts, x, y, length) {
					used[x][y] = true
					for i := 1; i <= length; i++ {
						used[x + i][y] = true
						used[x - i][y] = true
						used[x][y + i] = true
						used[x][y - i] = true
					}
					result = append(result, x)
					result = append(result, y)
					result = append(result, length)
					length++
				}
			}
		}
	}

	if !check(starts, used) {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

func findStart(starts [][]byte, x, y int, length int) bool{

	defer func() {
		_ = recover()
	}()

	f := true
	for i := 1; i <= length; i++ {
		if starts[x + i][y] != '*' {
			f = false
			break
		}
		if starts[x - i][y] != '*' {
			f = false
			break
		}
		if starts[x][y + i] != '*' {
			f = false
			break
		}
		if starts[x][y - i] != '*' {
			f = false
			break
		}
	}

	return f

}

func check(starts [][]byte, used [][]bool) bool {
	f := true
	for i := 0; i < len(starts); i++ {
		for j := 0; j < len(starts[i]); j++ {
			if starts[i][j] == '*' && !used[i][j] {
				f = false
				break
			}
		}
	}
	return f
}

package main

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

func main() {
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

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

	var n, m int
	var sky [1000][1000]byte
	Fscan(in, &n, &m)
	for i := 0; i < n; i++ {
		var s string
		Fscan(in, &s)
		copy(sky[i][:], s)
	}

	var marks [1000][1000]bool
	var maxLen [1000][1000]int

	valid := func(i, j, len int) bool {
		left := j+len < m && sky[i][j+len] == '*'
		right := j-len >= 0 && sky[i][j-len] == '*'

		top := i-len >= 0 && sky[i-len][j] == '*'
		down := i+len < n && sky[i+len][j] == '*'

		return left && right && top && down
	}

	findRightLen := func(i, j int) int {
		if !marks[i][j-1] {
			return 0
		}
		for k := j - 1; k >= 1; k-- {
			if sky[i][k] != '*' {
				return 0
			}
			l := maxLen[i][k]
			if l > 0 {
				return max(0, l-(j-k))
			}
		}
		return 0
	}

	findDownLen := func(i, j int) int {
		if !marks[i-1][j] {
			return 0
		}
		for k := i - 1; k >= 1; k-- {
			if sky[k][j] != '*' {
				return 0
			}
			l := maxLen[k][j]
			if l > 0 {
				return max(0, l-(i-k))
			}
		}
		return 0
	}

	mark := func(x, y, len int) {
		for j := y - len; j <= y+len; j++ {
			marks[x][j] = true
		}
		for i := x - len; i <= x+len; i++ {
			marks[i][y] = true
		}
	}

	var ans []int
	for i := 1; i < n-1; i++ {
		for j := 1; j < m-1; j++ {
			if sky[i][j] == '*' {
				rightLen := findRightLen(i, j)
				downLen := findDownLen(i, j)

				l := min(rightLen, downLen)

				for ; valid(i, j, l+1); l++ {
				}

				if l > 0 {
					maxLen[i][j] = l
					mark(i, j, l)
					ans = append(ans, i,j,l)
				}

			}
		}
	}

	for i := 1; i < n-1; i++ {
		for j := 1; j < m-1; j++ {
			if sky[i][j] == '*' && !marks[i][j] {
				Fprintln(out, -1)
				return
			}
		}
	}

	l := len(ans)
	Fprintln(out, l/3)
	for i := 0; i < l; i+=3 {
		Fprintln(out, ans[i]+1, ans[i+1]+1, ans[i+2])
	}
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	starts, used := make([][]bool, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		starts[i] = make([]bool, m)
		used[i] = make([]bool, m)
	}

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			if s[j] == '*' {
				starts[i][j] = true
			}
		}
	}

	result := make([]int8, 0)

	for x := 1; x < n - 1; x++ {

		for y := 1; y < m - 1; y++ {

			if starts[x][y] {

				length := 1

				for {

					if x - length < 0 || x + length >= n {
						break
					}
					if y - length < 0 || y + length >= m {
						break
					}

					f := true

					if !starts[x + length][y] {
						f = false
					}
					if !starts[x - length][y] {
						f = false
					}
					if !starts[x][y + length] {
						f = false
					}
					if !starts[x][y - length] {
						f = false
					}
					if !f {
						break
					}

					used[x][y] = true
					used[x + length][y] = true
					used[x - length][y] = true
					used[x][y + length] = true
					used[x][y - length] = true

					if length == 1 {
						result = append(result, int8(x))
						result = append(result, int8(y))
						result = append(result, int8(length))
					} else {
						result[len(result) - 1] = int8(length)
					}

					length++

				}

			}

		}

	}

	check := true
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if starts[i][j] && !used[i][j] {
				check = false
				break
			}
		}
	}

	if !check {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintln(out, len(result) / 3)
		for i := 0; i < len(result); i += 3 {
			fmt.Fprintln(out, result[i] + 1, result[i + 1] + 1, result[i + 2])
		}
	}

}

package main

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

const (
	N = 1024
	M = 1024
)

type star struct {
	i, j int
	len  int
}

var n, m int
var pic [N][M]byte
var res [N][M]byte
var maxRay, h, v, left, right, up, down [N][M]int
var stars []star

func min(args ... int) int {
	m := args[0]
	for _, v := range args[1:] {
		if v < m {
			m = v
		}
	}
	return m
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Fscanf(buf, "%c", &pic[i][j])
		}
		fmt.Fscanf(buf, "\n")
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if pic[i][j] == '*' {
				up[i][j]++
				left[i][j]++
				if i > 0 {
					up[i][j] += up[i-1][j]
				}
				if j > 0 {
					left[i][j] += left[i][j-1]
				}
			}
		}
	}

	for i := n - 1; i >= 0; i-- {
		for j := m - 1; j >= 0; j-- {
			if pic[i][j] == '*' {
				down[i][j]++
				right[i][j]++
				if i < n-1 {
					down[i][j] += down[i+1][j]
				}
				if j < m-1 {
					right[i][j] += right[i][j+1]
				}
			}
		}
	}

	stars = make([]star, 0)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			mray := min(up[i][j], down[i][j], left[i][j], right[i][j]) - 1
			if mray > 0 {
				stars = append(stars, star{i, j, mray})
			}
		}
	}

	fmt.Println(stars)

	for i := 0; i < len(stars); i++ {
		x := stars[i].i
		y := stars[i].j
		l := stars[i].len
		v[x - l][y]++
		v[x + l + 1][y]--
		h[x][y - l]++
		h[x][y + l + 1]--
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if i > 0 {
				v[i][j] += v[i - 1][j]
			}
			if j > 0 {
				h[i][j] += h[i][j - 1]
			}
		}
	}

	//for i := 0; i < n; i++ {
	//	for j := 0; j < m; j++ {
	//		fmt.Printf("%d ", v[i][j])
	//	}
	//	fmt.Println()
	//}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if v[i][j] > 0 || h[i][j] > 0 {
				res[i][j] = '*'
			} else {
				res[i][j] = '.'
			}
		}
	}

	if res == pic {
		fmt.Println(len(stars))
		for i := 0; i < len(stars); i++ {
			fmt.Println(stars[i].i + 1, stars[i].j + 1, stars[i].len)
		}
	} else {
		fmt.Println(-1)
	}

}