package main
import("bufio";."fmt";."math/big";."os";"sort")

// github.com/EndlessCheng/codeforces-go
func main(){
	in:=bufio.NewReader(Stdin)
	const M=998244353
	var n,m,f int64
	Fscan(in,&n,&m)
	a:=make([][]int,m)
	for i:=range a{a[i]=make([]int,n)}
	f=1
	for i:=int64(0);i<n;i++{
		for _,r:=range a{Fscan(in,&r[i])}
		f=f*(i+1)%M
	}
	ans:=f*m
	for _,r:=range a{
		sort.Ints(r)
		x:=int64(1)
		for j,v:=range r{
			v-=j+1
			if v<0{v=0}
			x=x*int64(v)%M
		}
		ans-=x
	}
	Print((ans%M+M)%M*new(Int).ModInverse(NewInt(f),NewInt(M)).Int64()%M)
}

package main
import (
	."fmt"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	ri := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	const mod = 998244353
	pow := func(x, n int64) int64 {
		x %= mod
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	inv := func(a int64) int64 { return pow(a, mod-2) }
	div := func(a, b int64) int64 { return a % mod * inv(b) % mod }

	n, m := ri(), ri()
	a := make([][]int8, m)
	for i := range a {
		a[i] = make([]int8, n)
	}
	f := int64(1)
	for i := range a[0] {
		for _, r := range a {
			r[i] = int8(ri())
		}
		f = f * int64(i+1) % mod
	}
	ans := f * int64(m)
o:
	for _, r := range a {
		sort.Slice(r, func(i, j int) bool { return r[i] < r[j] })
		x := int64(1)
		for j, v := range r {
			v -= int8(j + 1)
			if v < 0 {
				continue o
			}
			x = x * int64(v) % mod
		}
		ans -= x
	}
	Print(div(ans%mod+mod, f))
}

package main

import (
	. "fmt"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	ri := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	const mod = 998244353
	pow := func(x, n int64) int64 {
		x %= mod
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	inv := func(a int64) int64 { return pow(a, mod-2) }
	div := func(a, b int64) int64 { return a % mod * inv(b) % mod }

	n, m := ri(), ri()
	a := make([][]int8, m)
	for i := range a {
		a[i] = make([]int8, n)
	}
	f := int64(1)
	for i := range a[0] {
		for _, r := range a {
			r[i] = int8(ri())
		}
		f = f * int64(i+1) % mod
	}
	ans := f * int64(m)
o:
	for _, r := range a {
		sort.Slice(r, func(i, j int) bool { return r[i] < r[j] })
		x := int64(1)
		for j, v := range r {
			v -= int8(j + 1)
			if v < 0 {
				continue o
			}
			x = x * int64(v) % mod
		}
		ans -= x
	}
	Print(div(ans%mod+mod, f))
}

package main

import (
	. "fmt"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	ri := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	const mod = 998244353
	pow := func(x, n int64) int64 {
		x %= mod
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	inv := func(a int64) int64 { return pow(a, mod-2) }
	div := func(a, b int64) int64 { return a % mod * inv(b) % mod }

	n, m := int64(ri()), int64(ri())
	a := make([][]int8, m)
	for i := range a {
		a[i] = make([]int8, n)
	}
	f := int64(1)
	for i := int64(0); i < n; i++ {
		for _, r := range a {
			r[i] = int8(ri())
		}
		f = f * (i + 1) % mod
	}
	ans := f * m
o:
	for _, r := range a {
		sort.Slice(r, func(i, j int) bool { return r[i] < r[j] })
		x := int64(1)
		for j, v := range r {
			v -= int8(j + 1)
			if v < 0 {
				continue o
			}
			x = x * int64(v) % mod
		}
		ans -= x
	}
	Print(div(ans%mod+mod, f))
}

package main
import("bufio";."fmt";."math/big";."os";"sort")

// github.com/EndlessCheng/codeforces-go
func main(){
	in:=bufio.NewReader(Stdin)
	const M=998244353
	var n,m int64
	Fscan(in,&n,&m)
	a:=make([][]int,m)
	for i:=range a{a[i]=make([]int,n)}
	f:=make([]int64,n+1)
	f[0]=1
	for i:=int64(0);i<n;i++{
		for _,r:=range a{Fscan(in,&r[i])}
		f[i+1]=f[i]*(i+1)%M
	}
	ans:=f[n]*m
	for _,r:=range a{
		sort.Ints(r)
		x:=int64(1)
		for j,v:=range r{
			v-=j+1
			if v<0{v=0}
			x=x*int64(v)%M
		}
		ans-=x
	}
	Print((ans%M+M)%M*new(Int).ModInverse(NewInt(f[n]),NewInt(M)).Int64()%M)
}

package main

import (

	"fmt"

	"math/rand"
	"time"

	"sort"

	"math/big"
	"bufio"
	"os"
)

func main() {

	r := bufio.NewReader(os.Stdin)
	rand.Seed(time.Now().UnixNano())

	var n, m int
	fmt.Fscan(r, &n, &m)
	//n = 5
	//m = 50000

	//for k := 0; k < 100; k++ {

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

			for k := 0; k < m; k++ {
				fmt.Fscan(r, &dist[j][k])
				//dist[j][k] = 1 + rand.Intn(n + 1)
			}
		}

		ans1 := solve(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)

		/*if ans1 != ans2 {
			fmt.Println(ans1)
			fmt.Println(ans2)
			fmt.Println(dist)

			fmt.Println("ERROR")
			break
		}*/
	//}

	fmt.Println(ans1)
	//fmt.Println(ans2)

}

func solve(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	cnt := big.NewInt(0)

	for i := 0; i < m; i ++ {

		l := make([]int, n)

		for j := 0; j < n; j++ {
			//1 1 2 1 3 4 1 5 2 3 4 6 8 1 2 8 3 5 3
			d := dist[j][i]
			l[j] = d
		}

		offset := 1
		var cntPerPoint int64

		sort.Ints(l)

		for j := 0; j < n; j++ {
			d := l[j]
			if d > n {
				break
			}
			if d == 1 {
				cntPerPoint = fact[n]
				break
			}

			lat := n - d + 1

			f := int64(lat) * fact[n - offset]
			offset++

			delta := 0
			for k := 0; k < j; k++ {
				v := l[k] - 1 - delta
				delta++

				f *= int64(v)
			}

			cntPerPoint += f
		}

		cnt = cnt.Add(cnt, big.NewInt(cntPerPoint))
	}

	//fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	z := cnt.Mul(cnt, big.NewInt(modInv))
	z = z.Mod(z, big.NewInt(998244353))

	return z.Int64()
}

func solve_stupid(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	scores := make([][][]int, n)
	for j := 0; j < n; j++ {
		scores[j] = make([][]int, n + 1)
	}

	orig := make([]int, n)
	for j := 0; j < n; j++ {
		orig[j] = j
	}

	var cnt int64

	for p := make([]int, len(orig)); p[0] < len(p); nextPerm(p) {
		perm := getPerm(orig, p)

		points := make([]bool, m)

		for i := 0; i < len(perm); i ++ {
			c := perm[i]
			maxDist := n - i

			for k := 0; k < len(dist[c]); k++ {
				if dist[c][k] <= maxDist {
					points[k] = true
				}
			}
		}

		for j := 0; j < len(points); j++ {
			if points[j] {
				cnt++
			}
		}
	}

	//fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353

}

func nextPerm(p []int) {
	for i := len(p) - 1; i >= 0; i-- {
		if i == 0 || p[i] < len(p)-i-1 {
			p[i]++
			return
		}
		p[i] = 0
	}
}

func getPerm(orig, p []int) []int {
	result := append([]int{}, orig...)
	for i, v := range p {
		result[i], result[i+v] = result[i+v], result[i]
	}
	return result
}

func modInverse(a int64, m int64) int64 {
	var x, y int64
    g := gcdExtended(a, m, &x, &y)

	if g != 1 {
		panic( "Inverse doesn't exist")
	} else {

	// m is added to handle negative x
	res := (x % m + m) % m
	return res
	}
}

func gcdExtended(a int64, b int64, x *int64, y *int64) int64 {

	// Base Case
	if a == 0 {
		*x, *y = 0,1
		return b
	}

	// To store results of recursive call
	var x1, y1 int64
	gcd := gcdExtended(b%a, a, &x1, &y1);

	// Update x and y using results of recursive
	// call
	*x = y1 - (b/a)*x1;
	*y = x1
	return gcd
}

package main
import("bufio";."fmt";."math/big";."os";"sort")

// github.com/EndlessCheng/codeforces-go
func main(){
	in:=bufio.NewReader(Stdin)
	const M=998244353
	var n,m,f int64
	Fscan(in,&n,&m)
	a:=make([][]int,m)
	for i:=range a{a[i]=make([]int,n)}
	f=1
	for i:=int64(0);i<n;i++{
		for _,r:=range a{Fscan(in,&r[i])}
		f*=i+1
	}
	ans:=f*m
	for _,r:=range a{
		sort.Ints(r)
		x:=int64(1)
		for j,v:=range r{
			v-=j+1
			if v<0{v=0}
			x=x*int64(v)%M
		}
		ans-=x
	}
	Print((ans%M+M)%M*new(Int).ModInverse(NewInt(f),NewInt(M)).Int64()%M)
}

package main

import (

	"fmt"

	"math/rand"
	"time"

	"sort"

	"bufio"
	"os"
)

func main() {

	r := bufio.NewReader(os.Stdin)
	rand.Seed(time.Now().UnixNano())

	var n, m int
	fmt.Fscan(r, &n, &m)
	//n = 10
	//m = 500

	//for k := 0; k < 1000; k++ {

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

			for k := 0; k < m; k++ {
				fmt.Fscan(r, &dist[j][k])
				//dist[j][k] = 1 + rand.Intn(n + 1)
			}
		}

		ans1 := solve(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)

		/*if ans1 != ans2 {
			fmt.Println(ans1)
			fmt.Println(ans2)
			fmt.Println(dist)

			fmt.Println("ERROR")
			break
		}*/
	//}

	fmt.Println(ans1)
	//fmt.Println(ans2)

}

func solve(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	var cnt int64

	for i := 0; i < m; i ++ {

		l := make([]int, n)

		for j := 0; j < n; j++ {
			//1 1 2 1 3 4 1 5 2 3 4 6 8 1 2 8 3 5 3
			d := dist[j][i]
			l[j] = d
		}

		offset := 1
		var cntPerPoint int64

		sort.Ints(l)

		for j := 0; j < n; j++ {
			d := l[j]
			if d > n {
				break
			}
			if d == 1 {
				cntPerPoint = fact[n]
				break
			}

			lat := n - d + 1

			f := int64(lat) * fact[n - offset]
			offset++

			delta := 0
			for k := 0; k < j; k++ {
				v := l[k] - 1 - delta
				delta++

				f *= int64(v)
			}

			cntPerPoint += f
		}

		cnt += cntPerPoint
	}

	//fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return (int64(modInv) * cnt) % 998244353
}

func solve_stupid(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	scores := make([][][]int, n)
	for j := 0; j < n; j++ {
		scores[j] = make([][]int, n + 1)
	}

	orig := make([]int, n)
	for j := 0; j < n; j++ {
		orig[j] = j
	}

	var cnt int64

	for p := make([]int, len(orig)); p[0] < len(p); nextPerm(p) {
		perm := getPerm(orig, p)

		points := make([]bool, m)

		for i := 0; i < len(perm); i ++ {
			c := perm[i]
			maxDist := n - i

			for k := 0; k < len(dist[c]); k++ {
				if dist[c][k] <= maxDist {
					points[k] = true
				}
			}
		}

		for j := 0; j < len(points); j++ {
			if points[j] {
				cnt++
			}
		}
	}

	//fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353

}

func nextPerm(p []int) {
	for i := len(p) - 1; i >= 0; i-- {
		if i == 0 || p[i] < len(p)-i-1 {
			p[i]++
			return
		}
		p[i] = 0
	}
}

func getPerm(orig, p []int) []int {
	result := append([]int{}, orig...)
	for i, v := range p {
		result[i], result[i+v] = result[i+v], result[i]
	}
	return result
}

func modInverse(a int64, m int64) int64 {
	var x, y int64
    g := gcdExtended(a, m, &x, &y)

	if g != 1 {
		panic( "Inverse doesn't exist")
	} else {

	// m is added to handle negative x
	res := (x % m + m) % m
	return res
	}
}

func gcdExtended(a int64, b int64, x *int64, y *int64) int64 {

	// Base Case
	if a == 0 {
		*x, *y = 0,1
		return b
	}

	// To store results of recursive call
	var x1, y1 int64
	gcd := gcdExtended(b%a, a, &x1, &y1);

	// Update x and y using results of recursive
	// call
	*x = y1 - (b/a)*x1;
	*y = x1
	return gcd
}

package main

import (

	"fmt"

	"math/rand"
	"time"

	"sort"
	"bufio"
	"os"
)

func main() {

	r := bufio.NewReader(os.Stdin)
	rand.Seed(time.Now().UnixNano())

	var n, m int
	fmt.Fscan(r, &n, &m)
	//n = 4
	//m = 5

	//for k := 0; k < 100; k++ {

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

			for k := 0; k < m; k++ {
				fmt.Fscan(r, &dist[j][k])
				//dist[j][k] = 1 + rand.Intn(n + 1)
			}
		}

		ans1 := solve(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)

		/*if ans1 != ans2 {
			fmt.Println(ans1)
			fmt.Println(ans2)
			fmt.Println(dist)

			fmt.Println("ERROR")
			break
		}*/
	//}

	fmt.Println(ans1)
	//fmt.Println(ans2)

}

