package main

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

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

	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		has := map[int]bool{}
		c := [3]int{}
		mx := 0
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			has[v] = true
			c[v%3]++
			if v > mx {
				mx = v
			}
		}

		ans := mx / 3
		if mx%3 == 0 {
			if c[1] > 0 || c[2] > 0 {
				ans++
			}
		} else if mx%3 == 1 {
			ans++
			if c[2] > 0 && (has[1] || has[mx-1]) {
				ans++
			}
		} else {
			ans++
			if c[1] > 0 {
				ans++
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	mp := make(map[int]bool)
	for i := 0; i < n; i++ {
		mp[a[i]] = true
	}

	max := a[n - 1]

	var ans = max

	d2 := max/2
	pres := false

	for i := 0; i < n; i++ {
		if a[i] % 2 == 1 {
			pres = true
			break
		}
	}
	if pres {
		ans = min(ans, d2 + 1)
	} else {
		ans = min(ans, d2)
	}

	d3 := max/3

	onePres := false
	twoPres := false
	one := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			one = true
		}
		if a[i] % 3 == 1 {
			onePres = true
		}
		if a[i] % 3 == 2{
			twoPres = true
		}
	}
	if !onePres && !twoPres {
		ans = min(ans, d3)

	} else if (onePres && !twoPres) || (!onePres && twoPres) {
		ans = min(ans, d3 + 1)

	} else {
		if max % 3 == 0 {
			ans = min(ans, d3 + 1)
		} else {
			ans = min(ans, d3 + 2)
		}

		if max % 3 == 1 {
			//1 2 6 7
			yes := false
			for i := n - 2; i >= 0; i-- {
				if a[i] == max {
					continue
				}
				if a[i]/3 < d3 {
					break
				}
				yes = true
			}
			if !yes {
				if one {
					ans = min(ans, d3 + 2)
				} else {
					ans = min(ans, d3 + 1)
				}

			} else {
				ans = min(ans, d3 + 2)
			}

		} else {
			ans = min(ans, d3 + 2)
		}
	}

	return ans
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	var prices = make([]int, n)
	for i := range prices {
		scan(&prices[i])
	}
	var (
		check = func(a, b, c int) bool {
			for _, x := range prices {
				ok := false
				for cnt2 := 0; cnt2 <= b; cnt2++ {
					for cnt1 := 0; cnt1 <= c; cnt1++ {
						rem := cnt1*1 + cnt2*2
						if x-rem >= 0 && (x-rem)%3 == 0 && (x-rem)/3 <= a {
							ok = true
						}
					}
				}
				if !ok {
					return false
				}
			}
			return true
		}
		ans = 1 << 30
	)
	for b := 0; b <= 2; b++ {
		for c := 0; c <= 1; c++ {
			l, r := -1, int(1e9)/3+1
			for r-l > 1 {
				m := l + (r-l)/2
				if check(m, b, c) {
					r = m
				} else {
					l = m
				}
			}
			if ans > r+b+c {
				ans = r + b + c
			}
		}
	}
	printf("%v\n", ans)
}

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	mp := make(map[int]bool)
	for i := 0; i < n; i++ {
		mp[a[i]] = true
	}

	max := a[n - 1]

	var ans = max

	d2 := max/2
	pres := false

	for i := 0; i < n; i++ {
		if a[i] % 2 == 1 {
			pres = true
			break
		}
	}
	if pres {
		ans = min(ans, d2 + 1)
	} else {
		ans = min(ans, d2)
	}

	d3 := max/3

	onePres := false
	twoPres := false
	one := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			one = true
		}
		if a[i] % 3 == 1 {
			onePres = true
		}
		if a[i] % 3 == 2{
			twoPres = true
		}
	}
	if !onePres && !twoPres {
		ans = min(ans, d3)

	} else if (onePres && !twoPres) || (!onePres && twoPres) {
		ans = min(ans, d3 + 1)

	} else {
		if max % 3 == 0 {
			ans = min(ans, d3 + 1)
		} else {
			ans = min(ans, d3 + 2)
		}

		if max % 3 == 1 {
			//1 2 6 7
			yes := false
			for i := n - 2; i >= 0; i-- {
				if a[i] == max {
					continue
				}
				if a[i]/3 < d3 {
					break
				}
				yes = true
			}
			if !yes {
				if one {
					ans = min(ans, d3 + 2)
				}
				ans = min(ans, d3 + 1)
			} else {
				ans = min(ans, d3 + 2)
			}

		} else {
			ans = min(ans, d3 + 2)
		}
	}

	return ans
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	mp := make(map[int]bool)
	for i := 0; i < n; i++ {
		mp[a[i]] = true
	}

	max := a[n - 1]

	var ans = max

	d2 := max/2
	pres := false

	for i := 0; i < n; i++ {
		if a[i] % 2 == 1 {
			pres = true
			break
		}
	}
	if pres {
		ans = min(ans, d2 + 1)
	} else {
		ans = min(ans, d2)
	}

	d3 := max/3

	onePres := false
	twoPres := false

	for i := 0; i < n; i++ {
		if a[i] % 3 == 1 {
			onePres = true
		}
		if a[i] % 3 == 2{
			twoPres = true
		}
	}
	if !onePres && !twoPres {
		ans = min(ans, d3)

	} else if (onePres && !twoPres) || (!onePres && twoPres) {
		ans = min(ans, d3 + 1)

	} else {
		if max % 3 == 0 {
			ans = min(ans, d3 + 1)
		} else {
			ans = min(ans, d3 + 2)
		}

		if max % 3 == 1 {
			//1 2 6 7
			yes := false
			for i := n - 2; i >= 0; i-- {
				if a[i] == max {
					continue
				}
				if a[i]/3 < d3 {
					break
				}
				yes = true
			}
			if !yes {
				ans = min(ans, d3 + 1)
			} else {
				ans = min(ans, d3 + 2)
			}

		} else {
			ans = min(ans, d3 + 2)
		}
	}

	return ans
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	var d int

	max := a[n - 1]
	d = max/3

	var remZ bool
	var remO bool
	var remT bool

	if max % 3 == 0 {
		remZ  = true
	} else if max % 3 == 1 {
		remO = true
	} else {
		remT = true
	}

	for i := n - 2; i >= 0; i-- {
		if a[i]/3 < d {
			break
		}

		rem := a[i]% 3

		if rem == 0 {
			remZ  = true
		} else if rem == 1 {
			remO = true
		} else {
			remT = true
		}
	}

	o := false
	t := false
	onePres := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			onePres = true
		}

		if a[i] % 3 == 1 {
			o = true
		}
		if a[i] % 3 == 2 {
			t = true
		}
	}
	if !o && !t {
		return d
	}

	if (o && !t) || (!o && t) {
		return d + 1
	}

	//1 1
	//2 2
	//1 2

	if !onePres {
		if remO && !remZ && !remT {
			return d + 1
		}

		return d + 2

	}

	ans := d + 2

	if max == 3 {
		ans--
	}

	return ans
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	max := a[len(a) - 1]

	d := max/3

	o := false
	t := false
	onePres := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			onePres = true
		}

		if a[i] % 3 == 1 {
			o = true
		}
		if a[i] % 3 == 2 {
			t = true
		}
	}
	if !o && !t {
		return d
	}

	if (o && !t) || (!o && t) {
		return d + 1
	}

	//1 1
	//2 2
	//1 2

	if !onePres {
		return d + 1
	}

	ans := d + 2

	if max == 3 {
		ans--
	}

	return ans
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	max := a[len(a) - 1]

	d := max/3

	o := false
	t := false
	onePres := false
	threePres := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			onePres = true
		}
		if a[i] == 3 {
			threePres = true
		}

		if a[i] % 3 == 1 {
			o = true
		}
		if a[i] % 3 == 2 {
			t = true
		}
	}
	if !o && !t {
		return d
	}

	if (o && !t) || (!o && t) {
		return d + 1
	}

	if onePres {
		ans := d + 2

		if threePres {
			ans--
		}
		return ans
	}

	return d + 1

	//1 1
	//2 2
	//1 2
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	max := a[len(a) - 1]

	d := max/3

	o := false
	t := false
	onePres := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			onePres = true
		}

		if a[i] % 3 == 1 {
			o = true
		}
		if a[i] % 3 == 2 {
			t = true
		}
	}
	if !o && !t {
		return d
	}

	if (o && !t) || (!o && t) {
		return d + 1
	}

	if onePres {
		if max > 3 {
			return d + 2
		}

		return d + 1

	}
	return d + 1
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() (int) {
	sort.Ints(a)

	max := a[len(a) - 1]

	d := max/3

	o := false
	t := false
	onePres := false

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			onePres = true
		}

		if a[i] % 3 == 1 {
			o = true
		}
		if a[i] % 3 == 2 {
			t = true
		}
	}
	if !o && !t {
		return d
	}

	if (o && !t) || (!o && t) {
		return d + 1
	}

	if onePres {
		return d + 2

	}
	return d + 1
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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


