package main

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

func gcd(x, y int)int{
	for y>0{
		t := x%y
		x = y
		y = t
	}
	return x
}
func lcm(x, y int)int{
	return x*y/gcd(x,y)
}
func abs(x int)int{
	if x<0{
		return -x
	}
	return x
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int,n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		ans := []int{}
		for i:=1;i<=n;i+=2{
			if n%2==1&&i==n{
				break
			}
			var x, y int
			if n%2==1&&i==n-2{
				if a[i]+a[i+2]!=0{
					y = a[i]+a[i+2]
					x = a[i+1]
					k := lcm(abs(x),abs(y))
					dx := k/abs(x)
					dy := k/abs(y)
					if x>0&&y>0{
						ans = append(ans,dy,-dx,dy)
					}
					if (x>0&&y<0)||(x<0&&y>0){
						ans = append(ans,dy,dx,dy)
					}
					if x<0&&y<0{
						ans = append(ans,dy,-dx,dy)
					}
				}else if a[i]+a[i+1]!=0{
					y = a[i]+a[i+1]
					x = a[i+2]
					k := lcm(abs(x),abs(y))
					dx := k/abs(x)
					dy := k/abs(y)
					if x>0&&y>0{
						ans = append(ans,dy,dy,-dx)
					}
					if (x>0&&y<0)||(x<0&&y>0){
						ans = append(ans,dy,dy,dx)
					}
					if x<0&&y<0{
						ans = append(ans,dy,dy,-dx)
					}
				}else{
					y=a[i+1]+a[i+2]
					x=a[i]
					k := lcm(abs(x),abs(y))
					dx := k/abs(x)
					dy := k/abs(y)
					if x>0&&y>0{
						ans = append(ans,-dx,dy,dy)
					}
					if (x>0&&y<0)||(x<0&&y>0){
						ans = append(ans,dx,dy,dy)
					}
					if x<0&&y<0{
						ans = append(ans,-dx,dy,dy)
					}
				}
				continue
			}else {
				x = a[i]
				y = a[i+1]
			}
			k := lcm(abs(x),abs(y))
			dx := k/abs(x)
			dy := k/abs(y)
			if x>0&&y>0{
				ans = append(ans,-dx,dy)
			}
			if (x>0&&y<0)||(x<0&&y>0){
				ans = append(ans,dx,dy)
			}
			if x<0&&y<0{
				ans = append(ans,-dx,dy)
			}
			if n%2==1&&i==n-2{
				ans = append(ans,dy)
			}
		}
		for i:=0;i<len(ans);i++{
			fmt.Fprintf(out,"%d ",ans[i])
		}
		fmt.Fprintln(out)
	}
}

package main

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

var n int

var a []int

var w *bufio.Writer

func main() {

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

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve()

	}
}

func solve() {
	//5 -2 10 -9 4
	//5* a1 + (-2) * a2 + 10 * a3 + (-9)*a4 + 4 * a5 == 0

	if n % 2 == 0 {
		for i := 0; i < n; i+=2 {
			g := GCD(a[i + 1], a[i])

			a1 := a[i + 1]/g
			a0 := a[i]/g

			fmt.Fprint(w, -a1)
			fmt.Fprint(w," ")
			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
		}
		fmt.Fprintln(w)
	 } else {
		for i := 0; i < n - 3; i+=2 {
			g := GCD(a[i + 1], a[i])

			a1 := a[i + 1]/g
			a0 := a[i]/g

			fmt.Fprint(w, -a1)
			fmt.Fprint(w," ")
			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
		}

		if a[n - 1] + a[n - 2] != 0 {
			d := a[n - 1] + a[n - 2]

			g := GCD(d, a[n - 3])

			a1 := d/g
			a0 := a[n - 3]/g

			fmt.Fprint(w, -a1)
			fmt.Fprint(w," ")
			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
			fmt.Fprintln(w)

		} else if a[n - 1] + a[n - 3] != 0 {
			d := a[n - 1] + a[n - 3]

			g := GCD(d, a[n - 2])

			a1 := d/g
			a0 := a[n - 2]/g

			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
			fmt.Fprint(w, -a1)
			fmt.Fprint(w, " ")
			fmt.Fprint(w, a0)
			fmt.Fprint(w, " ")
			fmt.Fprintln(w)

		} else {
			d := a[n - 2] + a[n - 3]

			g := GCD(d, a[n - 1])

			a1 := d/g
			a0 := a[n - 1]/g

			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
			fmt.Fprint(w, a0)
			fmt.Fprint(w," ")
			fmt.Fprint(w, -a1)
			fmt.Fprint(w," ")
			fmt.Fprintln(w)

		}

	}
	w.Flush()

}

// greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a % b)
}