func solve(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	var cnt int64

	for i := 0; i < m; i ++ {

		l := make([]int, n)

		for j := 0; j < n; j++ {
			//1 1 2 1 3 4 1 5 2 3 4 6 8 1 2 8 3 5 3
			d := dist[j][i]
			l[j] = d
		}

		offset := 1
		var cntPerPoint int64

		sort.Ints(l)

		for j := 0; j < n; j++ {
			d := l[j]
			if d > n {
				break
			}
			if d == 1 {
				cntPerPoint = fact[n]
				break
			}

			lat := n - d + 1

			f := int64(lat) * fact[n - offset]
			offset++

			delta := 0
			for k := 0; k < j; k++ {
				v := l[k] - 1 - delta
				delta++

				f *= int64(v)
			}

			cntPerPoint += f
		}

		cnt += cntPerPoint
	}

	//fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353
}

func solve_stupid(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	scores := make([][][]int, n)
	for j := 0; j < n; j++ {
		scores[j] = make([][]int, n + 1)
	}

	orig := make([]int, n)
	for j := 0; j < n; j++ {
		orig[j] = j
	}

	var cnt int64

	for p := make([]int, len(orig)); p[0] < len(p); nextPerm(p) {
		perm := getPerm(orig, p)

		points := make([]bool, m)

		for i := 0; i < len(perm); i ++ {
			c := perm[i]
			maxDist := n - i

			for k := 0; k < len(dist[c]); k++ {
				if dist[c][k] <= maxDist {
					points[k] = true
				}
			}
		}

		for j := 0; j < len(points); j++ {
			if points[j] {
				cnt++
			}
		}
	}

	fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353

}

func nextPerm(p []int) {
	for i := len(p) - 1; i >= 0; i-- {
		if i == 0 || p[i] < len(p)-i-1 {
			p[i]++
			return
		}
		p[i] = 0
	}
}

func getPerm(orig, p []int) []int {
	result := append([]int{}, orig...)
	for i, v := range p {
		result[i], result[i+v] = result[i+v], result[i]
	}
	return result
}