package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,t,c int
    var a,cnt [200005]int
    fmt.Scan(&n,&t,&c)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if a[i] > t { cnt[i]++ }
        if i != 0 { cnt[i] += cnt[i-1] }
    }
    ans := 0
    for i := 0; i <= (n-c); i++ {
        if i == 0 {
            if cnt[i+c-1] == 0 { ans++ }
        } else {
            if (cnt[i+c-1]-cnt[i-1]) == 0 { ans++ }
        }
    }
    fmt.Println(ans)
}

package main

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

func main()  {
	var n,t,c int
	fmt.Scan(&n,&t,&c)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	s := make([]int,n)
	for i:=0; i<n; i++{
		scanner.Scan()
		s[i],_ = strconv.Atoi(scanner.Text())
	}
	var res int
	var cnt int //number of violation in the current interval
	for i:=0;i<c;i++{
		if s[i] > t {cnt++}
	}
	if cnt == 0 {res++}
	for i:=c;i<n;i++{
		if s[i-c] > t {cnt--}
		if s[i] > t {cnt++}
		if cnt == 0 {res++}
	}
	fmt.Println(res)

}

package main

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

func main() {
	var n, t, c, tmp int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &t)
	fmt.Fscan(reader, &c)
	list := make([]int, 0)
	for i := 0; i < n; i += 1 {
		fmt.Fscan(reader, &tmp)
		list = append(list, tmp)
	}
	way := 0
	count := 0
	for i := 0; i < c; i += 1 {
		if list[i] > t {
			count += 1
		}
	}
	if count == 0 {
		way += 1
	}
	for i := c; i < n; i += 1 {
		if list[i-c] > t {
			count -= 1
		}
		if list[i] > t {
			count += 1
		}
		if count == 0 {
			way += 1
		}
	}
	fmt.Println(way)
}

package main

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

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

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

	n, t, c := nextInt(), nextInt(), nextInt()
	countC := 0
	crimeLevel := 0
	count := 0

	for i:=0; i<n; i++ {
		crimeLevel = nextInt()
		if crimeLevel > t {
			countC = 0
		} else {
			if countC+1 == c {
				count++
			} else {
				countC++
			}
		}
	}

	println(count)
}

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 nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	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 (
	"fmt"
	//"sort"
	"bufio"
	"os"
	"strconv"
)

func main() {
	var n,t,c int
	input := bufio.NewScanner(os.Stdin)
    	input.Split(bufio.ScanWords)
    	k,s:=0,0
    	fmt.Scan(&n,&t,&c)

	for i:=1;i<=n;i++ {
		input.Scan()
       		aa, _ := strconv.Atoi(input.Text())
		if aa>t {
			if i-k>=c {
				s+=i-k-c
			}
			k=i
		}
		if i==n && aa<=t && i-k+1>=c {
			s+=i-k-c+1
		}
	}
	fmt.Println(s)
}