func main() {
	var T int
	scanf("%d", &T)
	for t := 0; t < T; t++ {
		var n int
		scanf("\n%d\n", &n)
		arr := make([]int,n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		brr := make([]int, n)
		round := n / 2 * 2
		for i := 0; i < round; i += 2 {
			lcm := arr[i] * arr[i + 1] / gcd(arr[i], arr[i + 1])
			brr[i] -= lcm / arr[i]
			brr[i + 1] += lcm / arr[i + 1]
		}
		if n % 2 == 1 {
			lcm := arr[n - 1] * arr[n - 2] / gcd(arr[n - 1], arr[n - 2])
			if brr[n - 2] - lcm / arr[n - 2] != 0 {
				brr[n - 2] -= lcm / arr[n - 2]
				brr[n - 1] += lcm / arr[n - 1]
			} else {
				brr[n - 2] += lcm / arr[n - 2]
				brr[n - 1] -= lcm / arr[n - 1]
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", brr[i])
		}
		fmt.Printf("\n")
	}
}

package main

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

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

func CF1582D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n int
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n)
		arr := make([]int64, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}

		res := make([]int64, n)
		if n%2 == 0 {
			for i := 0; i < n; i += 2 {
				if (arr[i] > 0 && arr[i+1] > 0) || (arr[i] < 0 && arr[i+1] < 0) {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = -arr[i+1]
					res[i+1] = arr[i]
				}
			}
		} else {
			for i := 0; i < n-3; i += 2 {
				if (arr[i] > 0 && arr[i+1] > 0) || (arr[i] < 0 && arr[i+1] < 0) {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = -arr[i+1]
					res[i+1] = arr[i]
				}
			}

			a, b := arr[n-3], arr[n-2]+arr[n-1]
			aIdx, bIdx, cIdx := n-3, n-2, n-1
			if a == 0 || b == 0 {
				a, b = arr[n-2] , arr[n-3]+arr[n-1]
				aIdx, bIdx, cIdx = n-2, n-3, n-1
				if a == 0 || b == 0 {
					a, b = arr[n-1] , arr[n-3]+arr[n-2]
					aIdx, bIdx, cIdx = n-1, n-3, n-2
				}
			}
			if (a > 0 && b > 0) || (a < 0 && b < 0) {
				res[aIdx] = b
				res[bIdx] = -a
				res[cIdx] = -a
			} else {
				res[aIdx] = -b
				res[bIdx] = a
				res[cIdx] = a
			}
		}
		for _, v := range res {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w)
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			first := ARR[1]
			Midd := ARR[2]
			Last := ARR[3]
			var F, M, L int
			Pos := 0
			Neg := 0
			if first > 0 {
				Pos++
			} else {
				Neg++
			}
			if Midd > 0 {
				Pos++
			} else {
				Neg++
			}
			if Last > 0 {
				Pos++
			} else {
				Neg++
			}
			if Pos*Neg != 0 {
				if ABS(first) == ABS(Midd) && ABS(Midd) == ABS(Last) {
					if first == Midd {
						if Midd == Last {
							F = -1
							M = -1
							L = 2
						} else {
							F = 1
							M = 1
							L = 2
						}
					} else {
						if first == Last {
							F = 1
							L = 1
							M = 2
						} else {
							M = 1
							L = 1
							F = 2
						}
					}
				} else {
					One := first + Midd
					Two := Midd + Last
					Thr := first + Last
					l := 0
					if One != 0 && ABS(One) <= 10000 {
						F = Last
						M = Last
						L = -One
						l = 1
					}

					if Two != 0 && ABS(Two) <= 10000 && l == 0 {
						F = -Two
						M = first
						L = first
						l = 1
					}
					if Thr != 0 && ABS(Thr) <= 10000 && l == 0 {
						F = Midd
						M = -Thr
						L = Midd
					}

				}
			} else {
				if ABS(first) == ABS(Midd) && ABS(Midd) == ABS(Last) {
					F = -1
					M = -1
					L = 2
				} else {
					One := first - Midd
					Two := Midd - Last
					Thr := first - Last
					l := 0
					if One != 0 && ABS(One) <= 10000 {
						F = -Last
						M = Last
						L = One
						l = 1
					}

					if Two != 0 && ABS(Two) <= 10000 && l == 0 {
						F = Two
						M = -first
						L = first
						l = 1
					}
					if Thr != 0 && ABS(Thr) <= 10000 && l == 0 {
						F = -Midd
						M = Thr
						L = Midd
					}

				}
			}

			fmt.Println(F)
			fmt.Println(M)
			fmt.Println(L)

			q := (n / 2) + 2

			for i := n; i > 3; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}

		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

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