func modInverse(a int64, m int64) int64 {
	var x, y int64
    g := gcdExtended(a, m, &x, &y)

	if g != 1 {
		panic( "Inverse doesn't exist")
	} else {

	// m is added to handle negative x
	res := (x % m + m) % m
	return res
	}
}

func gcdExtended(a int64, b int64, x *int64, y *int64) int64 {

	// Base Case
	if a == 0 {
		*x, *y = 0,1
		return b
	}

	// To store results of recursive call
	var x1, y1 int64
	gcd := gcdExtended(b%a, a, &x1, &y1);

	// Update x and y using results of recursive
	// call
	*x = y1 - (b/a)*x1;
	*y = x1
	return gcd
}

package main

import (

	"fmt"

	"math/rand"
	"time"
	"bufio"
	"os"
)

func main() {

	r := bufio.NewReader(os.Stdin)
	rand.Seed(time.Now().UnixNano())

	var n, m int
	fmt.Fscan(r, &n, &m)
	//n = 4
	//m = 5

	//for k := 0; k < 100; k++ {

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

			for k := 0; k < m; k++ {
				fmt.Fscan(r, &dist[j][k])
				//dist[j][k] = 1 + rand.Intn(n + 1)
			}
		}

		//ans1 := solve(dist, n, m)
		ans2 := solve_stupid(dist, n, m)
		//ans2 := solve_stupid(dist, n, m)

	/*	if ans1 != ans2 {
			fmt.Println(ans1)
			fmt.Println(ans2)
			fmt.Println(dist)

			fmt.Println("ERROR")
			break
		}*/
	//}

	//fmt.Println(ans1)
	fmt.Println(ans2)

}

func solve(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	var cnt int64

	for i := 0; i < m; i ++ {

		l := make([]int, n)

		for j := 0; j < n; j++ {
			//1 1 2 1 3 4 1 5 2 3 4 6 8 1 2 8 3 5 3
			d := dist[j][i]
			latest := n - d + 1

			l[j] = latest
		}

		p := 0

		for j := 0; j < n; j++ {
			lat := l[j]
			if lat <= 0 {
				continue
			}

			s := int64(lat) * fact[n - p - 1]
			p++

			for k := j - 1; k >= 0; k-- {
				if l[k] <= 0 {
					continue
				}
				s *= int64(n) - int64(l[k])
			}

			cnt += s
		}
	}

	fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353
}

func solve_stupid(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	scores := make([][][]int, n)
	for j := 0; j < n; j++ {
		scores[j] = make([][]int, n + 1)
	}

	orig := make([]int, n)
	for j := 0; j < n; j++ {
		orig[j] = j
	}

	var cnt int64

	for p := make([]int, len(orig)); p[0] < len(p); nextPerm(p) {
		perm := getPerm(orig, p)

		points := make([]bool, m)

		for i := 0; i < len(perm); i ++ {
			c := perm[i]
			maxDist := n - i

			for k := 0; k < len(dist[c]); k++ {
				if dist[c][k] <= maxDist {
					points[k] = true
				}
			}
		}

		for j := 0; j < len(points); j++ {
			if points[j] {
				cnt++
			}
		}
	}

	fmt.Println(cnt)

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353

}

func nextPerm(p []int) {
	for i := len(p) - 1; i >= 0; i-- {
		if i == 0 || p[i] < len(p)-i-1 {
			p[i]++
			return
		}
		p[i] = 0
	}
}

func getPerm(orig, p []int) []int {
	result := append([]int{}, orig...)
	for i, v := range p {
		result[i], result[i+v] = result[i+v], result[i]
	}
	return result
}

func modInverse(a int64, m int64) int64 {
	var x, y int64
    g := gcdExtended(a, m, &x, &y)

	if g != 1 {
		panic( "Inverse doesn't exist")
	} else {

	// m is added to handle negative x
	res := (x % m + m) % m
	return res
	}
}

func gcdExtended(a int64, b int64, x *int64, y *int64) int64 {

	// Base Case
	if a == 0 {
		*x, *y = 0,1
		return b
	}

	// To store results of recursive call
	var x1, y1 int64
	gcd := gcdExtended(b%a, a, &x1, &y1);

	// Update x and y using results of recursive
	// call
	*x = y1 - (b/a)*x1;
	*y = x1
	return gcd
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

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

	ans := solve(dist, n, m)
	fmt.Println(ans)

}

func solve(dist [][]int, n, m int) int64 {
	fact := make([]int64, 21)
	fact[0] = 1
	for i := 1; i <= 20; i ++ {
		fact[i] = fact[i - 1] * int64(i)
	}

	var cnt int64

	for i := 0; i < m; i ++ {

		l := make([]int, n)

		for j := 0; j < n; j++ {
			//1 1 2 1 3 4 1 5 2 3 4 6 8 1 2 8 3 5 3
			d := dist[j][i]
			latest := n - d + 1

			l[j] = latest
		}

		p := 0

		for j := 0; j < n; j++ {
			lat := l[j]
			if lat <= 0 {
				continue
			}

			s := int64(lat) * fact[n - p - 1]
			p++

			for k := j - 1; k >= 0; k-- {
				if l[k] <= 0 {
					continue
				}
				s *= int64(n) - int64(l[k])
			}

			cnt += s
		}
	}

	modInv := modInverse(fact[n], 998244353)

	return int64(modInv) * cnt % 998244353
}

func modInverse(a int64, m int64) int64 {
	var x, y int64
    g := gcdExtended(a, m, &x, &y)

	if g != 1 {
		panic( "Inverse doesn't exist")
	} else {

	// m is added to handle negative x
	res := (x % m + m) % m
	return res
	}
}

func gcdExtended(a int64, b int64, x *int64, y *int64) int64 {

	// Base Case
	if a == 0 {
		*x, *y = 0,1
		return b
	}

	// To store results of recursive call
	var x1, y1 int64
	gcd := gcdExtended(b%a, a, &x1, &y1);

	// Update x and y using results of recursive
	// call
	*x = y1 - (b/a)*x1;
	*y = x1
	return gcd
}


package main

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

const N = 105

var t, n, m int
var s [N]string

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for qq := 0; qq < t; qq++ {
		fmt.Fscan(input, &n, &m)

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

		ans := 0

		for i := 0; i < n; i++ {
			if s[i][m-1] == 'R' {
				ans += 1
			}
		}

		for i := 0; i < m; i++ {
			if s[n-1][i] == 'D' {
				ans += 1
			}
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n, m int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &m)

		var line string
		var count = 0
		for j := 1; j <= n; j++ {
			fmt.Fscan(in, &line)
			if j == n {
				for k := 0; k < m-1; k++ {
					if line[k] != 'R' {
						count++
					}
				}
			} else {
				if line[m-1] != 'D' {
					count++
				}
			}
		}
		fmt.Println(count)
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var T, n, m int
	var str[105] string;
	fmt.Fscan(input, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &m)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &str[i])
		}
		ret := 0
		for i := 0; i < n; i++ {
			if str[i][m - 1] == 'R' {
				ret += 1
			}
		}
		for j := 0; j < m; j++ {
			if str[n - 1][j] == 'D' {
				ret += 1
			}
		}
		fmt.Printf("%d\n", ret)
	}
}

/*
URL:
https://codeforces.com/contest/1391/problem/B
*/

package main

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

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

const (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

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

var (
	t int

	n, m int
	C    [][]rune
)

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		n, m = ReadInt2()
		C = [][]rune{}

		for i := 0; i < n; i++ {
			row := ReadRuneSlice()
			C = append(C, row)
		}

		solve()
	}
}

func solve() {
	ans := 0

	for j := 0; j < m-1; j++ {
		if C[n-1][j] != 'R' {
			ans++
		}
	}
	for i := 0; i < n-1; i++ {
		if C[i][m-1] != 'D' {
			ans++
		}
	}

	fmt.Println(ans)
}

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