package main

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

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

func main() {
    var (
        n, t, c int
        p       [200010]int
    )
    fmt.Fscan(reader, &n, &t, &c)
    for i := 0; i < n; i++ {
        fmt.Fscan(reader, &p[i])
    }
    p[n] = 1e9 + 1
    var tmp, cnt int
    for i := 0; i <= n; i++ {
        if p[i] <= t {
            tmp++
        } else {
            if tmp-c >= 0 {
                cnt = cnt + tmp - c + 1
            }
            tmp = 0
        }
    }
    fmt.Println(cnt)
}

package main

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

func main() {
	var n, t, c int
	if _, err := fmt.Scanf("%d %d %d\n", &n, &t, &c); err != nil {
		return
	}

	plan := 0
	last_ok := -1

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		if a > t {
			if last_ok >= 0 && i-last_ok >= c {
				plan += i - last_ok - c + 1
			}
			last_ok = -1
		} else {
			if last_ok < 0 {
				last_ok = i
			}
		}
	}
	if last_ok >= 0 && n-last_ok >= c {
		plan += n - last_ok - c + 1
	}

	fmt.Println(plan)
}

package main

import (
	"bufio"
	"errors"
	"flag"
	"os"
	"strconv"
	"time"
)

// ******************************** CODE STARTS ********************************

var ()

func solve() {
	n := readInt()
	limit := readInt()
	num := readInt()

	ans := 0
	prev := -1
	for i := 0; i < n; i++ {
		value := readInt()
		if value == -1 || value > limit {
			if prev >= num {
				ans += prev - num + 1
			}
			prev = -1
		} else {
			if prev == -1 {
				prev = 1
			} else {
				prev++
			}
		}
	}
	if prev >= num {
		ans += prev - num + 1
	}
	printInt(ans)
	printLine()
}

// ********************************* CODE ENDS *********************************

// IO.

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
)

func main() {
	local := flag.Bool("local", false, "Defines whether run is local or remote.")
	flag.Parse()

	var (
		input  *os.File
		output *os.File
	)

	if *local {
		input, _ = os.Open("/home/outside/coding/workspace/go/io/input.txt")
		output, _ = os.Create("/home/outside/coding/workspace/go/io/output.txt")
		startTime := time.Now()
		defer func() {
			print("Time: ")
			print(strconv.FormatFloat(time.Since(startTime).Seconds(), 'f', 5, 64))
			println("s")
		}()
	} else {
		input = os.Stdin
		output = os.Stdout
		// input, _ = os.Open("")
		// output, _ = os.Create("")
	}
	defer input.Close()
	defer output.Close()

	scanner = bufio.NewScanner(input)
	writer = bufio.NewWriter(output)
	defer writer.Flush()

	scanner.Split(bufio.ScanWords)

	solve()
}

// Read.

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

func readLine() string {
	scanner.Split(bufio.ScanLines)
	defer scanner.Split(bufio.ScanWords)
	return readString()
}

func readInt() int {
	ans, _ := strconv.ParseInt(readString(), 10, 0)
	return int(ans)
}

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

func readFloat64() float64 {
	ans, _ := strconv.ParseFloat(readString(), 64)
	return ans
}

// Write.

func printString(value string) {
	writer.WriteString(value)
}

func printLine() {
	printString("\n")
}

func printInt(value int) {
	printString(strconv.FormatInt(int64(value), 10))
}

func printInt64(value int64) {
	printString(strconv.FormatInt(value, 10))
}

func printFLoat64(value float64) {
	printString(strconv.FormatFloat(value, 'f', 20, 64))
}

// Min, max, abs.

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

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

// Set Key interface implementations.

type Int int

func (p Int) Equals(key Key) bool {
	return int(p) == int(key.(Int))
}

func (p Int) Less(key Key) bool {
	return int(p) < int(key.(Int))
}

// Set.

type Key interface {
	Equals(key Key) bool
	Less(key Key) bool
}

type node struct {
	key   Key
	left  *node
	right *node
}

func newNode(key Key) *node {
	return &node{key, nil, nil}
}

type SplayTree struct {
	root *node
	tmp  *node
	len  int
}

func NewSplayTree() *SplayTree {
	return &SplayTree{nil, newNode(nil), 0}
}

func rotateLeft(x, p *node) {
	p.right = x.left
	x.left = p
}

func rotateRight(x, p *node) {
	p.left = x.right
	x.right = p
}

func (p *SplayTree) splay(x *node, key Key) *node {
	if x == nil {
		return nil
	}

	left := p.tmp
	right := p.tmp

	for {
		if key.Less(x.key) {
			y := x.left
			if y == nil {
				break
			}
			if key.Less(y.key) { // zig-zig
				rotateRight(y, x)
				x = y
				if x.left == nil {
					break
				}
			}
			// link right
			right.left = x
			right = x
			// move left
			x = x.left
		} else if x.key.Less(key) {
			y := x.right
			if y == nil {
				break
			}
			if y.key.Less(key) { // zig-zig
				rotateLeft(y, x)
				x = y
				if x.right == nil {
					break
				}
			}
			// link left
			left.right = x
			left = x
			// move right
			x = x.right
		} else {
			break
		}
	}

	left.right = x.left
	right.left = x.right
	x.left = p.tmp.right
	x.right = p.tmp.left

	return x
}

// left <= key < right
func (p *SplayTree) split(key Key) (left, right *node) {
	p.root = p.splay(p.root, key)
	if p.root.key.Equals(key) || p.root.key.Less(key) {
		right := p.root.right
		p.root.right = nil
		return p.root, right
	} else {
		left := p.root.left
		p.root.left = nil
		return left, p.root
	}
}

// keys from left tree must be less then keys from right tree
func (p *SplayTree) join(left, right *node) *node {
	if left == nil {
		return right
	} else if right == nil {
		return left
	}
	left = p.splay(left, right.key)
	left.right = right
	return left
}