func Ans(ARR []int) {
	if len(ARR) < 2 {
		return
	}
	if len(ARR) == 2 {
		fmt.Println(ARR[1])
		fmt.Println(-ARR[0])
	} else {
		if len(ARR) == 3 {
			first := ARR[0]
			Midd := ARR[1]
			Last := ARR[2]
			var F, M, L int
			Pos := 0
			Neg := 0
			if first > 0 {
				Pos++
			} else {
				Neg++
			}
			if Midd > 0 {
				Pos++
			} else {
				Neg++
			}
			if Last > 0 {
				Pos++
			} else {
				Neg++
			}
			if Pos*Neg != 0 {
				if ABS(first) == ABS(Midd) && ABS(Midd) == ABS(Last) {
					if first == Midd {
						if Midd == Last {
							F = -1
							M = -1
							L = 2
						} else {
							F = 1
							M = 1
							L = 2
						}
					} else {
						if first == Last {
							F = 1
							L = 1
							M = 2
						} else {
							M = 1
							L = 1
							F = 2
						}
					}
				} else {
					One := first + Midd
					Two := Midd + Last
					Thr := first + Last
					l := 0
					if One != 0 && ABS(One) <= 10000 {
						F = Last
						M = Last
						L = -One
						l = 1
					}

					if Two != 0 && ABS(Two) <= 10000 && l == 0 {
						F = -Two
						M = first
						L = first
						l = 1
					}
					if Thr != 0 && ABS(Thr) <= 10000 && l == 0 {
						F = Midd
						M = -Thr
						L = Midd
					}

				}
			} else {
				if ABS(first) == ABS(Midd) && ABS(Midd) == ABS(Last) {
					F = -1
					M = -1
					L = 2
				} else {
					One := first - Midd
					Two := Midd - Last
					Thr := first - Last
					l := 0
					if One != 0 && ABS(One) <= 10000 {
						F = -Last
						M = Last
						L = One
						l = 1
					}

					if Two != 0 && ABS(Two) <= 10000 && l == 0 {
						F = Two
						M = -first
						L = first
						l = 1
					}
					if Thr != 0 && ABS(Thr) <= 10000 && l == 0 {
						F = -Midd
						M = Thr
						L = Midd
					}

				}
			}

			fmt.Println(F)
			fmt.Println(M)
			fmt.Println(L)
		} else {
			Q := make([]int, 0)
			P := make([]int, 0)
			P = append(P, ARR[0], ARR[1], ARR[2])
			p := len(ARR)
			for i := 3; i < p; i++ {
				Q = append(Q, ARR[i])
			}
			Ans(P)
			Ans(Q)
		}
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

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

		}
		Ans(ARR)

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			first := ARR[1]
			Midd := ARR[2]
			Last := ARR[3]
			var F, M, L int

			if ABS(first) == ABS(Midd) && ABS(Midd) == ABS(Last) {
				if first == Midd {
					if Midd == Last {
						F = -1
						M = -1
						L = 2
					} else {
						F = 1
						M = 1
						L = 2
					}
				} else {
					if first == Last {
						F = 1
						L = 1
						M = 2
					} else {
						M = 1
						L = 1
						F = 2
					}
				}
			} else {
				One := first + Midd
				Two := Midd + Last
				Thr := first + Last
				if One != 0 && ABS(One) <= 10000 {
					F = Last
					M = Last
					L = -One
				} else {
					if Two != 0 && ABS(Two) <= 10000 {
						F = -Two
						M = first
						L = first
					} else {
						if Thr != 0 && ABS(Thr) <= 10000 {
							F = Midd
							M = -Thr
							L = Midd
						}
					}
				}
			}

			fmt.Println(F)
			fmt.Println(M)
			fmt.Println(L)

			q := (n / 2) + 2

			for i := n; i > 3; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}

		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		Pos := 0
		Neg := 0
		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])
			if ARR[i] < 0 {
				Neg++
			} else {
				Pos++
			}

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			first := ARR[1]
			Midd := ARR[2]
			Last := ARR[3]
			var F, M, L int

			if math.Abs(float64(first)) == math.Abs(float64(Midd)) && math.Abs(float64(Midd)) == math.Abs(float64(Last)) {
				if first == Midd {
					if Midd == Last {
						F = -1
						M = -1
						L = 2
					} else {
						F = 1
						M = 1
						L = 2
					}
				} else {
					if first == Last {
						F = 1
						L = 1
						M = 2
					} else {
						M = 1
						L = 1
						F = 2
					}
				}
			} else {
				One := first + Midd
				Two := Midd + Last
				Thr := Last + first
				if One != 0 && math.Abs(float64(One)) <= 10000 {
					F = Last
					M = Last
					L = -One
				} else {
					if Two != 0 && math.Abs(float64(Two)) <= 10000 {
						F = -Two
						M = first
						L = first
					} else {
						if Thr != 0 && math.Abs(float64(Thr)) <= 10000 {
							F = Midd
							M = -Thr
							L = Midd
						}
					}
				}
			}

			fmt.Println(F)
			fmt.Println(M)
			fmt.Println(L)

			q := (n / 2) + 2

			for i := n; i > 3; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}

		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		Pos := 0
		Neg := 0
		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])
			if ARR[i] < 0 {
				Neg++
			} else {
				Pos++
			}

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			q := (n + 1) / 2
			first := ARR[1]
			Midd := ARR[q]
			Last := ARR[n]
			var F, M, L int

			if first != Midd && Midd != Last && Last != Midd {
				if first-Midd <= 10000 && first-Midd >= -10000 {
					F = -Last
					M = Last
					L = first - Midd
				} else {
					if Last-first <= 10000 && Last-first >= -10000 {
						F = -Midd
						M = first - Last
						L = Midd
					} else {
						if Last-Midd <= 10000 && Last-Midd >= -10000 {
							F = Last - Midd
							M = first
							L = -first
						}
					}
				}

			} else {
				if first == Midd {
					if Last != 1 && Last != -1 && Last != -2 {
						F = -(Last / 2)
						M = -(Last + 1) / 2
						L = first
					} else {
						F = -Last
						M = -Last
						L = first
					}
				} else {
					if first == Last {
						if Midd != 1 && Midd != -1 && Midd != -2 {
							F = -(Midd / 2)
							L = -(Midd + 1) / 2
							M = first
						} else {
							F = -Midd
							M = -Midd
							L = first
						}
					} else {
						if first != 1 && first != -1 && first != -2 {
							M = -first / 2
							L = -(first + 1) / 2
							F = Midd
						} else {
							F = -first
							M = -first
							L = Last
						}
					}
				}
			}
			fmt.Println(F)
			for i := n - 1; i > q; i-- {
				fmt.Println(-ARR[i])
			}

			fmt.Println(M)
			for i := q - 1; i > 1; i-- {
				fmt.Println(ARR[i])
			}
			fmt.Println(L)
		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		Pos := 0
		Neg := 0
		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])
			if ARR[i] < 0 {
				Neg++
			} else {
				Pos++
			}

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			q := (n + 1) / 2
			first := ARR[1]
			Midd := ARR[q]
			Last := ARR[n]
			var F, M, L int

			if first != Midd && Midd != Last && Last != Midd {
				if first-Midd <= 10000 && first-Midd >= -10000 {
					F = -Last
					M = Last
					L = first - Midd
				} else {
					if Last-first <= 10000 && Last-first >= -10000 {
						F = -Midd
						M = first - Last
						L = Midd
					} else {
						if Last-Midd <= 10000 && Last-Midd >= -10000 {
							F = Last - Midd
							M = first
							L = -first
						}
					}
				}

			} else {
				if first == Midd {
					if Last != 1 && Last != -1 {
						F = -(Last / 2)
						M = -(Last + 1) / 2
						L = first
					} else {
						F = -Last
						M = -Last
						L = first
					}
				} else {
					if first == Last {
						if Midd != 1 && Midd != -1 {
							F = -(Midd / 2)
							L = -(Midd + 1) / 2
							M = first
						} else {
							F = -Midd
							M = -Midd
							L = first
						}
					} else {
						if first != 1 && first != -1 {
							M = -first / 2
							L = -(first + 1) / 2
							F = Midd
						} else {
							F = -first
							M = -first
							L = Last
						}
					}
				}
			}
			fmt.Println(F)
			for i := n - 1; i > q; i-- {
				fmt.Println(-ARR[i])
			}

			fmt.Println(M)
			for i := q - 1; i > 1; i-- {
				fmt.Println(ARR[i])
			}
			fmt.Println(L)
		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		Pos := 0
		Neg := 0
		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])
			if ARR[i] < 0 {
				Neg++
			} else {
				Pos++
			}

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			q := (n + 1) / 2
			first := ARR[1]
			Midd := ARR[q]
			Last := ARR[n]
			var F, M, L int

			if first != Midd && Midd != Last && Last != Midd {
				if first-Midd <= 10000 && first-Midd >= -10000 {
					F = -Last
					M = Last
					L = first - Midd
				} else {
					if Last-first <= 10000 && Last-first >= -10000 {
						F = -Midd
						M = first - Last
						L = Midd
					} else {
						if Last-Midd <= 10000 && Last-Midd >= -10000 {
							F = Last - Midd
							M = first
							L = -first
						}
					}
				}

			} else {
				if first == Midd {
					F = -(Last / 2)
					M = -(Last + 1) / 2
					L = first
				} else {
					if first == Last {
						F = -(Midd / 2)
						L = -(Midd + 1) / 2
						M = first
					} else {
						M = -first / 2
						L = -(first + 1) / 2
						F = Midd
					}
				}
			}
			fmt.Println(F)
			for i := n - 1; i > q; i-- {
				fmt.Println(-ARR[i])
			}

			fmt.Println(M)
			for i := q - 1; i > 1; i-- {
				fmt.Println(ARR[i])
			}
			fmt.Println(L)
		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

// for o := 0; o < t; o++ {
// 	var a, b, c int
// 	fmt.Fscan(input, &a, &b, &c)

// 	A := a % 2
// 	B := b % 2
// 	C := c % 2
// 	if A+B+C == 0 {
// 		fmt.Println(0)
// 	}
// 	if A+B+C == 1 {
// 		if A == 1 {
// 			fmt.Println(1)
// 		}
// 		if B == 1 {
// 			if a >= 2 {
// 				fmt.Println(0)
// 			} else {
// 				fmt.Println(2)
// 			}
// 		}
// 		if C == 1 {
// 			if a > 0
// 			fmt.Println(1)
// 		}
// 	}
// 	if A+B+C == 2 {

// 	}
// 	if A+B+C == 3 {
// 		fmt.Println(0)
// 	}

// }

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		Pos := 0
		Neg := 0
		ARR := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &ARR[i])
			if ARR[i] < 0 {
				Neg++
			} else {
				Pos++
			}

		}
		if n%2 == 0 {
			q := n / 2
			for i := n; i > 0; i-- {
				if i > q {
					fmt.Println(-ARR[i])
				} else {
					fmt.Println(ARR[i])

				}
			}
		} else {
			q := (n + 1) / 2
			first := ARR[1]
			Midd := ARR[q]
			Last := ARR[n]

			var F, M, L int
			if first-Midd <= 10000 && first-Midd >= -10000 {
				F = -Last
				M = Last
				L = first - Midd
			} else {
				if Last-first <= 10000 && Last-first >= -10000 {
					F = -Midd
					M = first - Last
					L = Midd
				} else {
					if Last-Midd <= 10000 && Last-Midd >= -10000 {
						F = Last - Midd
						M = first
						L = -first
					}
				}
			}

			fmt.Println(F)
			for i := n - 1; i > q; i-- {
				fmt.Println(-ARR[i])
			}

			fmt.Println(M)
			for i := q - 1; i > 1; i-- {
				fmt.Println(ARR[i])
			}
			fmt.Println(L)
		}

	}

}