/********** bufio setting **********/

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

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

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

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

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

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

/*********** Input ***********/

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

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

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

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

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

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

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

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

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

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

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

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

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

import "fmt"

const maxn = 100 + 10

var mp [maxn][maxn]int
var s string
var n, m int

func myinit(n, m int) {
	for i := 0; i <= n; i++ {
		for j := 0; j <= m; j++ {
			mp[i][j] = 0
		}
	}
}
func isborder(x, y int) bool {
	if x == n && y == m {
		return false
	}
	if x == 1 || x == n || y == 1 || y == m {
		return true
	}
	return false
}
func main() {
	var t int
	fmt.Scan(&t)
	for tim := 1; tim <= t; tim++ {
		fmt.Scan(&n, &m)
		myinit(n, m)
		for i := 1; i <= n; i++ {
			fmt.Scan(&s)
			length := len(s)
			for j := 0; j < length; j++ {
				if s[j] == 'R' {
					mp[i][j+1] = 1
				}
			}
		}
		ans := 0
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				if !isborder(i, j) {
					continue
				}
				if mp[i][j] == 0 {
					if i == n {
						ans++
					}
				} else {
					if j == m {
						ans++
					}
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

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

const N = 105

var t, n, m int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for qq := 0; qq < t; qq++ {
		fmt.Fscan(input, &n, &m)
		s := make([]string, n)

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

		ans := 0

		for i := 0; i < n; i++ {
			if s[i][m-1] == 'R' {
				ans += 1
			}
		}

		for i := 0; i < m; i++ {
			if s[n-1][i] == 'D' {
				ans += 1
			}
		}

		fmt.Println(ans)
	}
}

package main

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

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

	var t, n, m int

	fmt.Fscan(r, &t)

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

		var chars string

		arr := make([][]rune, n)
		for j := range arr {
			fmt.Fscan(r, &chars)
			arr[j] = []rune(chars)
		}
		count := 0

		for row := 0; row < n; row++ {
			for col := 0; col < m; col++ {
				if col == m-1 && arr[row][col] == rune('R') {
					count++
				} else if row == n-1 && arr[row][col] == rune('D') {
					count++
				}
			}
		}

		fmt.Fprintln(w, count)
	}
}

package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var testcases int
	con.Scan(&testcases)
	for testcase := 0; testcase < testcases; testcase++ {
		var n, m int
		con.Scan(&n, &m)
		r := make([]string, n)
		for i := 0; i < n; i++ {
			con.Scan(&r[i])
		}
		c := 0
		for i := 0; i < n-1; i++ {
			if r[i][m-1] != 'D' {
				c++
			}
		}
		for i := 0; i < m-1; i++ {
			if r[n-1][i] != 'R' {
				c++
			}
		}
		con.Println(c)
	}
	return nil
}

package main

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

var reader *bufio.Reader
var writer *bufio.Writer

func solve(dir []string) int {
	rows, cols := len(dir), len(dir[0])
	ans := 0
	for i := 0; i+1 < rows; i++ {
		if dir[i][cols-1] != 'D' {
			ans++
		}
	}
	for i := 0; i+1 < cols; i++ {
		if dir[rows-1][i] != 'R' {
			ans++
		}
	}
	return ans
}

func main() {
	//ioutil.WriteFile("input.txt", []byte(generateInput()), os.ModeExclusive)

	debug := 1
	filename := "input.txt"
	if debug != 0 && len(os.Args) > 1 && os.Args[1] == "debug" {
		file, _ := os.Open(filename)
		reader = bufio.NewReaderSize(file, 1024*1024)
	} else {
		reader = bufio.NewReaderSize(os.Stdin, 1024*1024)
	}
	writer = bufio.NewWriterSize(os.Stdout, 1024*1024)

	t := readInt()
	for ; t > 0; t-- {
		arr := readInts()
		dir := make([]string, arr[0])
		for i := range dir {
			dir[i] = readLine()
		}
		ans := solve(dir)
		fmt.Println(ans)
	}

	writer.Flush()
}

func readInts() []int {
	line := readLine()
	fields := strings.Fields(line)
	res := make([]int, len(fields))
	for i := range fields {
		v, _ := strconv.ParseInt(fields[i], 10, 64)
		res[i] = int(v)
	}
	return res
}

func readInt() int {
	line := readLine()
	n, _ := strconv.ParseInt(line, 10, 64)
	return int(n)
}

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

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

package main

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

var (
	reader *bufio.Reader
	writer *bufio.Writer
)

func init() {
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
}
func scanf(format string, args ...interface{}) (int, error) {
	return fmt.Fscanf(reader, format, args...)
}

func printf(format string, args ...interface{}) (int, error) {
	return fmt.Fprintf(writer, format, args...)
}

func getAddresses(n []int) []interface{} {
	adds := make([]interface{}, len(n))
	for i := 0; i < len(n); i++ {
		adds[i] = &n[i]
	}
	return adds
}

func main() {
	defer writer.Flush()
	var t int
	var n, m int
	scanf("%d\n", &t)
	results := make([]int, t)
	for i := 0; i < t; i++ {
		scanf("%d %d\n", &n, &m)
		change := 0
		for j := 0; j < n; j++ {
			var str string
			scanf("%s\n", &str)
			if j == n-1 {
				for k, c := range str {
					if k == m-1 {
						break
					}
					if string(c) != "R" {
						change++
					}
				}
			} else {
				if str[len(str)-1:] != "D" {
					change++
				}
			}
		}
		results[i] = change
	}
	for i := 0; i < t; i++ {
		printf("%d\n", results[i])
	}

}

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 next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

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 nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

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

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

var (
	dx [4]int = [4]int{-1, 0, 1, 0}
	dy [4]int = [4]int{0, 1, 0, -1}
)

func solve() {
	n, m := nextInt(), nextInt()
	arr := make([][]byte, n)
	for i := range arr {
		arr[i] = []byte(next())
	}
	res := 0
	for i := 0; i < n-1; i++ {
		if arr[i][m-1] != 'D' {
			res++
		}
	}
	for i := 0; i < m-1; i++ {
		if arr[n-1][i] != 'R' {
			res++
		}
	}
	printf("%d\n", res)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		// file2, err := os.Create(name + ".out")
		// if err != nil {
		// 	log.Fatal(err)
		// }
		in = bufio.NewReaderSize(file1, 8192)
		// out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	for t := nextInt(); t > 0; t-- {
		solve()
	}
}

package main

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

func main() {
	var t, n, m int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &m)
		ans := 0
		for j := 0; j < n-1; j++ {
			fmt.Fscan(in, &s)
			if s[m-1] == 'R' {
				ans++
			}
		}
		fmt.Fscan(in, &s)
		for j := 0; j < m; j++ {
			if s[j] == 'D' {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

package main

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

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

	for t := io.NextInt(); t > 0; t-- {
		n, m := io.NextInt(), io.NextInt()
		g := make([]string, n)
		for i := range g {
			g[i] = io.Next()
		}

		ans := 0
		for i := range g {
			if g[i][m-1] == 'R' {
				ans++
			}
		}
		for j := range g[0] {
			if g[n-1][j] == 'D' {
				ans++
			}
		}
		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) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}


package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	// "sort"
	// "strings"
)

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	log.SetOutput(ioutil.Discard)
	// log.SetOutput(os.Stderr)

	n := nextInt()
	ans, maxLengthNow := 1, 1
	pre := nextInt()

	for i := 1; i < n; i++ {
		a := nextInt()

		if a > pre {
			maxLengthNow++
		} else {
			maxLengthNow = 1
		}

		if maxLengthNow > ans {
			ans = maxLengthNow
		}

		pre = a
	}

	println(ans)
}

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

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

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

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

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