type Set interface {
	Len() int
	Insert(key Key) error
	Find(key Key) bool
	Remove(key Key) error
}

func NewSet() Set {
	return Set(NewSplayTree())
}

func (p *SplayTree) Len() int {
	return p.len
}

func (p *SplayTree) Insert(key Key) error {
	if p.root == nil {
		p.root = newNode(key)
		p.len++
	} else {
		p.root = p.splay(p.root, key)
		if p.root.key.Equals(key) {
			return errors.New("Such key already exists")
		} else {
			left, right := p.split(key)
			p.root = newNode(key)
			p.root.left = left
			p.root.right = right
			p.len++
		}
	}
	return nil
}

func (p *SplayTree) Find(key Key) bool {
	if p.root == nil {
		return false
	}
	p.root = p.splay(p.root, key)
	return p.root.key.Equals(key)
}

func (p *SplayTree) Remove(key Key) error {
	p.root = p.splay(p.root, key)
	if p.root == nil || !p.root.key.Equals(key) {
		return errors.New("Such key doesn't exist")
	}
	p.root = p.join(p.split(key))
	return nil
}

// 427B-mic
package main

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

func main() {
    w := bufio.NewScanner(os.Stdin)
    w.Split(bufio.ScanWords)
    var n, t, c int
    fmt.Scan(&n, &t, &c)
    a := make([]int, n+2)
    for i := 1; i <= n; i++ {
        w.Scan()
        a[i], _ = strconv.Atoi(w.Text())
    }
    a[n+1] = t + 1
    dem := 0
    //max := 0
    kq := 0
    for i := 1; i <= n+1; i++ {
        if a[i] <= t {
            dem++
        } else {
            if dem >= c {
                kq += dem - c + 1
            }
            dem = 0
        }
    }
    fmt.Println(kq)
}

package main

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

func main() {
	var n, t, c int
	if _, err := fmt.Scanf("%d %d %d\n", &n, &t, &c); err != nil {
		return
	}

	plan := 0
	last_ok := -1

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		if a > t {
			if last_ok >= 0 && i-last_ok >= c {
				plan += i - last_ok - c + 1
			}
			last_ok = -1
		} else {
			if last_ok < 0 {
				last_ok = i
			}
		}
	}
	if last_ok >= 0 {
		plan += n - last_ok - c + 1
	}

	fmt.Println(plan)
}

package main

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

func main() {
	var n, t, c int
	if _, err := fmt.Scanf("%d %d %d\n", &n, &t, &c); err != nil {
		return
	}

	plan := 0
	last_ok := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		if a > t {
			if i-last_ok >= c {
				plan += i - last_ok - c + 1
			}
			last_ok = -1
		} else {
			if last_ok < 0 {
				last_ok = i
			}
		}
	}
	if last_ok >= 0 {
		plan += n - last_ok - c + 1
	}

	fmt.Println(plan)
}


package main

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

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

func make2d[T any](n, m int) [][]T {
	mat := make([][]T, n)
	r := make([]T, n*m)
	for i, startRow := 0, 0; i < n; i, startRow = i+1, startRow+m {
		endRow := startRow + m
		mat[i] = r[startRow:endRow]
	}
	return mat
}

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

type pair struct {
	r int
	c int
}

func main() {
	defer out.Flush()
	x := pair{}

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, m int
		fmt.Fscan(in, &n, &m)
		a := make2d[int](n, m)
		b := int(-2e9)
		for i := range a {
			for j := range a[i] {
				fmt.Fscan(in, &a[i][j])
				if a[i][j] > b {
					b = a[i][j]
					x.r = i + 1
					x.c = j + 1
				}
			}
		}
		fmt.Printf("%d\n", max(x.c, m-x.c+1)*max(x.r, n-x.r+1))
	} //fim do loop de test cases
} // fim main

package main

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

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

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

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, m int
		fmt.Fscan(r, &n, &m)
		var i, j int
		var iIdx, jIdx, val int
		maxVal := math.MinInt32
		for i = 0; i < n; i++ {
			for j = 0; j < m; j++ {
				fmt.Fscan(r, &val)
				if val > maxVal {
					iIdx, jIdx, maxVal = i, j, val
				}
			}
		}

		ans := (iIdx + 1) * (jIdx + 1)
		ans = max(ans, (iIdx+1)*(m-jIdx))
		ans = max(ans, (n-iIdx)*(m-jIdx))
		ans = max(ans, (n-iIdx)*(jIdx+1))
		fmt.Fprintln(w, ans)
	}

}

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

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

package main

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

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

	tc := readInt(in)
	for i := 0; i < tc; i++ {
		arr := readArrInt(in)
		n := arr[0]
		//m := arr[1]
		grid := make([][]int, n)
		for j := 0; j < n; j++ {
			grid[j] = readArrInt(in)
		}

		fmt.Println(solve(grid))
	}
	fmt.Scanln()
}

func solve(grid [][]int) int {
	max := math.MinInt
	maxi := 0
	maxj := 0
	for i := range grid {
		for j := range grid[i] {
			if grid[i][j] > max {
				max = grid[i][j]
				maxi = i
				maxj = j
			}
		}
	}

	sq1 := (maxi + 1) * (maxj + 1)
	sq2 := (maxi + 1) * (len(grid[0]) - maxj)
	sq3 := (len(grid) - maxi) * (maxj + 1)
	sq4 := (len(grid) - maxi) * (len(grid[0]) - maxj)

	res1 := maxint(sq1, sq2)
	res2 := maxint(sq3, sq4)

	return maxint(res1, res2)
}

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

	return b
}

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
}

package main

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

func max(a int64, rest ...int64) int64 {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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, m int
		fmt.Fscan(in, &n, &m)

		g := int64(math.MinInt32)
		x, y := 0, 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var v int64
				fmt.Fscan(in, &v)
				if v > g {
					g = v
					x, y = i, j
				}
			}
		}

		fmt.Fprintln(out, max(int64(x+1), int64(n-x))*max(int64(y+1), int64(m-y)))
	}
}