package main

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

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

func CF1582D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n int
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n)
		arr := make([]int64, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}

		res := make([]int64, n)
		if n%2 == 0 {
			for i := 0; i < n; i += 2 {
				if (arr[i] > 0 && arr[i+1] > 0) || (arr[i] < 0 && arr[i+1] < 0) {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = -arr[i+1]
					res[i+1] = arr[i]
				}
			}
		} else {
			for i := 0; i < n-3; i += 2 {
				if (arr[i] > 0 && arr[i+1] > 0) || (arr[i] < 0 && arr[i+1] < 0) {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = -arr[i+1]
					res[i+1] = arr[i]
				}
			}

			a, b := arr[n-3], arr[n-2]+arr[n-1]
			if (a > 0 && b > 0) || (a < 0 && b < 0) {
				res[n-3] = b
				res[n-2] = -a
				res[n-1] = -a
			} else {
				res[n-3] = -b
				res[n-2] = a
				res[n-1] = a
			}
		}
		for _, v := range res {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

func CF1582D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n int
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n)
		arr := make([]int64, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}

		res := make([]int64, n)
		if n%2 == 0 {
			for i := 0; i < n; i += 2 {
				if (arr[i] > 0 && arr[i+1] > 0) || (arr[i] < 0 && arr[i+1] < 0) {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = arr[i+1]
					res[i+1] = arr[i]
				}
			}
		} else {
			for i := 0; i < n-3; i += 2 {
				if (arr[i] > 0 && arr[i+1] > 0) || (arr[i] < 0 && arr[i+1] < 0) {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = arr[i+1]
					res[i+1] = arr[i]
				}
			}

			a, b := arr[n-3], arr[n-2]+arr[n-1]
			if (a > 0 && b > 0) || (a < 0 && b < 0) {
				res[n-3] = b
				res[n-2] = -a
				res[n-1] = -a
			} else {
				res[n-3] = -b
				res[n-2] = a
				res[n-1] = a
			}
		}
		for _, v := range res {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

func CF1582D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n int
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n)
		arr := make([]int64, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}

		res := make([]int64, n)
		if n%2 == 0 {
			for i := 0; i < n; i += 2 {
				if arr[i] > 0 && arr[i+1] > 0 || arr[i] < 0 && arr[i+1] < 0 {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = arr[i+1]
					res[i+1] = arr[i]
				}
			}
		} else {
			for i := 0; i < n-3; i += 2 {
				if arr[i] > 0 && arr[i+1] > 0 || arr[i] < 0 && arr[i+1] < 0 {
					res[i] = arr[i+1]
					res[i+1] = -arr[i]
				} else {
					res[i] = arr[i+1]
					res[i+1] = arr[i]
				}
			}

			a, b := arr[n-3], arr[n-2]+arr[n-1]
			if a > 0 && b > 0 || a < 0 && b < 0 {
				res[n-3] = b
				res[n-2] = -a
				res[n-1] = -a
			} else {
				res[n-3] = b
				res[n-2] = a
				res[n-1] = a
			}
		}
		for _, v := range res {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a % b)
}