package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	pre := 0
	result := 0
	tmp := 0
	for i := 0; i < N; i++ {
		x := fsc.NextInt()
		if pre < x {
			tmp++
		} else {
			result = IntMax(result, tmp)
			tmp = 1
		}
		pre = x
	}
	result = IntMax(result, tmp)
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) 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 *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) 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
		}
	}
}

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

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

package main

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

func main() {
	var n int;
	fmt.Scan(&n)
	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)
	var lastNum uint64 = 0
	var maxCnt uint64 = 0
	var currCnt uint64 = 0
	//for _, v := range strings.Split(reader.Text(), " ") {
	for reader.Scan() {
		currNum, _ := strconv.ParseUint(reader.Text(), 10, 64)
		if currNum > lastNum {
			currCnt++
			if currCnt > maxCnt {
				maxCnt = currCnt
			}
		} else {
			currCnt = 1
		}
		lastNum = currNum
	}
	fmt.Println(maxCnt)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Split(bufio.ScanWords)
	reader.Scan()
	var lastNum = 0
	var maxCnt = 0
	var currCnt = 0
	for reader.Scan() {
		currNum, _ := strconv.Atoi(reader.Text())
		if currNum > lastNum {
			currCnt++
			if currCnt > maxCnt {
				maxCnt = currCnt
			}
		} else {
			currCnt = 1
		}
		lastNum = currNum
	}
	fmt.Println(maxCnt)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text2.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Split(bufio.ScanWords)
	reader.Scan()
	var lastNum = 0
	var currCnt = 0
	var maxCnt = 0
	for reader.Scan() {
		currNum, _ := strconv.Atoi(reader.Text())
		if currNum > lastNum {
			currCnt++

		} else {
			if currCnt > maxCnt {
				maxCnt = currCnt
			}
			currCnt = 1
		}
		lastNum = currNum
	}
	if currCnt > maxCnt {
		maxCnt = currCnt
	}
	fmt.Println(maxCnt)
}
/*
int main() {
    int n;
    cin >> n;

    int max = 0;
    int cur = 0;

    int c, p = 0;
    for (int i = 0; i < n; i++) {
        cin >> c;
        if (c > p) {
            cur++;
        } else {
            if (cur > max) {
                max = cur;
            }
            cur = 1;
        }
        p = c;
    }

    if (cur > max) {
        max = cur;
    }

    cout << max;
    return 0;

 */

//func main() {
//	//file, _ := os.Open("text5.txt")
//	file, _ := os.Create("text5.txt")
//	size := 9999999
//	file.WriteString(strconv.Itoa(size) + "\n")
//
//	for i := 0; i < size; i++ {
//		file.WriteString(strconv.Itoa(rand.Intn(99999999)) + " ")
//
//	}
//
//}

//Infra for scanner
func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text5.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Split(bufio.ScanWords)
	reader.Scan()
	var lastNum = 0
	var maxCnt int32 = 0
	var currCnt int32 = 0
	for reader.Scan() {
		currNum, _ := strconv.Atoi(reader.Text())
		if currNum > lastNum {
			currCnt++
			if currCnt > maxCnt {
				maxCnt = currCnt
			}
		} else {
			currCnt = 1
		}
		lastNum = currNum
	}
	fmt.Println(maxCnt)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text2.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

    package main

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

    func main() {
        var n int
        fmt.Scan(&n)
        scanner := bufio.NewScanner(os.Stdin)
        scanner.Split(bufio.ScanWords)

        lastNum := 0
        maxCnt := 0
        for curCnt:=0; scanner.Scan(); {
            curNum, _ := strconv.Atoi(scanner.Text())
            if curNum > lastNum {
                curCnt++
                if curCnt > maxCnt {
                    maxCnt = curCnt
                }
            } else {
                curCnt = 1
            }
            lastNum = curNum
        }
        fmt.Print(maxCnt)
    }

package main

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

func main() {
	var n, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	count := 1
	fmt.Fscan(in, &a)
	la := a
	max := 1
	for i := 1; i < n; i++ {
		fmt.Fscan(in, &a)
		if a > la {
			count++
			if max < count {
				max = count
			}
		} else {
			count = 1
		}
		la = a

	}
	fmt.Println(max)
}

package main

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

var n int
var a []int
var r int

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

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

	r = 1
	for i := 0; i < n; i++ {
		j := i
		for (i+1 < n) && (a[i] < a[i+1]) {
			i++
		}
		l := i - j + 1
		if l > r {
			r = l
		}
	}

	fmt.Fprint(bufout, r)
}

package main

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

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

	text, _, err := reader.ReadLine()
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	n, err := strconv.ParseInt(string(text), 10, 64)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0)

	input, _, _ := reader.ReadLine()

	ns := strings.Split(string(input), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 0
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	var prev int = 0
	var inc_len int = 1
	var max_inc_len int = 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if a > prev && prev > 0 {
			inc_len += 1
		} else {
			if max_inc_len < inc_len {
				max_inc_len = inc_len
			}
			inc_len = 1
		}
		prev = a
	}
	if max_inc_len < inc_len {
		max_inc_len = inc_len
	}

	fmt.Println(max_inc_len)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())
    length, maxlength := 1, 0

    scanner.Scan()
    a, _ := strconv.Atoi(scanner.Text())
    for i := 1; i < n; i++ {
        scanner.Scan()
        b, _ := strconv.Atoi(scanner.Text())
        if b-a <= 0 {
            if length > maxlength {maxlength = length}
            length = 1
        } else {
            length++
        }
        a=b
    }
    if length > maxlength {
        fmt.Println(length)
    } else {
        fmt.Println(maxlength)
    }
}

package main

import "bufio"
import "os"
import "fmt"

func Read(s *bufio.Reader) string {
    line, _ := s.ReadString('\n')
    return line
}

func Write(s *bufio.Writer, a ...interface{}) {
    fmt.Fprintln(s, a...)
    s.Flush()
}

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

    var n int
    fmt.Sscanln(Read(reader), &n)

    a := make([]int, n)

    for i := 0; i < n - 1; i++ {
        line, _ := reader.ReadString(' ')
        fmt.Sscanln(line, &a[i])
    }

    fmt.Sscanln(Read(reader), &a[n - 1])
    var last int = 1
    var max int = 1

    for i := 1; i < n; i++ {
        if a[i] > a[i - 1] {
            last++
        } else {
            if last > max {
                max = last
            }
            last = 1
        }
    }

    if last > max {
        max = last
    }

    writer := bufio.NewWriter(os.Stdout)

    Write(writer, max)
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

const MAXN = 100000 + 10
func max(_x , _y int)int {
	if(_x > _y) {
		return _x
	}
	return _y
}
func main() {
	scanner = bufio.NewScanner(os.Stdin)
  	scanner.Split(bufio.ScanWords)
 	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	sol := 1
	var a [MAXN]int

	for i := 0 ; i < n ; i ++ {
		a[i] = getI()
	}
	now := 1
	for i := 1 ; i < n ; i ++ {
		if a[i] > a[i-1] {
			now ++
			sol = max(sol ,now)
		}else{
			now = 1
		}
	}

	writer.WriteString(fmt.Sprintf("%d\n",sol))
}

package main

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

func main() {
	var n, inp, maxc, perve, max uint32
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &n)
	for i := uint32(0); i < n; i++ {
		fmt.Fscanf(in, "%d", &inp)
		if inp > perve {
			perve = inp
			maxc++
			if max < maxc {
				max = maxc
			}
		} else {
			perve = inp
			maxc = 0
			maxc++
			if max < maxc {
				max = maxc
			}
		}
	}
	fmt.Println(max)
}

package main

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

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

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var max int
	seq := 1
	prev := int(1e9 + 1)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		if a > prev {
			seq++
		} else {
			seq = 1
		}
		if seq > max {
			max = seq
		}
		prev = a
	}
	fmt.Println(max)
}