package main

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

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

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

func solve(n, m int, a [][]int) int {
	var maxx, maxy int
	var mx = -1000000001
	for i, r := range a {
		for j, x := range r {
			if x > mx {
				maxx = i
				maxy = j
				mx = x
			}
		}
	}
	return max(maxx+1, n-maxx) * max(maxy+1, m-maxy)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &m)
		a := make([][]int, n)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
			for j := 0; j < m; j++ {
				fmt.Fscan(reader, &a[i][j])
			}
		}
		fmt.Println(solve(n, m, a))
	}
}

package main

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

/*
1
4 4
2 12 6 10
3 15 16 4
1 13 8 11
14 7 9 5
-----

*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n, m int
	scanf("%d %d\n", &n, &m)

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

	maxR, maxC := 0, 0
	maxVal := minInt

	for r := 0; r < n; r++ {
		a[r] = make([]int, m)

		for c := range a[r] {
			scanf("%d", &a[r][c])

			if a[r][c] > maxVal {
				maxVal = a[r][c]
				maxR, maxC = r, c
			}
		}
		scanf("\n")
	}

	maxR++
	maxC++

	ans := maxR * maxC
	ans = max(ans, (n-maxR+1)*(m-maxC+1))
	ans = max(ans, (n-maxR+1)*(maxC))
	ans = max(ans, (maxR)*(m-maxC+1))

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int64) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

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

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

func (in *CF1695A) 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 *CF1695A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1695A
Date: 9/16/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1695/A
Problem: CF1695A
**/
func (in *CF1695A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, m := in.NextInt(), in.NextInt()
		max := -1000000001
		x, y := -1, -1
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				val := in.NextInt()
				if val > max {
					max = val
					x = i
					y = j
				}
			}
		}

		fmt.Println(maxi(n-x, x+1) * maxi(m-y, y+1))
	}
}

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

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

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

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,M := gi(),gi(); gr := make([][]int,N); for i:=0;i<N;i++ { gr[i] = gis(M); }
		m,mi,mj := -1000000001,-1,-1
		for i:=0;i<N;i++ { for j:=0;j<M;j++ { if gr[i][j] > m { m,mi,mj = gr[i][j],i,j } } }
		mi = max(mi,N-1-mi); mj = max(mj,M-1-mj)
		fmt.Fprintln(wrtr,(mi+1)*(mj+1))
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n, m int
		fmt.Fscan(r, &n, &m)
		a := make([][]int, n)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
			for j := 0; j < m; j++ {
				fmt.Fscan(r, &a[i][j])
			}
		}
		w1 := do(a, n, m)
		fmt.Fprintln(w, w1)
	}
}

func do(a [][]int, n, m int) int {
	b := a[0][0]
	var x, y int
	for i, v := range a {
		for j, w := range v {
			if b < w {
				b = w
				x, y = i, j
			}
		}
	}
	w := max(x+1, n-x)
	h := max(y+1, m-y)
	return h * w
}

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

package main

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

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

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

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, m int
		fmt.Fscan(r, &n, &m)
		var i, j, maxVal int
		var iIdx, jIdx, val int
		for i = 0; i < n; i++ {
			for j = 0; j < m; j++ {
				fmt.Fscan(r, &val)
				if val > maxVal {
					iIdx, jIdx, maxVal = i, j, val
				}
			}
		}

		ans := (iIdx + 1) * (jIdx + 1)
		ans = max(ans, (iIdx+1)*(m-jIdx))
		ans = max(ans, (n-iIdx)*(m-jIdx))
		ans = max(ans, (n-iIdx)*(jIdx+1))
		fmt.Fprintln(w, ans)
	}

}

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

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

package main

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

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

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

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, m int
		fmt.Fscan(r, &n, &m)
		var i, j, maxVal int
		var iIdx, jIdx, val int
		for i = 0; i < n; i++ {
			for j = 0; j < m; j++ {
				fmt.Fscan(r, &val)
				if val > maxVal {
					iIdx, jIdx, maxVal = i, j, val
				}
			}
		}

		ans := (iIdx + 1) * (jIdx + 1)
		ans = max(ans, (iIdx+1)*(m-jIdx))
		ans = max(ans, (n-iIdx)*(m-jIdx))
		ans = max(ans, (n-iIdx)*(jIdx+1))
		fmt.Println(w, ans)
	}

}

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

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

package main

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

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

	tc := readInt(in)
	for i := 0; i < tc; i++ {
		arr := readArrInt(in)
		n := arr[0]
		//m := arr[1]
		grid := make([][]int, n)
		for j := 0; j < n; j++ {
			grid[j] = readArrInt(in)
		}

		if tc == 20 && arr[0] == arr[1] && arr[0] == 10 {
			for _, r := range grid {
				for _, s := range r {
					fmt.Println(s)
				}
			}
		}
		fmt.Println(solve(grid))
	}
}

func solve(grid [][]int) int {
	max := 0
	maxi := 0
	maxj := 0
	for i := range grid {
		for j := range grid[i] {
			if grid[i][j] > max {
				max = grid[i][j]
				maxi = i
				maxj = j
			}
		}
	}

	sq1 := (maxi + 1) * (maxj + 1)
	sq2 := (maxi + 1) * (len(grid[0]) - maxj)
	sq3 := (len(grid) - maxi) * (maxj + 1)
	sq4 := (len(grid) - maxi) * (len(grid[0]) - maxj)

	res1 := maxint(sq1, sq2)
	res2 := maxint(sq3, sq4)

	return maxint(res1, res2)
}

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

	return b
}

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
}

package main

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

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

	tc := readInt(in)
	for i := 0; i < tc; i++ {
		arr := readArrInt(in)
		n := arr[0]
		//m := arr[1]
		grid := make([][]int, n)
		for j := 0; j < n; j++ {
			grid[j] = readArrInt(in)
		}

		fmt.Println(solve(grid))
	}
}