func main() {
	var T int
	scanf("%d", &T)
	for t := 0; t < T; t++ {
		var n int
		scanf("\n%d\n", &n)
		arr := make([]int,n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		brr := make([]int, n)
		round := n / 2 * 2
		for i := 0; i < round; i += 2 {
			lcm := arr[i] * arr[i + 1] / gcd(arr[i], arr[i + 1])
			brr[i] -= lcm / arr[i]
			brr[i + 1] += lcm / arr[i + 1]
		}
		if n % 2 == 1 {
			lcm := arr[n - 1] * arr[n - 2] / gcd(arr[n - 1], arr[n - 2])
			if brr[n - 1] + lcm / arr[n - 1] != 0 {
				brr[n - 1] += lcm / arr[n - 1]
				brr[n - 2] -= lcm / arr[n - 2]
			} else {
				brr[n - 1] -= lcm / arr[n - 1]
				brr[n - 2] += lcm / arr[n - 2]
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", brr[i])
		}
		fmt.Printf("\n")
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a % b)
}

func main() {
	var T int
	scanf("%d", &T)
	for t := 0; t < T; t++ {
		var n int
		scanf("\n%d\n", &n)
		arr := make([]int,n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		brr := make([]int, n)
		round := n / 2 * 2
		for i := 0; i < round; i += 2 {
			lcm := arr[i] * arr[i + 1] / gcd(arr[i], arr[i + 1])
			brr[i] -= lcm / arr[i]
			brr[i + 1] += lcm / arr[i + 1]
		}
		if n % 2 == 1 {
			lcm := arr[n - 1] * arr[n - 2] / gcd(arr[n - 1], arr[n - 2])
			if brr[n - 1] > 0 {
				brr[n - 1] += lcm / arr[n - 1]
				brr[n - 2] -= lcm / arr[n - 2]
			} else {
				brr[n - 1] -= lcm / arr[n - 1]
				brr[n - 2] += lcm / arr[n - 2]
			}
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", brr[i])
		}
		fmt.Printf("\n")
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a % b)
}

func main() {
	var T int
	scanf("%d", &T)
	for t := 0; t < T; t++ {
		var n int
		scanf("\n%d\n", &n)
		arr := make([]int,n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		brr := make([]int, n)
		round := n / 2 * 2
		for i := 0; i < round; i += 2 {
			lcm := arr[i] * arr[i + 1] / gcd(arr[i], arr[i + 1])
			brr[i] -= lcm / arr[i]
			brr[i + 1] += lcm / arr[i + 1]
		}
		if n % 2 == 1 {
			lcm := arr[n - 1] * arr[n - 2] / gcd(arr[n - 1], arr[n - 2])
			brr[n - 1] += lcm / arr[n - 1]
			brr[n - 2] -= lcm / arr[n - 2]
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", brr[i])
		}
		fmt.Printf("\n")
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a % b)
}

func main() {
	var T int
	scanf("%d", &T)
	for t := 0; t < T; t++ {
		var n int
		scanf("\n%d\n", &n)
		arr := make([]int,n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		brr := make([]int, n)
		round := n / 2 * 2
		for i := 0; i < round; i += 2 {
			lcm := arr[i] * arr[i + 1] / gcd(arr[i], arr[i + 1])
			brr[i] -= lcm / arr[i]
			brr[i + 1] += lcm / arr[i + 1]
		}
		if n % 2 == 1 {
			lcm := arr[n - 1] * arr[n - 2] / gcd(arr[n - 1], arr[n - 2])
			brr[n - 1] -= lcm / arr[n - 1]
			brr[n - 2] += lcm / arr[n - 2]
		}
		for i := 0; i < n; i++ {
			fmt.Printf("%d ", brr[i])
		}
		fmt.Printf("\n")
	}
}

package main

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

var n int

var a []int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve()

	}
}

func solve() {
	//5 -2 10 -9 4
	//5* a1 + (-2) * a2 + 10 * a3 + (-9)*a4 + 4 * a5 == 0

	if n % 2 == 0 {
		for i := 0; i < n; i+=2 {
			g := GCD(a[i + 1], a[i])

			a1 := a[i + 1]/g
			a0 := a[i]/g

			fmt.Print(-a1)
			fmt.Print(" ")
			fmt.Print(a0)
			fmt.Print(" ")
		}
		fmt.Println()
	 } else {
		for i := 0; i < n - 3; i+=2 {
			g := GCD(a[i + 1], a[i])

			a1 := a[i + 1]/g
			a0 := a[i]/g

			fmt.Print(-a1)
			fmt.Print(" ")
			fmt.Print(a0)
			fmt.Print(" ")
		}

		d := a[n - 1] + a[n - 2]

		g := GCD(d, a[n - 3])

		a1 := d/g
		a0 := a[n - 3]/g

		fmt.Print(-a1)
		fmt.Print(" ")
		fmt.Print(a0)
		fmt.Print(" ")
		fmt.Print(a0)
		fmt.Print(" ")
		fmt.Println()
	}

}

// greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

package main

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

var n int

var a []int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve()

	}
}

func solve() {
	//5 -2 10 -9 4
	//5* a1 + (-2) * a2 + 10 * a3 + (-9)*a4 + 4 * a5 == 0

	if n % 2 == 0 {
		for i := 0; i < n; i+=2 {
			fmt.Print(-a[i + 1])
			fmt.Print(" ")
			fmt.Print(a[i])
			fmt.Print(" ")
		}
		fmt.Println()
	 } else {
		for i := 0; i < n - 3; i+=2 {
			fmt.Print(-a[i + 1])
			fmt.Print(" ")
			fmt.Print(a[i])
			fmt.Print(" ")
		}

		d := a[n - 1] + a[n - 2]

		fmt.Print(-d)
		fmt.Print(" ")
		fmt.Print(a[n - 3])
		fmt.Print(" ")
		fmt.Print(a[n - 3])
		fmt.Print(" ")
		fmt.Println()
	}

}

package main

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

func gcd(x, y int)int{
	for y>0{
		t := x%y
		x = y
		y = t
	}
	return x
}
func lcm(x, y int)int{
	return x*y/gcd(x,y)
}
func abs(x int)int{
	if x<0{
		return -x
	}
	return x
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int,n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		ans := []int{}
		for i:=1;i<=n;i+=2{
			if n%2==1&&i==n{
				break
			}
			var x, y int
			if n%2==1&&i==n-2{
				if a[i]+a[i+2]!=0{
					y = a[i]+a[i+2]
					x = a[i+1]
					k := lcm(abs(x),abs(y))
					dx := k/abs(x)
					dy := k/abs(y)
					if x>0&&y>0{
						ans = append(ans,dy,-dx,dy)
					}
					if (x>0&&y<0)||(x<0&&y>0){
						ans = append(ans,dy,-dx,dy)
					}
					if x<0&&y<0{
						ans = append(ans,dy,-dx,dy)
					}
				}else if a[i]+a[i+1]!=0{
					y = a[i]+a[i+1]
					x = a[i+2]
					k := lcm(abs(x),abs(y))
					dx := k/abs(x)
					dy := k/abs(y)
					if x>0&&y>0{
						ans = append(ans,dy,dy,-dx)
					}
					if (x>0&&y<0)||(x<0&&y>0){
						ans = append(ans,dy,dy,-dx)
					}
					if x<0&&y<0{
						ans = append(ans,dy,dy,-dx)
					}
				}else{
					y=a[i+1]+a[i+2]
					x=a[i]
					k := lcm(abs(x),abs(y))
					dx := k/abs(x)
					dy := k/abs(y)
					if x>0&&y>0{
						ans = append(ans,-dx,dy,dy)
					}
					if (x>0&&y<0)||(x<0&&y>0){
						ans = append(ans,dx,dy,dy)
					}
					if x<0&&y<0{
						ans = append(ans,-dx,dy,dy)
					}
				}
				continue
			}else {
				x = a[i]
				y = a[i+1]
			}
			k := lcm(abs(x),abs(y))
			dx := k/abs(x)
			dy := k/abs(y)
			if x>0&&y>0{
				ans = append(ans,-dx,dy)
			}
			if (x>0&&y<0)||(x<0&&y>0){
				ans = append(ans,dx,dy)
			}
			if x<0&&y<0{
				ans = append(ans,-dx,dy)
			}
			if n%2==1&&i==n-2{
				ans = append(ans,dy)
			}
		}
		for i:=0;i<len(ans);i++{
			fmt.Fprintf(out,"%d ",ans[i])
		}
		fmt.Fprintln(out)
	}
}


package main
import (
	"fmt"
)
func max(a,b int) int{
	if a>b {
		return a
	} else {
		return b
	}
}

func main() {
	var n,ans int
	var a [1001]int
	ans=0
	fmt.Scan(&n)
	for i:=0; i<n; i++{
		fmt.Scan(&a[i])
	}
	for i:=0; i<n; i++{
		l,r:=0,0
		for ; (i-l)>0 && a[i-l-1]<=a[i-l];l++ {}
		for ; (i+r)<n-1 && a[i+r]>=a[i+r+1];r++ {}
		ans = max(ans,l+r+1)
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var arr [1001]int
	max := -1

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}

	for i := 0; i < n; i++ {
		counter := 1
		for j := i; (j-1) >= 0 && arr[j] >= arr[j-1]; j-- {
			counter++
		}

		for j := i; (j+1) < n && arr[j] >= arr[j+1]; j++ {
			counter++
		}

		if max < counter {
			max = counter
		}
	}

	fmt.Println(max)

}

package main

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

func max(nums ...int) int {
	res := math.MinInt32
	for _, num := range nums {
		if num > res {
			res = num
		}
	}
	return res
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanInt := func() int {
		scanner.Scan()
		num, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		return num
	}

	n := scanInt()
	f, width := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		f[i] = scanInt()
	}

	for i := 0; i < n; i++ {
		left, right := i, i
		for (left > 0) && (f[left-1] <= f[left]) {
			left--
		}
		for (right < (n - 1)) && (f[right+1] <= f[right]) {
			right++
		}
		width[i] = right - left + 1
	}
	fmt.Println(max(width...))
}