package main

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

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

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

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

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

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

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

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

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

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

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

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	var ans int
	i := 0
	for i < n {
		j := i + 1
		for j < n && a[j-1] < a[j] {
			j++
		}
		ans = max(ans, j-i)
		i = j
	}
	println(ans)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	if len(nums) <= 1 {
		fmt.Println(len(nums))
		os.Exit(0)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	if len(nums) <= 1 {
		fmt.Println(len(nums))
		os.Exit(0)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

func getInts(s *bufio.Scanner, n int) []int {
    s.Scan()
    ab := strings.Fields(s.Text())
    a := make([]int,n)
    for i:=0; i<n; i++ {
        a[i], _ = strconv.Atoi(ab[i])
    }
    return a
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    n := getInts(scanner,1)
    as := getInts(scanner,n[0])
    maxlength := 0
    length := 1
    for i := 1; i < n[0]; i++ {
        if as[i]<=as[i-1] {
            if length > maxlength{
                maxlength = length
                length = 1
            }
        } else {
            length++
        }
    }
    if length > maxlength {
        fmt.Println(length)
    } else {
        fmt.Println(maxlength)
    }
}

package main

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

func main() {
	reader := getReader()
	reader.Scan()
	reader.Text()
	reader.Scan()
	var prev = -1
	var maxUp = 0
	var currUp = 0
	for _, v := range strings.Split(reader.Text(), " ") {
		curr, _ := strconv.Atoi(v)
		if curr > prev {
			currUp++
		} else {
			if currUp > maxUp {
				maxUp = currUp
			}
			currUp = 1
		}
		prev = curr
	}
	if currUp > maxUp {
		maxUp = currUp
	}
	fmt.Println(maxUp)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text3.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Scan()
	reader.Text()
	reader.Scan()
	var prev int64 = -1
	var maxUp int64 = 0
	var currUp int64 = 0
	for _, v := range strings.Split(reader.Text(), " ") {
		curr, _ := strconv.ParseInt(v, 0, 64)
		if curr > prev {
			currUp++
		} else {
			if currUp > maxUp {
				maxUp = currUp
			}
			currUp = 1
		}
		prev = curr
	}
	if currUp > maxUp {
		maxUp = currUp
	}
	fmt.Println(maxUp)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Scan()
	reader.Text()
	reader.Scan()
	var lastNum uint64 = 0
	var maxCnt uint64 = 0
	var currCnt uint64 = 0
	for _, v := range strings.Split(reader.Text(), " ") {
		currNum, _ := strconv.ParseUint(v, 10, 64)
		if currNum > lastNum {
			currCnt++
			if currCnt > maxCnt {
				maxCnt = currCnt
			}
		} else {
			currCnt = 1
		}
		lastNum = currNum
	}
	fmt.Println(maxCnt)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text4.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Scan()
	reader.Text()
	reader.Scan()
	var lastNum int64 = 0
	var maxCnt uint64 = 0
	var currCnt uint64 = 0
	for _, v := range strings.Split(reader.Text(), " ") {
		currNum, _ := strconv.ParseInt(v, 0, 64)
		if currNum > lastNum {
			currCnt++
			if currCnt > maxCnt {
				maxCnt = currCnt
			}
		} else {
			currCnt = 1
		}
		lastNum = currNum
	}
	fmt.Println(maxCnt)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text4.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Scan()
	reader.Text()
	reader.Scan()
	var prev int64 = -1
	var maxUp int64 = 0
	var currUp int64 = 0
	for _, v := range strings.Split(reader.Text(), " ") {
		curr, _ := strconv.ParseInt(v, 0, 64)
		if curr > prev {
			currUp++
			if currUp > maxUp {
				maxUp = currUp
			}
		} else {
			currUp = 1
		}
		prev = curr
	}
	fmt.Println(maxUp)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

func main() {
	reader := getReader()
	reader.Scan()
	reader.Text()
	reader.Scan()
	var prev = 0
	var maxUp = 0
	var currUp = 0
	for _, v := range strings.Split(reader.Text(), " ") {
		curr, _ := strconv.Atoi(v)
		if curr > prev {
			prev = curr
			currUp++
		} else {
			prev = curr
			if currUp > maxUp {
				maxUp = currUp
			}
			currUp = 1
		}
	}
	if currUp > maxUp {
		maxUp = currUp
	}
	fmt.Println(maxUp)
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("text3.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	// "sort"
	// "strings"
)

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	log.SetOutput(ioutil.Discard)
	// log.SetOutput(os.Stderr)

	n := nextInt()
	ans, maxLengthNow := 0, 1
	pre := nextInt()

	for i := 1; i < n; i++ {
		a := nextInt()

		if a > pre {
			maxLengthNow++
		} else {
			maxLengthNow = 1
		}

		if maxLengthNow > ans {
			ans = maxLengthNow
		}

		pre = a
	}

	println(ans)
}

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

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

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

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

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

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	if n <= 1 {
		fmt.Println(n)
		fmt.Println("early exit")
		os.Exit(0)
	}

	nums := make([]int64, 0)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	if len(nums) <= 1 {
		fmt.Println(len(nums))
		os.Exit(0)
	}

	maxsofar := 1
	for i := 1; i < len(nums); i++ {
		if nums[i-1] >= nums[i] {
			maxsofar = 1
		} else {
			maxsofar++
		}
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0)

	scanner.Scan()
	input := scanner.Text()
	if n == 10000 {
		fmt.Println(input)
	}
	ns := strings.Split(input, " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 0
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Println(maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	if len(nums) <= 1 {
		fmt.Println(len(nums))
		os.Exit(0)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i-1] >= nums[i] {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		} else {
			maxrn++
		}
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	if n <= 1 {
		fmt.Println(n)
		log.Println("early exit")
		os.Exit(0)
	}

	nums := make([]int64, 0)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	text, _, err := reader.ReadLine()
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	n, err := strconv.ParseInt(string(text), 10, 64)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0)

	input, _, _ := reader.ReadLine()

	ns := strings.Split(string(input), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 0
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 32)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0, n)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 1
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	if n <= 1 {
		fmt.Println(n)
		os.Exit(0)
	}

	nums := make([]int64, 0)

	scanner.Scan()
	ns := strings.Split(scanner.Text(), " ")

	for _, num := range ns {
		nn, _ := strconv.ParseInt(num, 10, 64)
		nums = append(nums, nn)
	}

	var maxsofar int64 = 0
	var maxrn int64 = 1
	for i := 1; i < len(nums); i++ {
		if nums[i] > nums[i-1] {
			maxrn++
		} else {
			if maxrn > maxsofar {
				maxsofar = maxrn
			}
			maxrn = 1
		}
		fmt.Fprintln(os.Stderr, maxrn)
	}
	if maxrn > maxsofar {
		maxsofar = maxrn
	}
	fmt.Println(maxsofar)
}


package main

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

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

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

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

		if sum/n*n != sum {
			fmt.Fprintln(out, "NO")
		} else {
			x := sum / n
			var f bool
			for _, v := range arr {
				if x == v {
					f = true
					break
				}
			}

			if f {
				fmt.Fprintln(out, "YES")
			} else {
				fmt.Fprintln(out, "NO")
			}
		}
	}
}

package main

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

var bufferedStdin = bufio.NewReader(os.Stdin)
var bufferedStdout = bufio.NewWriter(os.Stdout)

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

func solve() {
	var n int
	_, _ = fmt.Fscan(bufferedStdin, &n)
	m := make(map[int]bool)
	sum := 0
	for i := 0; i < n; i++ {
		var a int
		_, _ = fmt.Fscan(bufferedStdin, &a)
		m[a] = true
		sum += a
	}
	if _, exists := m[sum/n]; exists && sum%n == 0 {
		_, _ = fmt.Fprint(bufferedStdout, "YES\n")
	} else {
		_, _ = fmt.Fprint(bufferedStdout, "NO\n")
	}
}