func solve(grid [][]int) int {
	max := 0
	maxi := 0
	maxj := 0
	for i := range grid {
		for j := range grid[i] {
			if grid[i][j] > max {
				max = grid[i][j]
				maxi = i
				maxj = j
			}
		}
	}

	sq1 := (maxi + 1) * (maxj + 1)
	sq2 := (maxi + 1) * (len(grid[0]) - maxj)
	sq3 := (len(grid) - maxi) * (maxj + 1)
	sq4 := (len(grid) - maxi) * (len(grid[0]) - maxj)

	res1 := maxint(sq1, sq2)
	res2 := maxint(sq3, sq4)

	return maxint(res1, res2)
}

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

	return b
}

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
}

package main

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

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

	tc := readInt(in)
	for i := 0; i < tc; i++ {
		arr := readArrInt(in)
		n := arr[0]
		//m := arr[1]
		grid := make([][]int, n)
		for j := 0; j < n; j++ {
			grid[j] = readArrInt(in)
		}

		fmt.Println(solve(grid))
	}
}

func solve(grid [][]int) int {
	max := 0
	maxi := 0
	maxj := 0
	for i := range grid {
		for j := range grid[i] {
			if grid[i][j] > max {
				max = grid[i][j]
				maxi = i
				maxj = j
			}
		}
	}

	resi, resj := 0, 0

	resi = maxint(maxi+1, len(grid)-maxi)
	resj = maxint(maxj+1, len(grid[0])-maxj)

	return resi * resj
}

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

	return b
}

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
}

package main

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

func max(a int64, rest ...int64) int64 {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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, m int
		fmt.Fscan(in, &n, &m)

		g := int64(0)
		x, y := 0, 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var v int64
				fmt.Fscan(in, &v)
				if v > g {
					g = v
					x, y = i, j
				}
			}
		}

		fmt.Fprintln(out, max(int64(x+1), int64(n-x))*max(int64(y+1), int64(m-y)))
	}
}

package main

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

func max(a int, rest ...int) int {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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, m int
		fmt.Fscan(in, &n, &m)

		g := 0
		x, y := 0, 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var v int
				fmt.Fscan(in, &v)
				if v > g {
					g = v
					x, y = i, j
				}
			}
		}

		fmt.Fprintln(out, max(x+1, n-x)*max(y+1, m-y))
	}
}

package main

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

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

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

func solve(n, m int, a [][]int) int {
	var mx, maxx, maxy int
	for i, r := range a {
		for j, x := range r {
			if x > mx {
				maxx = i
				maxy = j
				mx = x
			}
		}
	}
	return max(maxx+1, n-maxx) * max(maxy+1, m-maxy)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &m)
		a := make([][]int, n)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
			for j := 0; j < m; j++ {
				fmt.Fscan(reader, &a[i][j])
			}
		}
		fmt.Println(solve(n, m, a))
	}
}

package main

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

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

func make2d[T any](n, m int) [][]T {
	mat := make([][]T, n)
	r := make([]T, n*m)
	for i, startRow := 0, 0; i < n; i, startRow = i+1, startRow+m {
		endRow := startRow + m
		mat[i] = r[startRow:endRow]
	}
	return mat
}

type pair struct {
	r int
	c int
}

func main() {
	defer out.Flush()
	x := pair{}

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, m int
		fmt.Fscan(in, &n, &m)
		a := make2d[int](n, m)
		b := int(-2e9)
		for i := range a {
			for j := range a[i] {
				fmt.Fscan(in, &a[i][j])
				if a[i][j] > b {
					b = a[i][j]
					x.r = i
					x.c = j
				}
			}
		}
		fmt.Printf("%d\n", (m/2+1)*(n/2+1))
	} //fim do loop de test cases
} // fim main

package main

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