package main

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

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

	var n, m, h int
	fmt.Fscanln(in, &n, &m, &h)

	marr := make([]int, m)
	narr := make([]int, n)

	for i := range marr {
		fmt.Fscan(in, &marr[i])
	}
	in.ReadLine()
	for i := range narr {
		fmt.Fscan(in, &narr[i])
	}
	in.ReadLine()

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			var cur int
			fmt.Fscan(in, &cur)

			if cur == 0 {
				fmt.Print(0, " ")
				continue
			}

			if narr[i] < marr[j] {
				fmt.Print(narr[i], " ")
			} else {
				fmt.Print(marr[j], " ")
			}
		}
		fmt.Println()
		in.ReadLine()
	}
}

package main

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

func main() {
	sc := NewScanner()
	n, m, _ := sc.NextInt(), sc.NextInt(), sc.NextInt()
	a := sc.NextIntArray()
	b := sc.NextIntArray()

	ans := make([][]int, n)

	H := make([][]int, n)
	for i := 0; i < n; i++ {
		ans[i] = make([]int, m)
		H[i] = sc.NextIntArray()
	}

	for j := 0; j < m; j++ {
		for k := 0; k < n; k++ {
			if H[k][j] == 1 {
				//fmt.Println(k, j)
				ans[k][j] = min(a[j], b[k])
			}
		}
	}
	for i := 0; i < n; i++ {
		PrintI(ans[i]...)
	}
}

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

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

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

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

func maxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = max(s, v)
	}
	return s
}

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 (
	"bufio"
	"fmt"
	"os"
)

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

	var n, m, h int
	fmt.Fscanf(buf, "%d %d %d\n", &n, &m, &h)
	matn := make([]int, n+1)
	matm := make([]int, m+1)

	for i := 1; i <= m; i++ {
		fmt.Fscanf(buf, "%d", &matm[i])
	}
	fmt.Fscanf(buf, "\n")
	for i := 1; i <= n; i++ {
		fmt.Fscanf(buf, "%d", &matn[i])
	}
	fmt.Fscanf(buf, "\n")
	var val int
	for i:=1;i <= n;i++{
		for j:=1;j <= m;j++{
			fmt.Fscanf(buf, "%d", &val)
			if val == 0{
				fmt.Printf("0 ")
			}else{
				if matn[i] < matm[j]{
					fmt.Printf("%d ",matn[i])
				}else{
					fmt.Printf("%d ",matm[j])
				}

			}
		}
		fmt.Printf("\n")
		fmt.Fscanf(buf, "\n")
	}

}
/**
2 0 0 0 2 0 0
0 0 0 0 0 0 1
2 3 0 0 0 0 0
 */

package main

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

func main() {
    reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)

    arTemp := strings.Split(readLine(reader), " ")
    n64, err := strconv.ParseInt(arTemp[0], 10, 32)
    checkError(err)
    m64, err := strconv.ParseInt(arTemp[1], 10, 32)
    checkError(err)
    //h64, err := strconv.ParseInt(arTemp[2], 10, 32)
    //checkError(err)
    n := int32(n64)
    m := int32(m64)
    //h := int32(h64)

    a := make([]int32, m)
    b := make([]int32, n)
    ans := make([][]int32, n)

    arTemp = strings.Split(readLine(reader), " ")
    for i := int32(0); i < m; i++ {
        arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 32)
        checkError(err)
        arItem := int32(arItemTemp)
        a[i] = arItem
    }
    arTemp = strings.Split(readLine(reader), " ")
    for i := int32(0); i < n; i++ {
        arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 32)
        checkError(err)
        arItem := int32(arItemTemp)
        b[i] = arItem
    }
    for i := int32(0); i < n; i++ {
        ans[i] = make([]int32, m)
        arTemp = strings.Split(readLine(reader), " ")
        for j := int32(0); j < m; j++ {
            arItemTemp, err := strconv.ParseInt(arTemp[j], 10, 32)
            checkError(err)
            arItem := int32(arItemTemp)
            ans[i][j] = arItem
        }
    }

    for i := int32(0); i < n; i++ {
        for j := int32(0); j < m; j++ {
            if ans[i][j] == 1 {
                if a[j] < b[i] {
                    fmt.Print(a[j])
                } else {
                    fmt.Print(b[i])
                }
            } else {
                fmt.Print(0)
            }
            if j < (m - 1) {
                fmt.Print(" ")
            }
        }
        fmt.Println("")
    }
}

func readLine(reader *bufio.Reader) string {
    str, _, err := reader.ReadLine()
    if err == io.EOF {
        return ""
    }

    return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
    if err != nil {
        panic(err)
    }
}

package main

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

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

	var n, m, h int
	fmt.Fscanln(in, &n, &m, &h)

	marr := make([]int, m)
	narr := make([]int, n)

	for i := range marr {
		fmt.Fscan(in, &marr[i])
	}
	in.ReadLine()
	for i := range narr {
		fmt.Fscan(in, &narr[i])
	}
	in.ReadLine()

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			var cur int
			fmt.Fscan(in, &cur)

			if cur == 0 {
				fmt.Print(0, " ")
				continue
			}

			if narr[i] > marr[i] {
				fmt.Print(narr[i], " ")
			} else {
				fmt.Print(marr[i], " ")
			}
		}
		fmt.Println()
		in.ReadLine()
	}
}


package main

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

const INF int = 10000000

var a [100005]int
var minv, pos, sum [300005]int

func up(o int) {
	sum[o] = sum[o<<1] + sum[o<<1|1]
	if minv[o<<1] <= minv[o<<1|1] {
		minv[o] = minv[o<<1]
		pos[o] = pos[o<<1]
	} else {
		minv[o] = minv[o<<1|1]
		pos[o] = pos[o<<1|1]
	}
}

func build(o, l, r int) {
	if l >= r {
		minv[o] = a[l]
		pos[o] = l
		sum[o] = 1
		return
	}
	m := (l + r) >> 1
	build(o<<1, l, m)
	build(o<<1|1, m+1, r)
	up(o)
}

func query(L, R, o, l, r int) (x, y, z int) {
	if L <= l && r <= R {
		return minv[o], pos[o], sum[o]
	}
	m := (l + r) >> 1
	x, y = INF, INF
	z = 0
	if L <= m {
		x1, y1, z1 := query(L, R, o<<1, l, m)
		if x > x1 {
		    x = x1
		    y = y1
		} else if x == x1 {
		    if y > y1 {
		        y = y1
		    }
		}
		z += z1
	}
	if m < R {
		x1, y1, z1 := query(L, R, o<<1|1, m+1, r)
		if x > x1 {
		    x = x1
		    y = y1
		} else if x == x1 {
		    if y > y1 {
		        y = y1
		    }
		}
		z += z1
	}
	return
}