func main() {
	var t int
	_, _ = fmt.Fscan(bufferedStdin, &t)
	for i := 0; i < t; i++ {
		solve()
	}
	_ = bufferedStdout.Flush()
}

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 gi2() (int,int) { return gi(),gi() }
func gi3() (int,int,int) { return gi(),gi(),gi() }
func gi4() (int,int,int,int) { return gi(),gi(),gi(),gi() }
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 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 tern(cond bool, a int, b int) int { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
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 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 vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		sa := sumarr(A); ans := "NO"
		for _,a := range A { if sa == a*N { ans = "YES" } }
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1686A
Date: 1/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1686/A
Problem: CF1686A
**/
func (in *CF1686A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		mapa := map[int]bool{}
		sum := 0
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
			mapa[arr[i]] = true
			sum += arr[i]
		}

		ans := "NO"

		if len(mapa) == 1 {
			ans = "YES"
		} else {
			for i := 0; i < n; i++ {
				val := sum - arr[i]
				if val%(n-1) == 0 && int(val/(n-1)) == arr[i] {
					ans = "YES"
				}

			}
		}
		fmt.Println(ans)

	}
}

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

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

package main

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

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)
		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}

		Fprintln(out, solveA(nums))
	}

}

func solveA(nums []int) string {
	n := len(nums)

	sum := 0
	for i := range nums {
		sum += nums[i]
	}

	for i := range nums {
		rem := sum - nums[i]
		avg := float32(rem) / float32(n-1)
		if float32(avg) == float32(nums[i]) {
			return "YES"
		}
	}
	return "NO"
}

package main

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

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

func ReadInt() int {
	var x int
	fmt.Fscan(in, &x)
	return x
}

func ReadString() string {
	var x string
	fmt.Fscan(in, &x)
	return x
}

func WritelnString(x string) {
	fmt.Fprintln(out, x)
}

func WriteString(x string) {
	fmt.Fprint(out, x)
}

func WritelnInt(x int) {
	fmt.Fprintln(out, "%d", x)
}

func WriteInt(x int) {
	fmt.Fprint(out, "%d ", x)
}

func Solve() string {

	var a []int
	sum := 0

	n := ReadInt()
	for i := 0; i < n; i++ {
		x := ReadInt()
		a = append(a, x)
		sum += x
	}

	for _, each := range a {
		if each*n == sum {
			return "YES"
		}
	}
	return "NO"

}

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

	T := ReadInt()
	for i := 0; i < T; i++ {
		WritelnString(Solve())
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		for j:=0;j<n;j++{
			sum:=0
			for k:=0;k<n;k++{
				if k == j {
					continue
				}
				sum+=list[k]
			}
			if float64(sum)/float64(n-1) == float64(list[j]) {
				fmt.Fprintln(out,"YES")
				goto out
			}
		}
		fmt.Fprintln(out,"NO")
		out:
	}
}

package main

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var ntests int
	fmt.Fscan(scanner, &ntests)
outer:
	for iter := 0; iter < ntests; iter++ {
		var n int
		fmt.Fscan(scanner, &n)
		slice := make([]int, n)
		sum := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(scanner, &slice[i])
			sum += slice[i]
		}
		for i := 0; i < n; i++ {
			tmp := sum - slice[i]
			if (tmp%(n-1) == 0) && (tmp/(n-1) == slice[i]) {
				fmt.Fprintln(writer, "YES")
				continue outer
			}
		}
		fmt.Fprintln(writer, "NO")
	}
}

package main

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

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

func ReadInt() int {
	var x int
	fmt.Fscan(in, &x)
	return x
}

func ReadString() string {
	var x string
	fmt.Fscan(in, &x)
	return x
}

func WritelnString(x string) {
	fmt.Fprintln(out, x)
}

func WriteString(x string) {
	fmt.Fprint(out, x)
}

func WritelnInt(x int) {
	fmt.Fprintln(out, "%d", x)
}

func WriteInt(x int) {
	fmt.Fprint(out, "%d ", x)
}

func Solve() string {

	var n, sum int
	var a []int
	sum = 0

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		a = append(a, x)
		sum += x
	}

	for _, each := range a {
		if each*n == sum {
			return "YES"
		}
	}
	return "NO"

}

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

	T := ReadInt()
	for i := 0; i < T; i++ {
		WritelnString(Solve())
	}
}

package main

import (
	"fmt"
)

func solve() string {

	var n, sum int
	var a []int
	sum = 0

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		a = append(a, x)
		sum += x
	}

	for _, each := range a {
		if each*n == sum {
			return "YES"
		}
	}
	return "NO"

}

func main() {

	var test int
	fmt.Scanf("%d", &test)
	for i := 0; i < test; i++ {
		fmt.Println(solve())
	}

}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var sum,yes uint
		for j:=0;j<n;j++{
			var x uint
			fmt.Fscan(in,&x)
			if sum==x {yes=1}
			sum|=x
		}
		if yes==1 {fmt.Fprintln(out,"YES")} else {fmt.Fprintln(out,"NO")}
	}
}


package main

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

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

type edge struct {
	x, y int
}

func ask(i int, n int) []int {
	if i < 0 {
		panic(fmt.Sprintln(out, "Incorrect value for ask"))
	}
	fmt.Fprintln(out, "?", i+1)
	out.Flush()
	d := make([]int, n)
	for i := range d {
		fmt.Fscan(in, &d[i])
	}
	return d
}

func printEdges(edges []edge) {
	fmt.Fprintln(out, "!")
	for i := range edges {
		fmt.Fprintln(out, edges[i].x+1, edges[i].y+1)
	}
}

func main() {

	defer out.Flush()

	solve := func(Case int) {
		var n int
		fmt.Fscan(in, &n)
		d := ask(0, n)
		cnt := [2]int{0, 0}
		for i := 1; i < n; i++ {
			cnt[d[i]&1]++
		}
		color := 0
		if cnt[0] > cnt[1] {
			color = 1
		}
		edges := []edge{}
		dNew := d
		for i, val := range d {
			if val&1 == color {
				if i != 0 {
					dNew = ask(i, n)
				}
				for j, val := range dNew {
					if val == 1 {
						edges = append(edges, edge{i, j})
					}
				}
			}
		}
		printEdges(edges)
	}

	T := 1
	//fmt.Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}
}

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