/*
1
4 4
2 12 6 10
3 15 16 4
1 13 8 11
14 7 9 5
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n, m int
	scanf("%d %d\n", &n, &m)

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

	maxR, maxC := 0, 0
	maxVal := minInt

	for r := 0; r < n; r++ {
		a[r] = make([]int, m)

		for c := range a[r] {
			scanf("%d", &a[r][c])

			if a[r][c] > maxVal {
				maxVal = a[r][c]
				maxR, maxC = r, c
			}
		}
		scanf("\n")
	}

	maxR++
	maxC++

	ans := maxR * maxC
	ans = max(ans, (n-maxR+1)*(m-maxC+1))
	ans = max(ans, (n-maxR+1)*(maxC))
	ans = max(ans, (maxR)*(m-maxC))

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int64) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}


package main

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

const debug = false

var in = bufio.NewReader(os.Stdin)

func init() {
	if debug {
		log.SetFlags(log.LstdFlags | log.Lshortfile)
	}
}

const N = 1e5

var adj [N + 1][]int32
var v [N + 1]bool

func dfs(i, p int32) bool {
	if v[i] {
		return true
	}
	v[i] = true
	var cycle bool
	for _, j := range adj[i] {
		if j != p && dfs(j, i) {
			cycle = true
		}
	}
	if debug {
		log.Println(i, p, cycle)
	}
	return cycle
}

func main() {
	var n, m int32
	fmt.Fscan(in, &n, &m)
	for ; m > 0; m-- {
		var x, y int32
		fmt.Fscan(in, &x, &y)
		adj[x] = append(adj[x], y)
		adj[y] = append(adj[y], x)
	}
	ans := 0
	for i := int32(1); i <= n; i++ {
		if !v[i] && !dfs(i, 0) {
			ans++
		}
	}
	fmt.Println(ans)
}

// Codeforces 659 E graphs
package main

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

var n,m int
// Vert vertice of graph.
type Vert struct {
    group int
    adj []int
}
var va []Vert

func addEdge(a,b int) {
    va[a].adj = append(va[a].adj, b)
    va[b].adj = append(va[b].adj, a)
}

// find group elements using dfs
func fillGroup(gr int, i int) {
    va[i].group = gr
    for ij:=0; ij<len(va[i].adj); ij++ {
        j := va[i].adj[ij]
        if va[j].group==0 {
            fillGroup(gr,j)
        }
    }
}

func main() {
	// reading n,m
 	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		return
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	n, err = strconv.Atoi(ss[0])
	if err != nil {
		fmt.Println("n atoi failure", err)
		return
	}
	m, err = strconv.Atoi(ss[1])
	if err != nil {
		fmt.Println("m atoi failure", err)
		return
	}
    // reading adj
    va = make([]Vert, n)
    for i:=0; i<m; i++ {
        s, err = in.ReadString('\n')
        if err != nil {
            fmt.Println("read failure", err)
            return
        }
	    ss = strings.Split(strings.Trim(s, " \n\r"), " ")
        var a,b int
        a, err = strconv.Atoi(ss[0])
        if err != nil {
            fmt.Println("n atoi failure", err)
            return
        }
        b, err = strconv.Atoi(ss[1])
        if err != nil {
            fmt.Println("m atoi failure", err)
            return
        }
        addEdge(a-1, b-1)
    }

    // looking for connected groups
    ngroup := 0
    for i:=0; i<len(va); i++ {
        if va[i].group==0 {
            ngroup++
            fillGroup(ngroup,i)
        }
    }
    ngroup++
    // counting vert nad edg in groups
    nvert := make([]int, ngroup)
    nedge := make([]int, ngroup)
    for i:=0; i<n; i++ {
        gr := va[i].group
        nvert[gr]++
        nedge[gr] += len(va[i].adj)
    }
    // if ne = ng-1, sep++, otherwise sep same
    nsep := 0
    for i:=1; i<ngroup; i++ {
        // fmt.Printf("nv,ne = %d %d\n", nvert[i],nedge[i])
        if 2*(nvert[i]-1) == nedge[i] {
            nsep++
        } else if 2*(nvert[i]-1) < nedge[i] {
            // has cycle
        } else {
            panic("wrong cyles number")
        }
    }

    // print result
    fmt.Println(nsep)
}


package main

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

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

	var T, n int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		b := make([]int64, n)
		s := int64(0)
		for i := range b {
			Fscan(in, &b[i])
			s += b[i]
		}
		d := int64(n) * int64(n+1) / 2
		if s%d > 0 {
			Fprintln(out, "NO")
			continue
		}
		s /= d
		a := make([]interface{}, n)
		for i, v := range b {
			s := s + b[(i+n-1)%n] - v
			if s <= 0 || s%int64(n) > 0 {
				Fprintln(out, "NO")
				continue o
			}
			a[i] = s / int64(n)
		}
		Fprintln(out, "YES")
		Fprintln(out, a...)
	}
}

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

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var tmp int64
		if sum_b%sum_gao != 0 {
			Fprintln(out, "NO")
			continue
		}
		var sum_a int64 = sum_b / sum_gao
		//差分求解
		for i := n; i > 1; i-- {
			if k := (sum_a - b[i] + b[i-1]) / n; (sum_a-b[i]+b[i-1])%n != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintln(out, "NO")
			continue
		}
		Fprintln(out, "YES")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
			if i == int(n) {
				Fprintf(out, "\n")
			}
		}
	h1:
	}
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, p := 0, 0, int64(0)
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, sum := []int64{}, int64(0)
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o = append(o, p)
			sum += p
		}
		tot, ans := (n*(n+1))/2, make([]int64, n)
		asum, check, not_ok := sum/int64(tot), int64(0), false
		if sum%int64(tot) != 0 {
			not_ok = true
		}
		for j := 0; j < n; j++ {
			ans[(j+1)%n] = (asum + o[j] - o[(j+1)%n]) / int64(n)
			check += ans[(j+1)%n]
			if ans[(j+1)%n] <= 0 {
				not_ok = true
			}
		}
		if not_ok || check != asum {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
			for _, v := range ans {
				fmt.Fprint(w, v, " ")
			}
			fmt.Fprintln(w, "")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

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

	var c int
	var n int
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int, n+1)
		b := make([]int, n+1)
		var sum_b int
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int = (1 + n) * n / 2
		var tmp int
		if sum_b % sum_gao != 0 {
			Fprintln(out, "NO")
			continue
		}
		var sum_a int = sum_b / sum_gao
		//差分求解
		for i := n; i > 1; i-- {
			if k := (sum_a - b[i] + b[i-1]) / n; (sum_a-b[i]+b[i-1])%n != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintln(out, "NO")
			continue
		}
		Fprintln(out, "YES")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
			if i == n {
				Fprintf(out, "\n")
			}
		}
	h1:
	}
}

package main

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

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

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

	var c int
	var n int
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int, n+1)
		b := make([]int, n+1)
		var sum_b int
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int = (1 + n) * n / 2
		var sum_a int = sum_b / sum_gao
		var tmp int
		//差分求解
		for i := n; i > 1; i-- {
			if k := (sum_a - b[i] + b[i-1]) / n; (sum_a-b[i]+b[i-1])%n != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintln(out, "NO")
			goto h1
		}
		Fprintln(out, "YES")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
			if i == n {
				Fprintf(out, "\n")
			}
		}
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		if i == 12 || i == 13 || i== 14{
			Println(b)
		}
		//差分求解
		for i := n; i > 1; i-- {
			if k := (sum_a - b[i] + b[i-1]) / n; (sum_a-b[i]+b[i-1])%n != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintln(out, "NO")
			goto h1
		}
		Fprintln(out, "YES")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
			if i == int(n) {
				Fprintf(out, "\n")
			}
		}
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (sum_a - b[i] + b[i-1]) / n; (sum_a - b[i] + b[i-1]) % n != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
			if i == int(n) {
				Fprintf(out, "\n")
			}
		}
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
			if i == int(n) {
				Fprintf(out, "\n")
			}
		}
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		if i == 14 {
			Println(b)
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 1; i <= c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		if i == 13 {
			Println(b)
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 0; i < c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

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

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

	var c int
	var n int64
	Fscan(in, &c)
	for i := 0; i < c; i++ {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		if i == 12 {Println(b)}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

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

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

	var c int64
	var n int64
	Fscan(in, &c)
	for ; c > 0; c-- {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k <= 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		if a[1] <= 0 {
			Fprintf(out, "NO\n")
			continue
		}
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

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

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

	var c int64
	var n int64
	Fscan(in, &c)
	for ; c > 0; c-- {
		Fscan(in, &n)
		a := make([]int64, n+1)
		b := make([]int64, n+1)
		var sum_b int64
		for i := range b {
			if i > 0 {
				Fscan(in, &b[i])
				sum_b += b[i]
			}
		}
		var sum_gao int64 = (1 + n) * n / 2
		var sum_a int64 = sum_b / sum_gao
		var tmp int64
		//差分求解
		for i := n; i > 1; i-- {
			if k := (b[i] - b[i-1] - sum_a) / (-n); (b[i]-b[i-1]-sum_a)%(-n) != 0 || k == 0 {
				Fprintf(out, "NO\n")
				goto h1
			} else {
				a[i] = k
				tmp += k
			}
		}
		a[1] = sum_a - tmp
		Fprintf(out, "YES\n")
		for i, v := range a {
			if i > 0 {
				Fprintf(out, "%d%s", v, " ")
			}
		}
		Fprintf(out, "\n")
	h1:
	}
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, p := 0, 0, int64(0)
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, sum := []int64{}, int64(0)
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o = append(o, p)
			sum += p
		}
		tot, ans := (n*(n+1))/2, make([]int64, n)
		asum, check, not_ok := sum/int64(tot), int64(0), false
		for j := 0; j < n; j++ {
			ans[(j+1)%n] = (asum + o[j] - o[(j+1)%n]) / int64(n)
			check += ans[(j+1)%n]
			if ans[(j+1)%n] <= 0 {
				not_ok = true
			}
		}
		if not_ok || check != asum {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
			for _, v := range ans {
				fmt.Fprint(w, v, " ")
			}
			fmt.Fprintln(w, "")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, p := 0, 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, sum := []int{}, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o = append(o, p)
			sum += p
		}
		tot, ans := (n*(n+1))/2, make([]int, n)
		asum, not_ok := sum/tot, false
		for j := 0; j < n; j++ {
			ans[(j+1)%n] = (asum + o[j] - o[(j+1)%n]) / n
			if ans[(j+1)%n] <= 0 {
				not_ok = true
			}
		}
		if not_ok {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
			for _, v := range ans {
				fmt.Fprint(w, v, " ")
			}
			fmt.Fprintln(w, "")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, p := 0, 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, sum := []int{}, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o = append(o, p)
			sum += p
		}
		tot, ans := (n*(n+1))/2, make([]int, n)
		asum, not_ok := sum/tot, false
		for j := 0; j < n; j++ {
			ans[(j+1)%n] = (asum + o[j] - o[(j+1)%n]) / n
			if ans[(j+1)%n] == 0 {
				not_ok = true
			}
		}
		if not_ok {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
			for _, v := range ans {
				fmt.Fprint(w, v, " ")
			}
			fmt.Fprintln(w, "")
		}
	}
	w.Flush()
}

func main() {
	solve()
}


package main

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

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

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

	s := ""
	fmt.Scan(&s)
	n := new(big.Int)
	n.SetString(s, 10)
	mod := big.NewInt(4)
	// println(s, n, mod)
	n.Mod(n, mod)

	if n.Int64() == 0 {
		println(4)
	} else {
		println(0)
	}
}

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 nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	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"
	"math/big"
)

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

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

	s := ""
	fmt.Scanf("%s", &s)
	// fmt.Scan(&s)
	n := new(big.Int)
	n.SetString(s, 10)
	mod := big.NewInt(4)
	n.Mod(n, mod)

	if n.Int64() == 0 {
		println(4)
	} else {
		println(0)
	}
}

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 nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	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"
	"io"
	"os"
	"regexp"
)

func main() {
	divisor := 4
	re := regexp.MustCompile(`\r?\n`)

	reader := bufio.NewReader(os.Stdin)
	if _s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s := re.ReplaceAllString(_s, "")
		remain := 0
		for i := 0; i < len(s); i++ {
			digit := int(s[i] - '0')
			dividend := digit + remain*10
			remain = dividend % divisor
		}

		if remain == 0 {
			fmt.Println(4)
		} else {
			fmt.Println(0)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"math/big"
	"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 scan(a ...interface{})                           { fmt.Fscanln(reader, a...) }

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

func main() {
	defer writer.Flush()

	var s string
	scanf("%s\n", &s)

	x := big.NewInt(0)
	x.SetString(s, 10)
	x.Mod(x, big.NewInt(4))

	n := int(x.Int64())

	var (
		a = int(math.Pow(1, float64(n)))
		b = int(math.Pow(2, float64(n)))
		c = int(math.Pow(3, float64(n)))
		d = int(math.Pow(4, float64(n)))
	)

	ans := (a + b + c + d) % 5

	printf("%d\n", ans)
}

package main

import (
	"fmt"
	"strconv"
)

func pow(a, p int) int {
	ans := 1
	for i := 0; i < p; i++ {
		ans *= a
	}
	return ans
}

func main() {
	var line string
	fmt.Scan(&line)

	length := len(line)
	num := 0
	if length >= 2 {
		num, _ = strconv.Atoi(line[length-2 : length])
	} else {
		num, _ = strconv.Atoi(string(line[length-1]))
	}

	num = (num-1)%4 + 1
	ans := (pow(1, num) + pow(2, num) + pow(3, num) + pow(4, num)) % 5
	fmt.Println(ans)
}