func update(x, o, l, r int) {
	if l >= r {
		minv[o] = INF
		pos[o] =  INF
		sum[o] = 0
		return
	}
	m := (l + r) >> 1
	if x <= m {
		update(x, o<<1, l, m)
	} else {
		update(x, o<<1|1, m+1, r)
	}
	up(o)
}

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n int
	var now = 1
	var ans int64 = 0
	fmt.Fscan(stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(stdin, &a[i])
	}
	build(1, 1, n)
	for sum[1] > 0 {
		_, nxt, cnt := query(now, n, 1, 1, n)
		if nxt != INF && a[nxt] == minv[1] {
			_, _, cnt = query(now, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		} else {
			ans += int64(cnt)
			_, nxt, cnt = query(1, now, 1, 1, n)
			_, _, cnt = query(1, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		}
		now = nxt
	}
	fmt.Println(ans)
}

package main

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

const INF int = 10000000

var a [100005]int
var minv, pos, sum [300005]int

func up(o int) {
	sum[o] = sum[o<<1] + sum[o<<1|1]
	if minv[o<<1] <= minv[o<<1|1] {
		minv[o] = minv[o<<1]
		pos[o] = pos[o<<1]
	} else {
		minv[o] = minv[o<<1|1]
		pos[o] = pos[o<<1|1]
	}
}

func build(o, l, r int) {
	if l >= r {
		minv[o] = a[l]
		pos[o] = l
		sum[o] = 1
		return
	}
	m := (l + r) >> 1
	build(o<<1, l, m)
	build(o<<1|1, m+1, r)
	up(o)
}

func query(L, R, o, l, r int) (x, y, z int) {
	if L <= l && r <= R {
		return minv[o], pos[o], sum[o]
	}
	m := (l + r) >> 1
	x, y = INF, INF
	z = 0
	if L <= m {
		x1, y1, z1 := query(L, R, o<<1, l, m)
		if x > x1 {
			x = x1
			y = y1
		} else if x == x1 {
			if y > y1 {
				y = y1
			}
		}
		z += z1
	}
	if m < R {
		x1, y1, z1 := query(L, R, o<<1|1, m+1, r)
		if x > x1 {
			x = x1
			y = y1
		} else if x == x1 {
			if y > y1 {
				y = y1
			}
		}
		z += z1
	}
	return
}

func update(x, o, l, r int) {
	if l >= r {
		minv[o] = INF
		pos[o] = INF
		sum[o] = 0
		return
	}
	m := (l + r) >> 1
	if x <= m {
		update(x, o<<1, l, m)
	} else {
		update(x, o<<1|1, m+1, r)
	}
	up(o)
}

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n int
	var now = 1
	var ans int64 = 0
	fmt.Fscan(stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(stdin, &a[i])
	}
	build(1, 1, n)
	for sum[1] > 0 {
		_, nxt, cnt := query(now, n, 1, 1, n)
		if nxt != INF && a[nxt] == minv[1] {
			_, _, cnt = query(now, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		} else {
			ans += int64(cnt)
			_, nxt, cnt = query(1, now, 1, 1, n)
			_, _, cnt = query(1, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		}
		now = nxt
	}
	fmt.Println(ans)
}

package main

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

const INF int = 10000000

var a [100005]int
var minv, pos, sum [300005]int

func up(o int) {
	sum[o] = sum[o<<1] + sum[o<<1|1]
	if minv[o<<1] <= minv[o<<1|1] {
		minv[o] = minv[o<<1]
		pos[o] = pos[o<<1]
	} else {
		minv[o] = minv[o<<1|1]
		pos[o] = pos[o<<1|1]
	}
}

func build(o, l, r int) {
	if l >= r {
		minv[o] = a[l]
		pos[o] = l
		sum[o] = 1
		return
	}
	m := (l + r) >> 1
	build(o<<1, l, m)
	build(o<<1|1, m+1, r)
	up(o)
}

func query(L, R, o, l, r int) (x, y, z int) {
	if L <= l && r <= R {
		return minv[o], pos[o], sum[o]
	}
	m := (l + r) >> 1
	x, y = INF, INF
	z = 0
	if L <= m {
		x1, y1, z1 := query(L, R, o<<1, l, m)
		if x > x1 {
		    x = x1
		    y = y1
		} else if x == x1 {
		    if y > y1 {
		        y = y1
		    }
		}
		z += z1
	}
	if m < R {
		x1, y1, z1 := query(L, R, o<<1|1, m+1, r)
		if x > x1 {
		    x = x1
		    y = y1
		} else if x == x1 {
		    if y > y1 {
		        y = y1
		    }
		}
		z += z1
	}
	return
}

func update(x, o, l, r int) {
	if l >= r {
		minv[o] = INF
		pos[o] =  INF
		sum[o] = 0
		return
	}
	m := (l + r) >> 1
	if x <= m {
		update(x, o<<1, l, m)
	} else {
		update(x, o<<1|1, m+1, r)
	}
	up(o)
}

func main() {
	stdin := bufio.NewReader(os.Stdin)
	stdout := bufio.NewWriter(os.Stdout)
	var n int
	var now = 1
	var ans int64 = 0
	fmt.Fscan(stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(stdin, &a[i])
	}
	build(1, 1, n)
	for sum[1] > 0 {
		_, nxt, cnt := query(now, n, 1, 1, n)
		if nxt != INF && a[nxt] == minv[1] {
			_, _, cnt = query(now, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		} else {
			ans += int64(cnt)
			_, nxt, cnt = query(1, now, 1, 1, n)
			_, _, cnt = query(1, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		}
		now = nxt
	}
	fmt.Fprintln(stdout, ans)
	stdout.Flush()
}

package main

import (
	"fmt"
)

const INF int = 10000000

var a [100005]int
var minv, pos, sum [300005]int

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

func up(o int) {
	sum[o] = sum[o<<1] + sum[o<<1|1]
	if minv[o<<1] <= minv[o<<1|1] {
		minv[o] = minv[o<<1]
		pos[o] = pos[o<<1]
	} else {
		minv[o] = minv[o<<1|1]
		pos[o] = pos[o<<1|1]
	}
}

func build(o, l, r int) {
	if l >= r {
		minv[o] = a[l]
		pos[o] = l
		sum[o] = 1
		return
	}
	m := (l + r) >> 1
	build(o<<1, l, m)
	build(o<<1|1, m+1, r)
	up(o)
}

func query(L, R, o, l, r int) (x, y int) {
	if L <= l && r <= R {
		return pos[o], sum[o]
	}
	m := (l + r) >> 1
	x = INF
	y = 0
	if L <= m {
		x1, y1 := query(L, R, o<<1, l, m)
		x = min(x, x1)
		y += y1
	}
	if m < R {
		x1, y1 := query(L, R, o<<1|1, m+1, r)
		x = min(x, x1)
		y += y1
	}
	return
}

func update(x, v, o, l, r int) {
	if l >= r {
		minv[o] = INF
		pos[o] =  INF
		sum[o] = 0
		return
	}
	m := (l + r) >> 1
	if x <= m {
		update(x, v, o<<1, l, m)
	} else {
		update(x, v, o<<1|1, m+1, r)
	}
	up(o)
}

func main() {
	var n int
	var now = 1
	var ans int64 = 0
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		fmt.Scan(&a[i])
	}
	build(1, 1, n)
	for sum[1] > 0 {
		nxt, cnt := query(now, n, 1, 1, n)
		if nxt != INF && a[nxt] == minv[1] {
			_, cnt = query(now, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, INF, 1, 1, n)
		} else {
			ans += int64(cnt)
			nxt, cnt = query(1, now, 1, 1, n)
			_, cnt = query(1, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, INF, 1, 1, n)
		}
		//fmt.Println(ans, nxt, sum[1])
		now = nxt
	}
	fmt.Println(ans)
}

package main

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

const INF int = 10000000

var a [100005]int
var minv, pos, sum [300005]int

func up(o int) {
	sum[o] = sum[o<<1] + sum[o<<1|1]
	if minv[o<<1] <= minv[o<<1|1] {
		minv[o] = minv[o<<1]
		pos[o] = pos[o<<1]
	} else {
		minv[o] = minv[o<<1|1]
		pos[o] = pos[o<<1|1]
	}
}

func build(o, l, r int) {
	if l >= r {
		minv[o] = a[l]
		pos[o] = l
		sum[o] = 1
		return
	}
	m := (l + r) >> 1
	build(o<<1, l, m)
	build(o<<1|1, m+1, r)
	up(o)
}

func query(L, R, o, l, r int) (x, y, z int) {
	if L <= l && r <= R {
		return minv[o], pos[o], sum[o]
	}
	m := (l + r) >> 1
	x, y = INF, INF
	z = 0
	if L <= m {
		x1, y1, z1 := query(L, R, o<<1, l, m)
		if x > x1 {
		    x = x1
		    y = y1
		} else if x == x1 {
		    if y > y1 {
		        y = y1
		    }
		}
		z += z1
	}
	if m < R {
		x1, y1, z1 := query(L, R, o<<1|1, m+1, r)
		if x > x1 {
		    x = x1
		    y = y1
		} else if x == x1 {
		    if y > y1 {
		        y = y1
		    }
		}
		z += z1
	}
	return
}

func update(x, o, l, r int) {
	if l >= r {
		minv[o] = INF
		pos[o] =  INF
		sum[o] = 0
		return
	}
	m := (l + r) >> 1
	if x <= m {
		update(x, o<<1, l, m)
	} else {
		update(x, o<<1|1, m+1, r)
	}
	up(o)
}

func main() {
	stdin := bufio.NewReader(os.Stdin)
	stdout := bufio.NewWriter(os.Stdout)
	var n int
	var now = 1
	var ans int64 = 0
	fmt.Fscan(stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(stdin, &a[i])
	}
	build(1, 1, n)
	for sum[1] > 0 {
		_, nxt, cnt := query(now, n, 1, 1, n)
		if nxt != INF && a[nxt] == minv[1] {
			_, _, cnt = query(now, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		} else {
			ans += int64(cnt)
			_, nxt, cnt = query(1, now, 1, 1, n)
			_, _, cnt = query(1, nxt, 1, 1, n)
			ans += int64(cnt)
			update(nxt, 1, 1, n)
		}
		now = nxt
	}
	fmt.Fprintln(stdout, ans)
}


package main

import (
    "fmt"
)

func main() {
    var n, k int
    fmt.Scanf("%d %d\n", &n, &k)
    var h = make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &h[i])
    }
    var idx = -1
    var ans = n
    for i := 0; i < n; i++ {
        //fmt.Printf("%d %d\n", i, h[i])
        var now = h[i] - k*i
        //fmt.Printf("%d\n", now)
        if now <= 0 {
            continue
        }
        //fmt.Printf("%d\n", now)
        var cur_ans = 0
        for j := 0; j < n; j++ {
            if now+j*k != h[j] {
                cur_ans++
            }
        }
        if ans > cur_ans {
            ans = cur_ans
            idx = i
        }
    }
    fmt.Printf("%d\n", ans)
    for i := 0; i < n; i++ {
        var target = h[idx] - (idx-i)*k
        if target > h[i] {
            fmt.Printf("+ %d %d\n", i+1, target-h[i])
        } else if target < h[i] {
            fmt.Printf("- %d %d\n", i+1, h[i]-target)
        }
    }
}

package main

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

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

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

	n, k := nextInt(), nextInt()

	a := make([]int, n+1)

	for i:=1; i<len(a); i++ {
		a[i] = nextInt()
	}

	max := 0
	min := 0
	notCut := 0
	minHeight := 0

	for i:=1; i<len(a); i++ {
		minHeight = a[i] - k*(i-1)
		if minHeight < 1 || min == minHeight {
			continue
		}

		notCut = 0
		for j:=1; j<len(a); j++ {
			if a[j] - k*(j-1) == minHeight {
				notCut++
			}
		}

		if notCut > max {
			max = notCut
			min = minHeight
		}
	}

	println(n - max)

	for i:=1 ; i<len(a); i++ {
		n = a[i] - k*(i-1)

		if n < min {
			println("+", i, min-n)
		}

		if n > min {
			println("-", i, n-min)
		}
	}
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1372D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	var sum, cur, ans int64
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
		sum += a[i]
	}
	for i := 0; i < n; i += 2 {
		cur += a[i]
	}
	for _, v := range a {
		if cur > ans {
			ans = cur
		}
		cur = sum - cur + v
	}
	Fprint(out, ans)
}

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