func min(a []int) int {
	mn := int(1e9)
	for i := range a {
		if a[i] < mn {
			mn = a[i]
		}
	}
	return mn
}
func gcd(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func reverse(s []byte) []byte {
	a := []byte(s)
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return a
}

package main

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

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

type edge struct {
	x, y int
}

func ask(i int, n int) []int {
	if i < 0 {
		panic(fmt.Sprintln(out, "Incorrect value for ask"))
	}
	fmt.Fprintln(out, "?", i+1)
	out.Flush()
	d := make([]int, n)
	for i := range d {
		fmt.Fscan(in, &d[i])
	}
	return d
}

func printEdges(edges []edge) {
	fmt.Fprintln(out, "!")
	for i := range edges {
		fmt.Fprintln(out, edges[i].x+1, edges[i].y+1)
	}
}

func main() {

	defer out.Flush()

	solve := func(Case int) {
		var n int
		fmt.Fscan(in, &n)
		d := ask(0, n)
		cnt := [2]int{0, 0}
		for _, val := range d {
			cnt[val&1]++
		}
		color := 0
		if cnt[0] > cnt[1] {
			color = 1
		}
		edges := []edge{}
		dNew := d
		for i, val := range d {
			if val&1 == color {
				if i != 0 {
					dNew = ask(i, n)
				}
				for j, val := range dNew {
					if val == 1 {
						edges = append(edges, edge{i, j})
					}
				}
			}
		}
		printEdges(edges)
	}

	T := 1
	//fmt.Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}
}

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

func min(a []int) int {
	mn := int(1e9)
	for i := range a {
		if a[i] < mn {
			mn = a[i]
		}
	}
	return mn
}
func gcd(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func reverse(s []byte) []byte {
	a := []byte(s)
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return a
}

package main

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

var (
	N     int
	depth [][]int
	memo  []int
	sc    *Scanner
	edges map[edge]bool
)

func f(n int) int {
	if n >= N-1 {
		return 0
	}
	if memo[n] == -1 {
		memo[n] = Min(len(depth[n])+f(n+1), len(depth[n+1])+f(n+2))
	}
	return memo[n]
}

type edge struct {
	a, b int
}

func ask(d int) {
	for _, v := range depth[d] {
		fmt.Printf("? %d\n", v)
		ans := sc.NextInts(N)
		for i, dist := range ans {
			if dist == 1 {
				edges[edge{Min(i+1, v), Max(i+1, v)}] = true
			}
		}
	}
}

func main() {
	sc = NewScanner()

	N = sc.NextInt()
	memo = InitInts1D(N, -1)

	fmt.Println("? 1")
	ans := sc.NextInts(N)
	depth = make([][]int, N)
	for i := 0; i < N; i++ {
		depth[ans[i]] = append(depth[ans[i]], i+1)
	}

	edges = make(map[edge]bool)
	for _, v := range depth[1] {
		edges[edge{1, v}] = true
	}

	d := 1
	for d < N-1 {
		if f(d) == len(depth[d])+f(d+1) {
			ask(d)
			d = d + 1
		} else if f(d) == len(depth[d+1])+f(d+2) {
			ask(d + 1)
			d = d + 2
		}
	}

	fmt.Println("!")
	for e := range edges {
		fmt.Printf("%d %d\n", e.a, e.b)
	}
}

type Scanner struct {
	bScanner *bufio.Scanner
}

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

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

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

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

package main

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

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

type edge struct {
	x, y int
}

func ask(i int, n int) []int {
	if i < 0 {
		panic(fmt.Sprintln(out, "Incorrect value for ask"))
	}
	fmt.Fprintln(out, "?", i+1)
	out.Flush()
	d := make([]int, n)
	for i := range d {
		fmt.Fscan(in, &d[i])
	}
	return d
}

func printEdges(edges []edge) {
	fmt.Fprintln(out, "!")
	for i := range edges {
		fmt.Fprintln(out, edges[i].x+1, edges[i].y+1)
	}
}

func main() {

	defer out.Flush()

	solve := func(Case int) {
		var n int
		fmt.Fscan(in, &n)
		d := ask(0, n)
		cnt := [2]int{0, 0}
		for i := range d[1:] {
			cnt[d[i]&1]++
		}
		color := 0
		if cnt[0] > cnt[1] {
			color = 1
		}
		edges := []edge{}
		dNew := d
		for i, val := range d {
			if val&1 == color {
				if i != 0 {
					dNew = ask(i, n)
				}
				for j, val := range dNew {
					if val == 1 {
						edges = append(edges, edge{i, j})
					}
				}
			}
		}
		printEdges(edges)
	}

	T := 1
	//fmt.Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}
}

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

func min(a []int) int {
	mn := int(1e9)
	for i := range a {
		if a[i] < mn {
			mn = a[i]
		}
	}
	return mn
}
func gcd(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func reverse(s []byte) []byte {
	a := []byte(s)
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return a
}


package main

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

var a [40003]int64

const md = 1e9 + 7
const N = 40000

func isPalindrome(s string) bool {
	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-i-1] {
			return false
		}
	}

	return true
}

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

	a[0] = 1
	for i := 1; i <= N; i++ {
		if !isPalindrome(fmt.Sprintf("%d", i)) {
			continue
		}

		for j := i; j <= N; j++ {
			a[j] = (a[j] + a[j-i]) % md
		}
	}

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

		fmt.Fprintln(out, a[n])
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func isPalindrome(i int) bool {
	v, r := i, 0
	for v != 0 {
		r *= 10
		r += v % 10
		v /= 10
	}
	return r == i
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()

	pals := make([]int, 0, 550)
	for i := 1; ; i++ {
		if isPalindrome(i) {
			pals = append(pals, i)
		}
		if len(pals) == 550 {
			break
		}
	}

	var dp [4*1e4 + 100][550]int

	for j := 0; j < 550; j++ {
		dp[1][j] = 1
	}

	for i := 1; i < 4*1e4+100; i++ {
		//for i := 2; i <= 20; i++ {
		//for j := 1; j < 20; j++ {
		for j := 1; j < 550; j++ {
			pal := pals[j-1]
			dp[i][j] = (dp[i][j-1] + dp[max(i-pal, 0)][j]) % (1e9 + 7)
			//fmt.Print(dp[i][j], "(", pal, ") ")
		}
		//fmt.Println()
	}

	for ; t > 0; t-- {
		n := io.ReadInt()
		fmt.Println(dp[n+1][549])
	}
}

package main

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

const mod = 1e9 + 7;
const mn = 4e4;
var (
	p [mn]int
	cnt int = 0
	f [500][mn + 5]int
)

func isPali(x int) bool {

	s := ""
	for x > 0 {

		s = strconv.Itoa(x % 10) + s
		x /= 10
	}

	//fmt.Println(s)

	l := 0
	r := len(s) - 1
	for r - l > 0 {

		if s[l] != s[r] {

			return false;
		}

		l += 1
		r -= 1
	}

	return true
}

func Init() {

	for i := 1; i <= mn; i++ {

		if isPali(i) {

			cnt += 1
			p[cnt] = i
			//fmt.Print(p[cnt - 1], " ")
		}
	}

	for i := 0; i <= cnt; i++ {

		f[i][0] = 1;
	}

	for i := 1; i <= mn; i++ {

		for j := 1; j <= cnt; j++ {

			if (p[j] <= i) {

				f[j][i] = (f[j-1][i] + f[j][i-p[j]]) % mod
			} else {

				f[j][i] = f[j-1][i]
			}
		}
	}
}

func main() {

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

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

		var n int;
		fmt.Fscan(in, &n)
		fmt.Println(f[cnt][n])
	}

}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func isPalindrome(i int) bool {
	v, r := i, 0
	for v != 0 {
		r *= 10
		r += v % 10
		v /= 10
	}
	return r == i
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()

	pals := make([]int, 0, 500)
	for i := 1; ; i++ {
		if isPalindrome(i) {
			pals = append(pals, i)
		}
		if len(pals) == 500 {
			break
		}
	}

	var dp [4*1e4 + 10][500]int

	for j := 0; j < 500; j++ {
		dp[1][j] = 1
	}

	for i := 1; i <= 4*1e4; i++ {
		//for i := 2; i <= 20; i++ {
		//for j := 1; j < 20; j++ {
		for j := 1; j < 500; j++ {
			pal := pals[j-1]
			dp[i][j] = (dp[i][j-1] + dp[max(i-pal, 0)][j]) % (1e9 + 7)
			//fmt.Print(dp[i][j], "(", pal, ") ")
		}
		//fmt.Println()
	}

	for ; t > 0; t-- {
		n := io.ReadInt()
		fmt.Println(dp[n+1][499])
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func isPalindrome(i int) bool {
	v, r := i, 0
	for v != 0 {
		r *= 10
		r += v % 10
		v /= 10
	}
	return r == i
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()

	pals := make([]int, 0, 500)
	for i := 1; ; i++ {
		if isPalindrome(i) {
			pals = append(pals, i)
		}
		if len(pals) == 500 {
			break
		}
	}

	var dp [4*1e4 + 10][500]int

	for j := 0; j < 500; j++ {
		dp[1][j] = 1
	}

	for i := 1; i <= 4*1e4; i++ {
		//for i := 2; i <= 20; i++ {
		//for j := 1; j < 20; j++ {
		for j := 1; j < 500; j++ {
			pal := pals[j-1]
			dp[i][j] = dp[i][j-1] + dp[max(i-pal, 0)][j]
			//fmt.Print(dp[i][j], "(", pal, ") ")
		}
		//fmt.Println()
	}

	for ; t > 0; t-- {
		n := io.ReadInt()
		fmt.Println(dp[n+1][499])
	}
}