package main

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

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

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

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

type priorityQueue [][2]int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i][1] > pq[j][1]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.([2]int))
}

func (pq *priorityQueue) Pop() (res interface{}) {
	res = (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return res
}

var err error

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

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

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

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

	n := nextInt()
	arr, pre, end := make([]int64, n), make([]int64, n+2), make([]int64, n+2)
	for i := 0; i < n; i++ {
		arr[i] = nextLong()
		pre[i+2] = pre[i] + arr[i]
	}
	for i := n - 1; i >= 0; i-- {
		end[i] = end[i+2] + arr[i]
	}

	var res int64 = 0
	for i := 0; i < n; i++ {
		res = Max(res, pre[i+1]+end[i])
	}
	printf("%d\n", res)
}

package main

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

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

	n := readNum(reader)
	A := readNNums(reader, n)

	fmt.Println(solve(n, A))
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, A []int) int64 {
	m := (n + 1) / 2
	var cur int64
	for j := 0; j < m; j++ {
		cur += int64(A[(j*2)%n])
	}
	var ans = cur

	for j := 0; j < n; j++ {
		cur -= int64(A[(j*2)%n])
		cur += int64(A[((j+m)*2)%n])
		ans = max(ans, cur)
	}

	return ans
}

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

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()
	a := io.NextInts(n)
	p, s := make([]int64, n+2), make([]int64, n+2)
	for i, x := range a {
		p[i+2] = int64(x) + p[i]
	}
	for i := n - 1; i >= 0; i-- {
		s[i] = int64(a[i]) + s[i+2]
	}
	var ans int64
	for i := range a {
		if p[i+2]+s[i+1] > ans {
			ans = p[i+2] + s[i+1]
		}
	}
	io.Println(ans)
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}