Ela likes Chess a lot. During breaks, she usually challenges her co-worker in DTL to some chess games. She's not an expert at classic chess, but she's very interested in Chess variants, where she has to adapt to new rules and test her tactical mindset to win the game.The problem, which involves a non-standard chess pieces type that is described below, reads: given $$$3$$$ white crickets on a $$$n \cdot n$$$ board, arranged in an "L" shape next to each other, there are no other pieces on the board. Ela wants to know with a finite number of moves, can she put any white cricket on the square on row $$$x$$$, column $$$y$$$?An "L"-shape piece arrangement can only be one of the below:    For simplicity, we describe the rules for crickets on the board where only three white crickets are. It can move horizontally, vertically, or diagonally, but only to a square in some direction that is immediately after another cricket piece (so that it must jump over it). If the square immediately behind the piece is unoccupied, the cricket will occupy the square. Otherwise (when the square is occupied by another cricket, or does not exist), the cricket isn't allowed to make such a move.See an example of valid crickets' moves on the pictures in the Note section.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows. The first line of each test case contains $$$n$$$ ($$$4 \le n \le 10^5$$$) — denotes the size of the chessboard. The second line of each test case contains 6 numbers: $$$r_1$$$, $$$c_1$$$, $$$r_2$$$, $$$c_2$$$, $$$r_3$$$, $$$c_3$$$ ($$$1 \le r_1, c_1, r_2, c_2, r_3, c_3 \le n$$$) — coordinates of the crickets. The input ensures that the three crickets are arranged in an "L" shape that the legend stated. The third line of each test case contains 2 numbers: $$$x$$$, $$$y$$$ ($$$1 \le x, y \le n$$$) — coordinates of the target square.

For each test case, print "YES" or "NO" to denotes whether Ela can put a cricket on the target square.

NoteHere's the solution for the first test case. The red square denotes where the crickets need to reach. Note that in chess horizontals are counted from bottom to top, as well as on this picture.

package main

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

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

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for tt:=0; tt<T; tt++ {
		var n int
		scanf("%d\n", &n)
		p := make([][]int, 3)
		for i:=0; i<3; i++ {
			p[i] = make([]int, 2)
			for j:=0; j<2; j++ {
				scanf("%d ", &p[i][j])
			}
		}

		var x, y int
		scanf("\n%d %d\n", &x, &y)

		middle := -1
		isMiddle := func (m, o1, o2 int) bool {
			return (p[m][0] == p[o1][0] && p[m][1] == p[o2][1]) || (p[m][0] == p[o2][0] && p[m][1] == p[o1][1])
		}
		if isMiddle(0, 1, 2) {
			middle = 0
		} else if isMiddle(1, 0, 2) {
			middle = 1
		} else {
			middle = 2
		}

		isCorner := func (r, c int) bool {
			if (r == 1 && c == 1) || (r == 1 && c == n) || (r == n && c == 1) || (r == n && c == n) {
				return true
			}
			return false
		}

		if isCorner(p[middle][0], p[middle][1]) {
			if p[middle][0] == x || p[middle][1] == y {
				printf("%s\n", "YES")
				continue
			}
			printf("%s\n", "NO")
			continue
		}

		isYes := func(r, c int) bool {
			if (int(math.Abs(float64(x - r))) & 1) == 0 && (int(math.Abs(float64(y - c))) & 1) == 0 {
				return true
			}
			return false
		}
		if isYes(p[0][0], p[0][1]) || isYes(p[1][0], p[1][1]) || isYes(p[2][0], p[2][1]) {
			printf("%s\n", "YES")
		} else {
			printf("%s\n", "NO")
		}
	}
}

package main

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

/*
type point struct {
	i int
	j int
}
*/

func is_corner(x, y, n int) bool {
	if x == 1 && y == 1 { return true }
	if x == 1 && y == n { return true }
	if x == n && y == 1 { return true }
	if x == n && y == n { return true }
	return false
}

func check_corner_reach(xc, yc, n, x, y int) bool {
	if (xc == x) || (yc == y) { return true }
	return false
}

func check_normal_reach(x, y int) bool {
	if x == 1 && y == 1 { return false }
	return true
}

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var l1, l2, l3, l4 int
		var r1, r2, r3, r4 int
		var lc, rc int
		var n int

		fmt.Fscan(r, &n, &l1, &r1, &l2, &r2, &l3, &r3, &l4, &r4)

		// fmt.Fprintln(w, "&&&& ", n, l1, r1, l2, r2, l3, r3, l4, r4) // ***

		if l1 == l2 || l1 == l3 {
			lc = l1
		} else if l2 == l1 || l2 == l3 {
			lc = l2
		} else {
			lc = l3
		}

		if r1 == r2 || r1 == r3 {
			rc = r1
		} else if r2 == r1 || r2 == r3 {
			rc = r2
		} else {
			rc = r3
		}

		// fmt.Fprintln(w, "%%%% ", lc, rc)

		can_reach := true
		if is_corner(lc, rc, n){
			// fmt.Fprintln(w, " &&&& Corner")
			can_reach = check_corner_reach(lc, rc, n, l4, r4)
		} else {
			l4 = abs(lc-l4)%2
			r4 = abs(rc-r4)%2
			can_reach = check_normal_reach(l4, r4)
		}

		if !can_reach {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
		}

	}

}

package main

import (
	"fmt"
	"math"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var n int
		fmt.Scan(&n)
		p := make([][]int, 3)
		for i:=0; i<3; i++ {
			p[i] = make([]int, 2)
			for j:=0; j<2; j++ {
				fmt.Scan(&p[i][j])
			}
		}

		var x, y int
		fmt.Scan(&x, &y)

		middle := -1
		isMiddle := func (m, o1, o2 int) bool {
			return (p[m][0] == p[o1][0] && p[m][1] == p[o2][1]) || (p[m][0] == p[o2][0] && p[m][1] == p[o1][1])
		}
		if isMiddle(0, 1, 2) {
			middle = 0
		} else if isMiddle(1, 0, 2) {
			middle = 1
		} else {
			middle = 2
		}

		isCorner := func (r, c int) bool {
			if (r == 1 && c == 1) || (r == 1 && c == n) || (r == n && c == 1) || (r == n && c == n) {
				return true
			}
			return false
		}

		if isCorner(p[middle][0], p[middle][1]) {
			if p[middle][0] == x || p[middle][1] == y {
				fmt.Println("YES")
				continue
			}
			fmt.Println("NO")
			continue
		}

		isYes := func(r, c int) bool {
			if int(math.Abs(float64(x - r))) & 1  > 0 && int(math.Abs(float64(y - c))) & 1 > 0 {
				return true
			}
			return false
		}
		if isYes(p[0][0], p[0][1]) || isYes(p[1][0], p[1][1]) || isYes(p[2][0], p[2][1]) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var n int
		fmt.Scan(&n)
		p := make([][]int, 3)
		for i:=0; i<3; i++ {
			p[i] = make([]int, 2)
			for j:=0; j<2; j++ {
				fmt.Scan(&p[i][j])
			}
		}
		// fmt.Scan(&n, &p1[0], &p1[1], &p2[0], &p2[1], &p3[0], &p3[1])

		// fmt.Println(tt);

		var x, y int
		fmt.Scan(&x, &y)
		isYes := func(r, c int) bool {
			if int(math.Abs(float64(x - r))) % 2 == 0 && int(math.Abs(float64(y - c))) % 2 == 0 {
				// fmt.Println(r, c)
				return true
			}
			return false
		}

		middle := -1
		isMiddle := func (m, o1, o2 int) bool {
			if p[m][0] == p[o1][0] {
				return p[m][1] == p[o2][1]
			} else if p[m][0] == p[o2][0] {
				return p[m][1] == p[o2][1]
			}
			return false
		}
		if isMiddle(0, 1, 2) {
			middle = 0
		} else if isMiddle(1, 0, 2) {
			middle = 1
		} else {
			middle = 2
		}

		isCorner := func (r, c int) bool {
			if (r == 1 && c == 1) || (r == 1 && c == n) || (r == n && c == 1) || (r == n && c == n) {
				return true
			}
			return false
		}

		if isCorner(p[middle][0], p[middle][1]) {
			if p[middle][0] == x || p[middle][1] == y {
				fmt.Println("YES")
				continue
			}
			fmt.Println("NO")
			continue
		}

		if isYes(p[0][0], p[0][1]) || isYes(p[1][0], p[1][1]) || isYes(p[2][0], p[2][1]) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


YouKn0wWho has an integer sequence $$$a_1, a_2, \ldots, a_n$$$. He will perform the following operation until the sequence becomes empty: select an index $$$i$$$ such that $$$1 \le i \le |a|$$$ and $$$a_i$$$ is not divisible by $$$(i + 1)$$$, and erase this element from the sequence. Here $$$|a|$$$ is the length of sequence $$$a$$$ at the moment of operation. Note that the sequence $$$a$$$ changes and the next operation is performed on this changed sequence.For example, if $$$a=[3,5,4,5]$$$, then he can select $$$i = 2$$$, because $$$a_2 = 5$$$ is not divisible by $$$i+1 = 3$$$. After this operation the sequence is $$$[3,4,5]$$$.Help YouKn0wWho determine if it is possible to erase the whole sequence using the aforementioned operation.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10\,000$$$)  — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

For each test case, print "YES" (without quotes) if it is possible to erase the whole sequence using the aforementioned operation, print "NO" (without quotes) otherwise. You can print each letter in any register (upper or lower).

NoteIn the first test case, YouKn0wWho can perform the following operations (the erased elements are underlined): $$$[1, \underline{2}, 3] \rightarrow [\underline{1}, 3] \rightarrow [\underline{3}] \rightarrow [\,].$$$In the second test case, it is impossible to erase the sequence as $$$i$$$ can only be $$$1$$$, and when $$$i=1$$$, $$$a_1 = 2$$$ is divisible by $$$i + 1 = 2$$$.

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int64, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
    }
    // NO: a[i] sholud be divisible for all: 2,..,i+2
    // that means: that a[i] should be divisible by d = lcm(2,3,..,i+2)
    // so, d <= a[i] <= 1e9
    // create appropriate divisors
    d := []int64{2}
    k := int64(1)
    for d[k - 1] < int64(1e9) {
        d = append(d, lcm(d[k - 1],(k+2)))
        k++
    }
    for i := 0; i < min(len(d), n); i++ {
        if a[i] % d[i] == 0 {
            fmt.Fprintln(output, "NO")
            return
        }
    }
    fmt.Fprintln(output, "YES")
}

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

func lcm(a, b int64) int64 {
    return a * b / gcd(a, b)
}
func min(a, b int) int {
    if a < b { return a}
    return b
}

package main

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

/*
2
2
3 6
4
3 7 8 10
---
NO
YES
*/

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

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	a = a[:min(22, len(a))]

	erasablePrefixLen := 0

	for i, num := range a {
		possible := false

		for j := i + 2 - erasablePrefixLen; j <= i+2; j++ {
			if num%j != 0 {
				possible = true
				break
			}
		}

		if possible {
			erasablePrefixLen++
		} else {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	fmt.Fprintln(writer, "YES")
}

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

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

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

const maxUint = ^uint(0)

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

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

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

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

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

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

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

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

	return minNumIdx
}

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

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

	return maxNumIdx
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

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

var N int
var a []int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

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

		a = make([]int, N)

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

		ans := solve()

		fmt.Println(ans)
	}
}

func solve() string {

	var b []int

	b = make([]int, N)

	for i := N - 1; i >= 0; i-- {
		pos := i + 1
		el := a[i]
		cnt := 0
		for ;; {
			if pos + 1 == 0 {
				break
			}
			if el % (pos + 1) == 0 {
				cnt++
				pos--
				continue
			}
			break
		}

		b[i] = cnt
	}

	var cnt int

	for i := 0; i < N; i++ {
		if b[i] > cnt {
			return "NO"
		}
		cnt++
	}
	return "YES"
}

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

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

package main

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

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

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

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

		}
		return m
	}
}

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

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

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

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

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

	return
}

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

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

	return num
}

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

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

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

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

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

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

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

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

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

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

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

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

func DIVI(x []int) string {
	if len(x) == 1 {
		if x[0]%2 == 0 {
			return "NO"
		} else {
			return "YES"

		}
	} else {
		q := len(x)
		if DIVI(x[:q-1]) == "YES" {
			b := 0
			for j := 2; j < q+2; j++ {
				if x[q-1]%j != 0 {
					b = 1
					break
				}
			}
			if b == 1 {
				return "YES"
			} else {
				return "NO"

			}
		} else {
			return "NO"
		}
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		ARR := make([]int, n)

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

		fmt.Println(DIVI(ARR))

	}
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		a := readArrayInt64(reader)

		var lsum int64 = 1
		ok := true
		for i := 0; i < n; i++ {
			lsum = lcm(lsum, int64(i+2))
			if a[i] % lsum == 0 {
				ok = false
				fmt.Fprintln(writer, "NO")
				break
			}
		}

		if ok {
			fmt.Fprintln(writer, "YES")
		}

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

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

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

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

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

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

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

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

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(in, &a[i])
		}

		var i int
		for i = 0; i < n; i++ {
			var d int
			for d = len(a) - 1; d >= 0; d-- {
				if a[d]%(d+2) != 0 {
					break
				}
			}
			if d == -1 {
				break
			}
			a = append(a[:d], a[d+1:]...)
		}

		if i == n {
			out.WriteString("YES\n")
		} else {
			out.WriteString("NO\n")
		}
	}
}

package main

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

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

var mod int64 = 1000000007
var a [100000]int

func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func f(n int) bool {
	x := int64(1)
	for i := 1; i <= n; i++ {
		if x < mod {
			gc := gcd(x, int64(i+1))
			x = x * int64(i+1)
			x = x / gc
		}
		if int64(a[i-1])%x == 0 {
			return false
		}
	}
	return true
}

func main() {
	defer w.Flush()
	var t int = 1000000
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n int
		fmt.Fscan(r, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		ans2 := f(n)
		if ans2 {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}

package main

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

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

var mod int64 = 1000000007
var a [100000]int

func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func f(n int) bool {
	x := int64(1)
	for i := 1; i <= n; i++ {
		if x < mod {
			gc := gcd(x, int64(i+1))
			x = x * int64(i+1)
			x = x / gc
		}
		if int64(a[i-1])%x == 0 {
			return false
		}
	}
	return true
}

func main() {
	defer w.Flush()
	var t int = 1000000
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n int
		fmt.Fscan(r, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		ans := f(n)
		if ans {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}

package main

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

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

var mod int64 = 1000000007

func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func f(a []int) bool {
	n := len(a)
	x := int64(1)
	for i := 1; i <= n; i++ {
		if x < mod {
			gc := gcd(x, int64(i+1))
			x = x * int64(i+1)
			x = x / gc
		}
		if int64(a[i-1])%x == 0 {
			return false
		}
	}
	return true
}

func main() {
	defer w.Flush()
	var t int = 1000000
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		ans := f(a)
		if ans {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}

package main

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

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

var mod int64 = 10000000000007

func f1(a []int) bool {

	lcms := [...]int{2, 6, 12, 60, 60, 420, 840, 2520, 2520, 27720, 27720, 360360, 360360, 360360, 720720, 12252240, 12252240, 232792560, 232792560, 232792560, 232792560}
	n := len(a)

	if n > 21 {
		a = a[:21]
	}
	for i, v := range a {
		if v%lcms[i] == 0 {
			return false
		}
	}
	return true

}

func f2(a []int) bool {
	n := len(a)
	x := int64(1)
	for i := 1; i <= n; i++ {
		if x < mod {
			x = x * int64(i+1)
		}
		if int64(a[i-1])%x == 0 {
			return false
		}
	}
	return true
}

func main() {
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		ans := f1(a)
		if ans {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}

}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		for i := 1; i <= n; i++ {
			var num int
			fmt.Fscan(in, &num)
			ok := false
			for j := i + 1; j >= 2; j-- {
				if num%j != 0 {
					ok = true
					break
				}
			}
			if !ok {
				can = false
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

	var t int
	var n int
	arr := make([]int, 3e5+10)
Outer:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		for i := 1; i <= n; i++ {
			Fscan(in, &arr[i])
		}
		for i := 1; i <= n; i++ {
			ok := false
			v := arr[i]
			for j := i + 1; j >= 2; j-- {
				if v%j != 0 {
					ok = true
					break
				}
			}
			if !ok {
				Fprintln(out, "NO")
				continue Outer
			}
		}
		Fprintln(out, "YES")
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1603A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	lcms := [...]int{2, 6, 12, 60, 60, 420, 840, 2520, 2520, 27720, 27720, 360360, 360360, 360360, 720720, 12252240, 12252240, 232792560, 232792560, 232792560, 232792560}
	var T, n int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		if n > 21 {
			a = a[:21]
		}
		for i, v := range a {
			if v%lcms[i] == 0 {
				Fprintln(out, "NO")
				continue o
			}
		}
		Fprintln(out, "YES")
	}
}

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

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int64, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
    }
    // NO: a[i] sholud be divisible for all: 2,..,i+2
    // that means: that a[i] should be divisible by d = 2*3*..*i+2
    // so, d <= a[i] <= 1e9
    // create appropriate divisors
    d := []int64{2}
    k := int64(1)
    for d[k - 1]*(k + 2) < int64(1e9) {
        d = append(d, d[k - 1]*(k+2))
        k++
    }
    for i := 0; i < min(11, n); i++ {
        if a[i] % d[i] == 0 {
            fmt.Fprintln(output, "NO")
            return
        }
    }
    fmt.Fprintln(output, "YES")
}

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func abs(x int64) int64 {
    if x >= 0 { return x}
    return -x
}

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
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
    }
    //prime := make([]bool, 314) // 313 is 65th prime number
    prime := []int{2,3}
    for i := 5; i*i <= 100000; i+=2 {
        if isPrime(i) {
            prime = append(prime, i)
        }
    }
    ans := true
    for i := 0; i < len(a); i++ {
        flag := false
        for _, p := range prime {
            if p > i + 2 { break }
            flag = flag || a[i] % p != 0
        }
        ans = ans && flag
    }
    if !ans {
        fmt.Fprintln(output, "NO")
    } else {
        fmt.Fprintln(output, "YES")
    }
}

func isPrime(x int) bool {
    for i := 2; i*i <= x; i++ {
        if x % i == 0 { return false}
    }
    return true
}

func abs(x int64) int64 {
    if x >= 0 { return x}
    return -x
}

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
}

package main

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

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

var mod int64 = 10000000000007

func f1(a []int) bool {

	lcms := [...]int{2, 6, 12, 60, 60, 420, 840, 2520, 2520, 27720, 27720, 360360, 360360, 360360, 720720, 12252240, 12252240, 232792560, 232792560, 232792560, 232792560}
	n := len(a)

	if n > 21 {
		a = a[:21]
	}
	for i, v := range a {
		if v%lcms[i] == 0 {
			return false
		}
	}
	return true

}

func f2(a []int) bool {
	n := len(a)
	x := int64(1)
	for i := 1; i <= n; i++ {
		if x < mod {
			x = x * int64(i+1)
		}
		if int64(a[i-1])%x == 0 {
			return false
		}
	}
	return true
}

func main() {
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		ans := f2(a)
		if ans {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}

}

package main

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

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

var mod int64 = 10000000000007

func main() {
	defer w.Flush()
	var t int
	Fscan(r, &t)
	for t > 0 {
		t--
		var n int
		Fscan(r, &n)
		var x int64
		x = 1
		ans := true
		for i := 1; i <= n; i++ {
			var y int
			if x < mod {
				x = x * int64(i+1)
			}
			Fscan(r, &y)
			if int64(y)%x == 0 {
				ans = false
			}
		}
		if ans {
			Println("YES")
		} else {
			Println("NO")
		}

	}

}

package main

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

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

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

var mod int64 = 100000000007

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for t > 0 {
		t--
		var n int
		scanf("%d\n", &n)
		var x int64
		x = 1
		i := 1
		ans := true
		for ; i <= n; i++ {
			var y int
			if x < mod {
				x = x * int64(i+1)
			}
			scanf("%d", &y)
			if int64(y)%x == 0 {
				ans = false
			}
		}
		if ans {
			printf("YES\n")
		} else {
			printf("NO\n")
		}

		scanf("\n")
	}

}

package main

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

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

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

var mod int64 = 1000000007

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for t > 0 {
		t--
		var n int
		scanf("%d\n", &n)
		var x int64
		x = 1
		i := 1
		ans := true
		for ; i <= n; i++ {
			var y int
			if x < mod {
				x = x * int64(i+1)
			}
			scanf("%d", &y)
			if int64(y)%x == 0 {
				ans = false
			}
		}
		if ans {
			printf("YES\n")
		} else {
			printf("NO\n")
		}

		scanf("\n")
	}

}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		for i := 1; i <= n; i++ {
			var num int
			fmt.Fscan(in, &num)
			ok := false
			for j := i + 1; j >= 2; j-- {
				if num%j != 0 {
					ok = true
					break
				}
			}
			if !ok {
				can = false
				break
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		for i := 1; i <= n; i++ {
			var num int
			fmt.Fscan(in, &num)
			for j := i + 1; j >= 2 && can; j-- {
				if num%j != 0 {
					can = true
					break
				}
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		var target int64 = 1
		for i := 0; i < n; i++ {
			var num int64
			fmt.Fscan(in, &num)

			if can {
				if target < 1e9 && isPrime(i+2) {
					target *= int64(i + 2)
				}
				can = num%target != 0
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

func isPrime(num int) bool {
	for i := 2; i*i < num; i++ {
		if num%i == 0 {
			return false
		}
	}
	return true
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		var target int64 = 1
		for i := 0; i < n; i++ {
			var num int64
			fmt.Fscan(in, &num)

			if can && target < 1e9 {
				if isPrime(i + 2) {
					target *= int64(i + 2)
				}
				can = num%target != 0
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

func isPrime(num int) bool {
	for i := 2; i*i < num; i++ {
		if num%i == 0 {
			return false
		}
	}
	return true
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		var target int64 = 1
		for i := 0; i < n; i++ {
			var num int64
			fmt.Fscan(in, &num)
			if can && target < 1e9 {
				target *= int64(i + 2)
				can = num%target != 0
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		target := 1
		for i := 0; i < n; i++ {
			num := 0
			fmt.Fscan(in, &num)
			if can && i < 11 {
				target *= i + 2
				can = num%target != 0
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		can := true
		for i := 0; i < n; i++ {
			num := 0
			fmt.Fscan(in, &num)
			if i == 0 {
				can = num&1 != 0
			}
		}
		if can {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

	var t int
	var n int
	arr := make([]int, 3e5+10)
A:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		for i := 1; i <= n; i++ {
			Fscan(in, &arr[i])
		}
		s := 0
	B:
		for i := 1; i <= n; i++ {
			v := arr[i]
			s++
			if v%(i+1) == 0 {
				for d := 1; s > 1; s, d = s-1, d+1 {
					if v%(i+1-d) != 0 {
						continue B
					}
				}
				Fprintln(out, "NO")
				continue A
			}
		}
		Fprintln(out, "YES")
	}
}

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

package main

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

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

	var t int
	var n int
	arr := make([]int, 3e5+10)
A:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		for i := 1; i <= n; i++ {
			Fscan(in, &arr[i])
		}
		s := 0
	B:
		for i := 1; i <= n; i++ {
			v := arr[i]
			s++
			if v%(i+1) == 0 {
				for d := 1; s != 0; s, d = s-1, d+1 {
					if v&(i+1-d) != 0 {
						continue B
					}
				}
				Fprintln(out, "NO")
				continue A
			}
		}
		Fprintln(out, "YES")
	}
}

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


A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true:  Employee A is the immediate manager of employee B  Employee B has an immediate manager employee C such that employee A is the superior of employee C. The company will not have a managerial cycle. That is, there will not exist an employee who is the superior of his/her own immediate manager.Today the company is going to arrange a party. This involves dividing all n employees into several groups: every employee must belong to exactly one group. Furthermore, within any single group, there must not be two employees A and B such that A is the superior of B.What is the minimum number of groups that must be formed?

The first line contains integer n (1 ≤ n ≤ 2000) — the number of employees. The next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager.  It is guaranteed, that no employee will be the immediate manager of him/herself (pi ≠ i). Also, there will be no managerial cycles.

Print a single integer denoting the minimum number of groups that will be formed in the party.

NoteFor the first example, three groups are sufficient, for example:   Employee 1  Employees 2 and 4  Employees 3 and 5

package main

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

var scanner *bufio.Scanner

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

type Node struct {
  Height int
  Children []*Node
}

func setHeight(node *Node) int {
  if node.Height == -1 {
    maxHeight := 1
    for _, child := range node.Children {
      height := 1 + setHeight(child)
      if height > maxHeight {
        maxHeight = height
      }
    }
    node.Height = maxHeight
  }
  return node.Height
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := int(getI())
  nodes := make([]Node, n)
  for i := 0; i < n; i++ {
    nodes[i] = Node{ -1, []*Node{} }
  }
  for i := 0; i < n; i++ {
    p := int(getI())
    if p != -1 {
      parent := &nodes[p-1]
      parent.Children = append(parent.Children, &nodes[i])
    }
  }
  maxHeight := 0
  for i := 0; i < n; i++ {
    height := setHeight(&nodes[i])
    if height > maxHeight {
      maxHeight = height
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", maxHeight))
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	n := nextInt(s)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		x := nextInt(s)
		if x == -1 {
			xs[i] = i
		} else {
			xs[i] = x - 1
		}
	}

	max := 0
	for i := 0; i < n; i++ {
		d := depth(xs, i)
		if d > max {
			max = d
		}
	}
	fmt.Println(max)
}

func depth(xs []int, x int) int {
	if xs[x] == x {
		return 1
	}
	d := 1
	p := xs[x]
	for p != xs[p] {
		p = xs[p]
		d++
	}
	d++
	return d
}

func maximum(xs ...int) int {
	max := 0
	for i := 0; i < len(xs); i++ {
		if xs[i] > max {
			max = xs[i]
		}
	}
	return max
}

func copyAppend(ys []int, xs ...int) []int {
	ns := make([]int, len(ys), len(ys)+len(xs))
	copy(ns, ys)
	return append(ns, xs...)
}

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

func toLower(x byte) byte {
	return x + ('a' - 'A')
}

func isUpper(x byte) bool {
	return x >= 'A' && x <= 'Z'
}

func initArray(n, x int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = x
	}
	return xs
}

func nextInt(s *bufio.Scanner) (n int) {
	s.Scan()
	n, _ = strconv.Atoi(s.Text())
	return
}

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

var in, d []int

func solve(n int) {
	var ans int
	in = make([]int, n+1)
	d = make([]int, n+1)
	for i := 1; i <= n; i++ {
		I(&in[i])
	}
	for i := 1; i <= n; i++ {
		ans = max(ans, depth(i))
	}
	O(ans, "\n")
}

func depth(i int) int {
	if in[i] == -1 {
		return 1
	}
	if d[i] > 0 {
		return d[i]
	}
	d[i] = 1 + depth(in[i])
	return d[i]
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

var in []int

func solve(n int) {
	var ans int
	in = make([]int, n+1)
	for i := 1; i <= n; i++ {
		I(&in[i])
	}
	for i := 1; i <= n; i++ {
		j := i
		d := 1
		for in[j] != -1 {
			d++
			j = in[j]
		}
		ans = max(ans, d)
	}
	O(ans, "\n")
}

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

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

func main() {
	var n,d,c,j int
	a:=make([]int,2011)
	fmt.Scan(&n)
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	for i:=1;i<=n;i++ {
		input.Scan()
		aa,_:= strconv.Atoi(input.Text())
		a[i]=aa
	}
	d=0
	for i:=1;i<=n;i++ {
		c=1
		j=i
		for ;a[j]!=-1; {
			j=a[j]
			c++
		}
		if c>d {
			d=c
		}
	}
	fmt.Println(d)
}

package main

import (
	"fmt"
)

var (
	graph [2001][]int
	cnt   int = 0
)

func dfs(node int, level int) {
	if len(graph[node]) == 0 {
		if level > cnt {
			cnt = level
		}
		return
	}

	level++
	for i := 0; i < len(graph[node]); i++ {
		dfs(graph[node][i], level)
	}
}

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

	for i := 1; i <= n; i++ {
		var p int
		fmt.Scan(&p)
		if p > 0 {
			graph[p] = append(graph[p], i)
		}
	}

	for i := 1; i <= n; i++ {
		dfs(i, 0)
	}

	fmt.Println(cnt + 1)
}

// leghosszabb ut csucsainak szama
// ezek mind kulon csoportban kell hogy legyenek
// ennyi szukseges, az hogy eleg lathato ha elkepzeljuk a
// graf szintekre-bontasat (bfs)

package main

import (
	"fmt"
)

var (
	dist [2048]int32
	par  [2048]int32
)

func Trav(node int32) {
	p := par[node]
	if dist[p] < 0 {
		Trav(p)
	}
	dist[node] = 1 + dist[p]
}

func main() {

	var (
		n, i, max int32
	)

	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Scan(&par[i])
		if par[i] < 0 {
			dist[i] = 0
		} else {
			dist[i] = -1
		}
	}

	for i = 1; i <= n; i++ {
		if dist[i] < 0 {
			Trav(i)
		}
	}

	max = 0
	for i = 1; i <= n; i++ {
		if dist[i] > max {
			max = dist[i]
		}
	}

	fmt.Println(1 + max)
}

package main

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

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

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

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

	var max_height int = 0
	for i := 1; i <= array[0][0]; i++ {
		root := array[0][i]
		height := 1 + calculate_height(root, array)
		if height > max_height {
			max_height = height
		}
	}

	fmt.Println(max_height)
}

func calculate_height(root int, array [][]int) int {
	if array[root][0] > 0 {
		var max_height int = 0
		for i := 1; i <= array[root][0]; i++ {
			height := calculate_height(array[root][i], array)
			if height > max_height {
				max_height = height
			}
		}
		return max_height + 1
	} else {
		return 0
	}
}

package main

import "fmt"

func dfs(a int, p []int, f []bool) int {
    f[a] = true
    if p[a] != -1 { return (1 + dfs(p[a],p,f)) }
    return 1
}

func main() {
    var n int
    fmt.Scan(&n)
    p, f := make([]int,n+1), make([]bool,n+1)
    for i := 1; i <= n; i++ {
        fmt.Scan(&p[i])
    }

    ans := 0
    for i := 1; i <= n; i++ {
        if !f[i] {
            cnt := dfs(i,p,f)
            if ans < cnt { ans = cnt }
        }
    }

    fmt.Println(ans)
}

// 115A-mic
package main

import (
    "fmt"
)

func main() {
    var n, max, c int               // variabel n,max,c dengan jenis int
    var a [2014]int                 // variabel a [2014] dengan jenis int
    fmt.Scan(&n)                    // mengambil input

    for i := 1; i <= n; i++ {       // looping
        fmt.Scan(&a[i])             // mengambil input kedua
    }
    for i := 1; i <= n; i++ {       // looping kedua
        c = 0                       // c sama dengan 0
        for j := i; j != -1; j = a[j] { // looping ketiga
            c++                     // c ditambah terus
        }
        if c > max {                // jika c lebih dari max
            max = c                 // max sama dengan c
        }
    }
    fmt.Println(max)            // cetak max
}

package main

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

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

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

func main () {
    defer writer.Flush()

    var pa [2012] int
    var n int

    scanf("%d\n", &n)
    for i := 1; i <= n; i++ {
        scanf("%d\n", &pa[i])
    }

    var ans = 0
    for i := 1; i <= n; i++ {
        var cur = 0
        var x = i
        for x != -1 {
            cur++
            x = pa[x]
        }
        if cur > ans {
            ans = cur
        }
    }
    printf("%d\n", ans)
    writer.Flush()
}

package main

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

type Pair struct {
	i     int
	level int
}

type Queue struct {
	d     []Pair
	front int
	rear  int
	size  int
}

func (q *Queue) isFull() bool {
	return q.rear+1 == q.size
}

func (q *Queue) isEmpty() bool {
	return q.front == q.rear
}

func (q *Queue) enqueue(p Pair) {
	if q.isFull() {
		return
	}
	q.rear += 1
	q.d[q.rear] = p
}

func (q *Queue) dequeue() Pair {
	if q.isEmpty() {
		return Pair{i: -1, level: -1}
	}
	q.front += 1
	data := q.d[q.front]
	return data
}

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

func depth(i int, children [][]int, lengths []int, n int) int {
	var max_level int
	p := Pair{i: i, level: 1}
	q := &Queue{d: make([]Pair, n), front: -1, rear: -1, size: n}
	q.enqueue(p)
	for !q.isEmpty() {
		node := q.dequeue()
		max_level = max(max_level, node.level)
		for _, c := range children[node.i][:lengths[node.i]] {
			q.enqueue(Pair{i: c, level: node.level + 1})
		}
	}
	return max_level
}

func min_teams(n int, managers []int) int {
	children := make([][]int, n)
	lengths := make([]int, n)
	for i := 0; i < n; i++ {
		children[i] = make([]int, n)
	}
	for i, m := range managers {
		if m == -1 {
			continue
		}
		children[m-1][lengths[m-1]] = i
		lengths[m-1] += 1
	}
	// Iterate all orphans
	// Do BFS on them
	// find depth
	// return max depth among all
	var max_depth int
	for i, manager := range managers {
		if manager != -1 {
			continue
		}
		max_depth = max(max_depth, depth(i, children, lengths, n))
	}
	return max_depth
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanf(reader, "%d", &n)
	managers := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "\n%d", &managers[i])
	}
	fmt.Fprintln(writer, min_teams(n, managers))
}

package main

import (
	"fmt"
)

func main() {
	var n, p int
	fmt.Scan(&n)
	var parent map[int]int = make(map[int]int)
	var levels map[int]int = make(map[int]int)
	for i := 1; i <= n; i++ {
		fmt.Scan(&p)
		parent[i] = p
	}
	for i, v := range parent {
		if v == -1 {
			levels[0]++
		} else {
			j := i
			level := 0
			for parent[j] != -1 {
				j = parent[j]
				level++
			}
			levels[level]++
		}
	}
	fmt.Println(len(levels))
}

// 5
// 1 - 5
// 2 - -1
// 3 - 5
// 4 - 2
// 5 - 2
//                      2
//                  5       4
//               1    3

package main

import (
	"fmt"
)

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

	pn := make([]int, n+1, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&pn[i])
	}

	ans := 0
	for i := 0; i < n; i++ {
		depth := 1
		cur := pn[i]
		for cur != -1 {
			cur = pn[cur-1]
			depth++
		}

		if ans < depth {
			ans = depth
		}
	}

	fmt.Println(ans)
}

// 115A-mic
package main

import (
	"fmt"
)

func main() {
	//w := bufio.NewScanner(os.Stdin)
	//w.Split(bufio.ScanWords)

	var n, max, c int
	var a [2014]int
	fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		//b, _ := strconv.Atoi(w.Text())
		//a[i] = b
		fmt.Scan(&a[i])
	}
	for i := 1; i <= n; i++ {
		c = 0
		for j := i; j != -1; j = a[j] {
			c++
		}
		if c > max {
			max = c
		}
	}
	fmt.Println(max)
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

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
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

var mx int

func dfs(g [][]int, c []int, v, d int) {
	mx = max(mx, d + 1)
	c[v] = 1
	for i := 0; i < len(g[v]); i++ {
		to := g[v][i]
		if c[to] == 0 {
			dfs(g, c, to, d + 1)
		}
	}
}

func solution(reader io.Reader, writer io.Writer) {
	var n int
	fmt.Fscanf(reader, "%d\n", &n)

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

	c:= make([]int, n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Fscanf(reader, "%d\n", &a)
		if a > 0 {
			a--
			g[a] = append(g[a], i)
		} else {
			c[i] = -1
		}
	}

	for i := 0; i < n; i++ {
		if c[i] == -1 {
			dfs(g, c, i, 0)
		}
	}

	fmt.Fprintf(writer, "%d\n", mx)
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

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

type Graph struct {
	Visited map[int]bool
	Dist    map[int]int
	Edges   map[int][]int
	Max     int
}

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

	var n, parent int
	fmt.Fscanf(reader, "%d\n", &n)
	g := Graph{Visited: make(map[int]bool), Dist: make(map[int]int), Edges: make(map[int][]int), Max: math.MinInt32}
	for i := 1; i <= n; i++ {
		fmt.Fscanf(reader, "%d\n", &parent)
		if _, ok := g.Edges[parent]; !ok {
			g.Edges[parent] = make([]int, 0)
		}
		g.Edges[parent] = append(g.Edges[parent], i)
	}
	q := make([]int, 0)
	q = append(q, -1)
	g.Dist[-1] = 0
	g.Visited[-1] = true
	for len(q) != 0 {
		u := q[0]
		q = q[1:]
		for _, v := range g.Edges[u] {
			g.Visited[v] = true
			g.Dist[v] = g.Dist[u] + 1
			q = append(q, v)
			if g.Max < g.Dist[v] {
				g.Max = g.Dist[v]
			}
		}
	}
	fmt.Fprintf(writer, "%d\n", g.Max)
}

// 115A-mic
package main

import (
    "fmt"
)

func main() {
    //w := bufio.NewScanner(os.Stdin)
    //w.Split(bufio.ScanWords)

    var n, max, c int
    var a [2014]int
    fmt.Scan(&n)

    for i := 1; i <= n; i++ {
        //b, _ := strconv.Atoi(w.Text())
        //a[i] = b
        fmt.Scan(&a[i])
    }
    for i := 1; i <= n; i++ {
        for j := i; j != -1; j = a[j] {
            c++
            if c > max {
                max = c
                c = 0
            }
        }
    }
    fmt.Println(max)
}

// 115A-mic
package main

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

func main() {
	//w := bufio.NewScanner(os.Stdin)
	//w.Split(bufio.ScanWords)

	var n, max, c int
	var a [2014]int
	fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		//b, _ := strconv.Atoi(w.Text())
		//a[i] = b
		fmt.Scan(&a[i])
	}
	for i := 1; i <= n; i++ {
		for j := i; j != -1; j = a[j] {
			c++
		}
		if c > max {
			max = c
			c = 0
		}
	}
	fmt.Println(max)
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

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
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

var mx int

func dfs(g [][]int, u []bool, v, d int) {
	mx = max(mx, d + 1)
	u[v] = true
	for i := 0; i < len(g[v]); i++ {
		to := g[v][i]
		if !u[to] {
			dfs(g, u, to, d + 1)
		}
	}
}

func solution(reader io.Reader, writer io.Writer) {
	var n int
	fmt.Fscanf(reader, "%d\n", &n)

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

	for i := 0; i < n; i++ {
		var a int
		fmt.Fscanf(reader, "%d\n", &a)
		if a > 0 {
			a--
			g[a] = append(g[a], i)
			g[i] = append(g[i], a)
		}
	}

	u := make([]bool, n)

	for i := 0; i < n; i++ {
		if !u[i] {
			dfs(g, u, i, 0)
		}
	}

	fmt.Fprintf(writer, "%d\n", mx)

}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

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
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

var mx int

func dfs(g [][]int, c []int, v, d int) {
	fmt.Println(d)
	mx = max(mx, d + 1)
	c[v] = 1
	for i := 0; i < len(g[v]); i++ {
		to := g[v][i]
		if c[to] == 0 {
			dfs(g, c, to, d + 1)
		}
	}
}

func solution(reader io.Reader, writer io.Writer) {
	var n int
	fmt.Fscanf(reader, "%d\n", &n)

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

	c:= make([]int, n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Fscanf(reader, "%d\n", &a)
		if a > 0 {
			a--
			g[a] = append(g[a], i)
		} else {
			c[i] = -1
		}
	}

	fmt.Println(g)

	for i := 0; i < n; i++ {
		if c[i] == -1 {
			dfs(g, c, i, 0)
		}
	}

	fmt.Fprintf(writer, "%d\n", mx)
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

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
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func dfs(g [][]int, c []int, v, d int) {
	c[v] = d
	for i := 0; i < len(g[v]); i++ {
		to := g[v][i]
		if c[to] == 0 {
			dfs(g, c, to, d)
		}
	}
}

func solution(reader io.Reader, writer io.Writer) {
	var n int
	fmt.Fscanf(reader, "%d\n", &n)

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

	c := make([]int, n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Fscanf(reader, "%d\n", &a)
		if a > 0 {
			a--
			g[a] = append(g[a], i)
			g[i] = append(g[i], a)
		} else {
			c[i] = -1
		}
	}

	for i := 0; i < n; i++ {
		if c[i] == 0 {
			dfs(g, c, i, i + 1)
		}
	}

	h := make(map[int]bool)
	for i := 0; i < n; i++ {
		h[c[i]] = true
	}
	fmt.Println(len(h))
	//fmt.Fprintf(writer, "%d\n", dm)

}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}


You are given $$$n$$$ arrays that can have different sizes. You also have a table with $$$w$$$ columns and $$$n$$$ rows. The $$$i$$$-th array is placed horizontally in the $$$i$$$-th row. You can slide each array within its row as long as it occupies several consecutive cells and lies completely inside the table.You need to find the maximum sum of the integers in the $$$j$$$-th column for each $$$j$$$ from $$$1$$$ to $$$w$$$ independently.  Optimal placements for columns $$$1$$$, $$$2$$$ and $$$3$$$ are shown on the pictures from left to right. Note that you can exclude any array out of a column provided it remains in the window. In this case its value is considered to be zero.

The first line contains two integers $$$n$$$ ($$$1 \le n \le 10^{6}$$$) and $$$w$$$ ($$$1 \le w \le 10^{6}$$$) — the number of arrays and the width of the table. Each of the next $$$n$$$ lines consists of an integer $$$l_{i}$$$ ($$$1 \le l_{i} \le w$$$), the length of the $$$i$$$-th array, followed by $$$l_{i}$$$ integers $$$a_{i1}, a_{i2}, \ldots, a_{il_i}$$$ ($$$-10^{9} \le a_{ij} \le 10^{9}$$$) — the elements of the array. The total length of the arrays does no exceed $$$10^{6}$$$.

Print $$$w$$$ integers, the $$$i$$$-th of them should be the maximum sum for column $$$i$$$.

NoteIllustration for the first example is in the statement.

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

func segTreeAdd(segTree []int64, index, l, r, left, right int, plus int64) {
	mid := (l + r) / 2
	if l == left && r == right {
		segTree[index] += plus
		return
	} else if mid < left {
		segTreeAdd(segTree, index * 2 + 2, mid + 1, r, left, right, plus)
	} else if mid >= right {
		segTreeAdd(segTree, index * 2 + 1, l, mid, left, right, plus)
	} else {
		segTreeAdd(segTree, index * 2 + 1, l, mid, left, mid, plus)
		segTreeAdd(segTree, index * 2 + 2, mid + 1, r, mid + 1, right, plus)
	}
}

func segTreeRead(segTree []int64, index, l, r, pos int) int64 {
	mid := (l + r) / 2
	if l == r && l == pos {
		return segTree[index]
	} else if pos <= mid {
		return segTree[index] + segTreeRead(segTree, index * 2 + 1, l, mid, pos)
	} else {
		return segTree[index] + segTreeRead(segTree, index * 2 + 2, mid + 1, r, pos)
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	writer := bytes.NewBuffer(make([]byte, 0, 10000000))

	var n, w int
	segTree := make([]int64, 3000000)

	fmt.Fscanf(reader, "%d %d\n", &n, &w)
	for i := 0;i < n;i ++ {
		var l int
		fmt.Fscanf(reader, "%d", &l)
		a := make([]int64, l)
		for j := 0;j < l;j ++ {
			fmt.Fscanf(reader, " %d", &a[j])
		}
		q, head, tail := make([]int, l), 0, 1
		q[0] = 0
		left := 0
		for j := 1;j < l;j ++ {
			if a[j] >= a[q[tail - 1]] {
				if head + 1 == tail {
					if left <= j - 1 {
						if a[q[head]] >= 0 {
							segTreeAdd(segTree, 0, 0, w - 1, left, j - 1, a[q[head]])
						} else if 2 * l > w {
							low, high := left, j - 1
							if w - l > low {
								low = w - l
							}
							if l - 1 < high {
								high = l - 1
							}
							if low <= high {
								segTreeAdd(segTree, 0, 0, w - 1, low, high, a[q[head]])
							}
						}
					}
					q[head] = j
					left = j
				} else {
					j --
					tail --
					continue
				}
			} else {
				q[tail] = j
				tail ++
				if w - l + q[head] < j {
					if left <= j - 1 {
						if a[q[head]] >= 0 {
							segTreeAdd(segTree, 0, 0, w - 1, left, j - 1, a[q[head]])
						} else if 2 * l > w {
							low, high := left, j - 1
							if w - l > low {
								low = w - l
							}
							if l - 1 < high {
								high = l - 1
							}
							if low <= high {
								segTreeAdd(segTree, 0, 0, w - 1, low, high, a[q[head]])
							}
						}
					}
					left = j
					head ++
				}
			}
		}
		for ;head != tail; head ++ {
			right := w - l + q[head]
			if left <= right {
				if a[q[head]] >= 0 {
					segTreeAdd(segTree, 0, 0, w - 1, left, right, a[q[head]])
				} else if 2 * l > w {
					low, high := left, right
					if w - l > low {
						low = w - l
					}
					if l - 1 < high {
						high = l - 1
					}
					if low <= high {
						segTreeAdd(segTree, 0, 0, w - 1, low, high, a[q[head]])
					}
				}
			}
			left = right + 1
		}
		fmt.Fscanf(reader, "\n")
	}
	for i := 0;i < w;i ++ {
		fmt.Fprintf(writer, "%d ", segTreeRead(segTree, 0, 0, w - 1, i))
	}
	writer.WriteTo(os.Stdout)

}


The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are n gems in the Shuseki Islands in total, and the i-th gem is located on island pi.Mr. Kitayuta has just arrived at island 0. With his great jumping ability, he will repeatedly perform jumps between islands to the east according to the following process:   First, he will jump from island 0 to island d.  After that, he will continue jumping according to the following rule. Let l be the length of the previous jump, that is, if his previous jump was from island prev to island cur, let l = cur - prev. He will perform a jump of length l - 1, l or l + 1 to the east. That is, he will jump to island (cur + l - 1), (cur + l) or (cur + l + 1) (if they exist). The length of a jump must be positive, that is, he cannot perform a jump of length 0 when l = 1. If there is no valid destination, he will stop jumping. Mr. Kitayuta will collect the gems on the islands visited during the process. Find the maximum number of gems that he can collect.

The first line of the input contains two space-separated integers n and d (1 ≤ n, d ≤ 30000), denoting the number of the gems in the Shuseki Islands and the length of the Mr. Kitayuta's first jump, respectively. The next n lines describe the location of the gems. The i-th of them (1 ≤ i ≤ n) contains a integer pi (d ≤ p1 ≤ p2 ≤ ... ≤ pn ≤ 30000), denoting the number of the island that contains the i-th gem.

Print the maximum number of gems that Mr. Kitayuta can collect.

NoteIn the first sample, the optimal route is 0  →  10 (+1 gem)  →  19  →  27 (+2 gems)  → ...In the second sample, the optimal route is 0  →  8  →  15  →  21 →  28 (+1 gem)  →  36 (+1 gem)  →  45 (+1 gem)  →  55 (+1 gem)  →  66 (+1 gem)  →  78 (+1 gem)  → ...In the third sample, the optimal route is 0  →  7  →  13  →  18 (+1 gem)  →  24 (+2 gems)  →  30 (+1 gem)  → ...

package main

import (
	"fmt"
)

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

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	var p [30010]int
	for i := 0; i < n; i++ {
		var g int
		fmt.Scan(&g)
		p[g]++
	}
	var dp [30010][510]int
	dp[d][250] = p[d]
	if p[d] == 0 {
		dp[d][250] = 1
	}
	for i := d; i < 30010; i++ {
		for j := 1; j < 500; j++ {
			if dp[i][j] == 0 {
				continue
			}
			for dl := -1; dl <= 1; dl++ {
				l := j - 250 + d + dl
				if i+l > 30000 || l <= 0 {
					continue
				}
				dp[i+l][j+dl] = max(dp[i+l][j+dl], dp[i][j]+p[i+l])
			}
		}
	}
	ans := 0
	for i := d; i < 30001; i++ {
		for j := 0; j < 510; j++ {
			ans = max(ans, dp[i][j])
		}
	}
	if p[d] == 0 {
		ans--
	}
	fmt.Println(ans)
}

package main

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

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

const MAXN = 30000
const SPREAD = 300

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, d := NextInt(), NextInt()
	var score = make([]int, MAXN + 1)
	for i := 0; i < n; i++ {
		score[NextInt()] += 1
	}

	var dp = make([][]int, MAXN + 1)
	for i := 0; i <= MAXN; i++ {
		dp[i] = make([]int, 2 * SPREAD)
		for j := 0; j < 2 * SPREAD; j++ {
			dp[i][j] = -1
		}
	}
	dp[d][SPREAD] = score[d]
	for i := 0; i <= MAXN; i++ {
		for j := 0; j < 2 * SPREAD; j++ {
			if dp[i][j] != -1 {
				for k := -1; k <= 1; k++ {
					dx := j - SPREAD + k
					if Abs(dx) >= SPREAD || d - dx <= 0{
						continue
					}
					nexti := i + d - dx
					if nexti > MAXN {
						continue
					}
					dp[nexti][dx + SPREAD] = Max(dp[nexti][dx + SPREAD], dp[i][j] + score[nexti])
				}
			}
		}
	}
	var ret int = 0
	for i := 0; i <= MAXN; i++ {
		for j := 0; j < 2 * SPREAD; j++ {
			ret = Max(ret, dp[i][j])
		}
	}
	fmt.Fprintln(out, ret)
}

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

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

func Next() string{
	if !in.Scan() {
		panic("Scan error")
	}
	return in.Text()
}

func NextInt() int{
	ret, _ := strconv.Atoi(Next())
	return ret
}

package main

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

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

const MAXN = 30000
const SPREAD = 300

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, d := NextInt(), NextInt()
	var score = make([]int, MAXN+1)
	for i := 0; i < n; i++ {
		score[NextInt()] += 1
	}

	var dp = make([][]int, MAXN+1)
	for i := 0; i <= MAXN; i++ {
		dp[i] = make([]int, 2*SPREAD)
		for j := 0; j < 2*SPREAD; j++ {
			dp[i][j] = -1
		}
	}
	dp[d][SPREAD] = score[d]
	for i := 0; i <= MAXN; i++ {
		for j := 0; j < 2*SPREAD; j++ {
			if dp[i][j] != -1 {
				for k := -1; k <= 1; k++ {
					dx := j - SPREAD + k
					if Abs(dx) >= SPREAD || d-dx <= 0 {
						continue
					}
					nexti := i + d - dx
					if nexti > MAXN {
						continue
					}
					dp[nexti][dx+SPREAD] = Max(dp[nexti][dx+SPREAD], dp[i][j]+score[nexti])
				}
			}
		}
	}
	var ret int = 0
	for i := 0; i <= MAXN; i++ {
		for j := 0; j < 2*SPREAD; j++ {
			ret = Max(ret, dp[i][j])
		}
	}
	fmt.Fprintln(out, ret)
}

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

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

func Next() string {
	if !in.Scan() {
		panic("Scan error")
	}
	return in.Text()
}

func NextInt() int {
	ret, _ := strconv.Atoi(Next())
	return ret
}

package main

import (
	"fmt"
)

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

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	var p [30010]int
	for i := 0; i < n; i++ {
		var g int
		fmt.Scan(&g)
		p[g]++
	}
	var dp [30010][510]int
	dp[d][250] = 1
	for i := 1; i < 30010; i++ {
		for j := 1; j < 500; j++ {
			if dp[i][j] == 0 {
				continue
			}
			for dl := -1; dl <= 1; dl++ {
				l := j - 250 + d + dl
				if i+l > 30000 {
					continue
				}
				dp[i+l][j+dl] = max(dp[i+l][j+dl], dp[i][j]+p[i+l])
			}
		}
	}
	ans := 0
	for i := 0; i < 30001; i++ {
		for j := 0; j < 510; j++ {
			ans = max(ans, dp[i][j])
		}
	}
	fmt.Println(ans - 1 + p[d])
}


You are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to n - 1.Graph is given as the array f0, f1, ..., fn - 1, where fi — the number of vertex to which goes the only arc from the vertex i. Besides you are given array with weights of the arcs w0, w1, ..., wn - 1, where wi — the arc weight from i to fi.    The graph from the first sample test. Also you are given the integer k (the length of the path) and you need to find for each vertex two numbers si and mi, where:  si — the sum of the weights of all arcs of the path with length equals to k which starts from the vertex i;  mi — the minimal weight from all arcs on the path with length k which starts from the vertex i. The length of the path is the number of arcs on this path.

The first line contains two integers n, k (1 ≤ n ≤ 105, 1 ≤ k ≤ 1010). The second line contains the sequence f0, f1, ..., fn - 1 (0 ≤ fi < n) and the third — the sequence w0, w1, ..., wn - 1 (0 ≤ wi ≤ 108).

Print n lines, the pair of integers si, mi in each line.

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

var n, l int
var k, p int64
var f []int
var w []int
var g, m [][]int
var s [][]int64

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

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

	fmt.Fscan(bufin, &n, &k)

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

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

	l := 1
	for p = 1; p*2 <= k; p *= 2 {
		l++
	}

	g = make([][]int, n)
	s = make([][]int64, n)
	m = make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, l)
		s[i] = make([]int64, l)
		m[i] = make([]int, l)

		g[i][0] = f[i]
		s[i][0] = int64(w[i])
		m[i][0] = w[i]
	}

	for j := 1; j < l; j++ {
		for i := 0; i < n; i++ {
			g[i][j] = g[g[i][j-1]][j-1]
			s[i][j] = s[i][j-1] + s[g[i][j-1]][j-1]
			m[i][j] = min(m[i][j-1], m[g[i][j-1]][j-1])
		}
	}

	for pos := 0; pos < n; pos++ {
		i := pos
		rs := int64(0)
		rm := 1000000000

		for j := 0; j < l; j++ {
			bit := (k >> uint(j)) & 1
			if bit == 1 {
				rs += s[i][j]
				rm = min(rm, m[i][j])
				i = g[i][j]
			}
		}

		fmt.Fprintln(bufout, rs, rm)
	}
}


Let $$$f(i)$$$ denote the minimum positive integer $$$x$$$ such that $$$x$$$ is not a divisor of $$$i$$$.Compute $$$\sum_{i=1}^n f(i)$$$ modulo $$$10^9+7$$$. In other words, compute $$$f(1)+f(2)+\dots+f(n)$$$ modulo $$$10^9+7$$$.

The first line contains a single integer $$$t$$$ ($$$1\leq t\leq 10^4$$$), the number of test cases. Then $$$t$$$ cases follow. The only line of each test case contains a single integer $$$n$$$ ($$$1\leq n\leq 10^{16}$$$).

For each test case, output a single integer $$$ans$$$, where $$$ans=\sum_{i=1}^n f(i)$$$ modulo $$$10^9+7$$$.

NoteIn the fourth test case $$$n=4$$$, so $$$ans=f(1)+f(2)+f(3)+f(4)$$$.  $$$1$$$ is a divisor of $$$1$$$ but $$$2$$$ isn't, so $$$2$$$ is the minimum positive integer that isn't a divisor of $$$1$$$. Thus, $$$f(1)=2$$$.  $$$1$$$ and $$$2$$$ are divisors of $$$2$$$ but $$$3$$$ isn't, so $$$3$$$ is the minimum positive integer that isn't a divisor of $$$2$$$. Thus, $$$f(2)=3$$$.  $$$1$$$ is a divisor of $$$3$$$ but $$$2$$$ isn't, so $$$2$$$ is the minimum positive integer that isn't a divisor of $$$3$$$. Thus, $$$f(3)=2$$$.  $$$1$$$ and $$$2$$$ are divisors of $$$4$$$ but $$$3$$$ isn't, so $$$3$$$ is the minimum positive integer that isn't a divisor of $$$4$$$. Thus, $$$f(4)=3$$$. Therefore, $$$ans=f(1)+f(2)+f(3)+f(4)=2+3+2+3=10$$$.

package main

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

const N = int(1e5 + 10)

func main() {
	// io := NewFastIO(os.Stdin, os.Stdout)
	// defer io.Flush()
	t := 1
	fmt.Scan(&t)
	// t = io.NextInt()

	val := make([]int64, 0)
	lc := int64(1)
	i := int64(1)
	for {
		lc = lcm(lc, i)
		val = append(val, lc)
		if lc >= int64(1e16) {
			break
		}
		i++
	}

	// io.Println(val)

	for tt := 0; tt < t; tt++ {
		solve := func() {
			var n, rem, ans int64
			fmt.Scan(&n)
			l := len(val)
			for i := l - 1; i >= 0; i-- {
				ans += (n/val[i] - rem) * int64(i+2)
				rem = n / val[i]
				ans %= int64(1e9 + 7)
			}
			fmt.Println(ans)
		}
		solve()
	}
}

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

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

func lcm(a, b int64) int64 {
	return (a / gcd(a, b)) * b
}

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

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"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1542C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod int64 = 1e9 + 7

	var T, n int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans := n
		for i, lcm := int64(2), int64(1); lcm <= n; i++ {
			ans += n / lcm
			lcm = lcm * i / gcd(lcm, i)
		}
		Fprintln(out, ans%mod)
	}
}

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

func gcd(a, b int64) int64 {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod int64 = 1e9 + 7

	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	lcm := func(a, b int64) int64 { return a / gcd(a, b) * b }

	a := []int64{0}
	v := int64(1)
	for i := int64(1); ; i++ {
		v = lcm(v, i)
		if v > 1e18 {
			break
		}
		a = append(a, v)
	}
	//Println(a)

	f := func(st, d, n int64) int64 {
		if n < st {
			return 0
		}
		return (n-st)/d + 1
	}

	solve := func(Case int) {
		var n, ans int64
		Fscan(in, &n)
		//Println(n)
		for mex := 2; mex < len(a); mex++ {
			d := a[mex]
			if a[mex] == a[mex-1] {
				continue
			}
			for st := a[mex-1]; st < d; st += a[mex-1] {
				res := f(st, d, n)
				//if res > 0 {
				//	Println(st,d,res,mex)
				//}
				res = res%mod * int64(mex) % mod
				ans = (ans + res) % mod
			}
		}
		//Println()
		Fprintln(out, ans)
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

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

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

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

const M = 1000000007

func gcd(a, b int64) int64 {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

func lcm(a, b int64) int64 {
	return a / gcd(a, b) * b
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		s, d := n, int64(1)
		for i := int64(1); d <= n; i++ {
			d = lcm(d, i)
			s = (s + n/d) % M
		}
		Fprintln(out, s)
	}
}

package main

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

var in *bufio.Reader

const kMod int64 = 1000000007

func calGCD(a, b int64) int64 {
	if b == 0 {
		return a
	} else {
		return calGCD(b, a%b)
	}
}

func calLCM(a, b int64) int64 {
	gcd := calGCD(a, b)
	return (a / gcd) * b
}

func solve() {
	var n int64
	fmt.Fscan(in, &n)

	var result int64 = 0
	var lcm int64 = 1
	remain := n
	for i := int64(2); remain > 0; i++ {
		lcm = calLCM(lcm, i)
		next := n / lcm
		result += (((remain - next) % kMod) * i) % kMod
		result %= kMod
		remain = next
	}
	fmt.Println(result)
}

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

	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

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

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

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

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

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

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

type ll = int64

const mod = 1e9 + 7

func LCM(a, b ll) ll {
	return a / GCD(a, b) * b
}

func GCD(a, b ll) ll {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

func solve() {
	var (
		n, ans, took ll
		prev         ll = 1
	)
	scan(&n)
	for i := ll(2); took < n; i++ {
		prev = LCM(prev, i-1)
		cnt := n/prev - n/LCM(prev, i)
		took += cnt
		ans += (cnt * i) % mod
		ans %= mod
	}
	printf("%v\n", ans)
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		var n uint64
		s, _ := reader.ReadBytes('\n')
		readUint64(s, 0, &n)
		res := solve(int64(n))
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

const MOD = 1000000007

func solve(n int64) int {
	// f(1) = 2
	// f(2) = 3
	// f(odd) = 2
	var g int64 = 1
	var ans int64

	for i := 1; g <= n; i++ {
		g = lcm(g, int64(i))
		if g > n {
			break
		}
		ans += n / g
		ans %= MOD
	}

	return int((ans + int64(n)) % MOD)
}

func lcm(x, y int64) int64 {
	return x / gcd(x, y) * y
}

func gcd(a, b int64) int64 {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func gcd(x, y ll) ll {
	if y!=0{
		return gcd(y,x%y)
	}else{
		return x
	}
}
func LCM(x, y ll)ll{
	return x*y/gcd(x,y)
}
type ll int64
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++ {
		var n ll
		fmt.Fscan(in,&n)
		var i ll
		var G ll
		G = 1
		var ans ll
		ans = 0
		for i=1;G<=n;i++{
			G = LCM(G,i)
			if G>n{
				break
			}
			ans+=n/G
		}
		fmt.Fprintln(out,(ans+n)%1000000007)
	}
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

//2*3*5*7*11*13*17*19*23*29*31*37*41*43 > 10000000000000000
//2*3*5*7*11*13*17*19*23*29*31*37*41 < 10000000000000000

// first fully saturated relation:
// 32*27*25*7*11*13*17*19*23*29*31*37 < 10000000000000000
// meaning that 41 can occur as f(i) once

// we can observe that the non 2,3 ones can only be powers of primes (less than 41)
// 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23 ,25, 27, 29, 31, 32, 37, 41
//

// Though this doesn't solve the problem
// Per the tutorials' hint on using lcm, we're counting up to f(i)=41

func LCM(out *big.Int,a *big.Int,b *big.Int) {
	temp := big.NewInt(0)
	temp.GCD(nil,nil, a ,b)
	out.Mul(a,b)
	out.Div(out,temp)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {
		pn,_ := Readln(reader)
		n,_ := strconv.ParseInt(pn,10,64)
		res:=int64(0)
		curlcm := big.NewInt(1)
		// we add in all candidates that supposed to be not divisible by all items below i with n/lcm(i...i-1)
		// and we subtract off n/lcm(1..i) to filter out the items with smallest non divisible at exactly i
		// we can check as (python) [math.lcm(*x) for x in [[i for i in range(1,j)]for j in range(1,41)]]
		// we should only have f(i) values when the consecutive values differ
		// which counts f(i) = 2, f(i) = 3... 4,5,7,8,9,11, etc..
		for i:= int64(1); i<=41 ; i++ {
			res+= i*(n/curlcm.Int64())
			LCM(curlcm, curlcm, big.NewInt(i))
			res-= i*(n/curlcm.Int64())
			res = res % 1000000007
		}
		fmt.Println(res)

	}

}

package main

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

const MOD int64 = 1e9 + 7

const LOCAL = false

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

	var t int
	fmt.Fscan(r, &t)

	if LOCAL {
		rand.Seed(time.Now().UnixNano())

		for i := 0; i < t; i++ {
			n := rand.Intn( 10000000) + 1

			a1 := solve(int64(n))
			a2 := solve_stupid(int64(n))

			if a1 != a2 {
				fmt.Println("ERROR")
				fmt.Println(a1)
				fmt.Println(a2)
				fmt.Println(n)
				break
			}
		}

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

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

func solve_stupid(n int64) int64 {

	if n == 1 {
		return 2
	}

	var ans int64

	var i int64

	for i = 2; i <= n; i ++ {

		var j int64
		for j = 1; j <= i + 1; j ++ {
			if i % j != 0 {
				ans += j
				ans = ans % MOD
				break
			}
		}
	}

	return (ans + 2) % MOD
}

//5342931457063200
//10000000000000000

func solve(n int64) int64 {
	var ans int64

	var k int64

	k = 2 * 3 * 2 * 5 * 7 * 2 * 3 * 11 * 13 * 2 * 17 * 19 * 23 * 5 * 3 * 29 * 31 * 2 * 37

	var count int64

	//41
	if n >= k {
		d := n/k

		ans += d * 41
		ans = ans % MOD
		count = d
	}

	//37
	k /= 37

	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 37
		ans = ans % MOD
	}

	//32
	k /= 2

	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 32
		ans = ans % MOD
	}

	//31
	k /= 31
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 31
		ans = ans % MOD
	}

	//29
	k /= 29
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 29
		ans = ans % MOD
	}

	//27
	k /= 3
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 27
		ans = ans % MOD
	}

	//25
	k /= 5
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 25
		ans = ans % MOD
	}

	//23
	k /= 23
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 23
		ans = ans % MOD
	}

	//19
	k /= 19
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 19
		ans = ans % MOD
	}

	//17
	k /= 17
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 17
		ans = ans % MOD
	}

	//16
	k /= 2
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 16
		ans = ans % MOD
	}

	//13
	k /= 13
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 13
		ans = ans % MOD
	}

	//11
	k /= 11
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 11
		ans = ans % MOD
	}

	//9
	k /= 3
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 9
		ans = ans % MOD
	}

	//8
	k /= 2
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 8
		ans = ans % MOD
	}

	//7
	k /= 7
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 7
		ans = ans % MOD
	}

	//5
	k /= 5
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 5
		ans = ans % MOD
	}

	//4
	k /= 2
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 4
		ans = ans % MOD
	}

	//3
	k /= 3
	if n >= k {
		d := n/k

		temp := d
		d -= count
		count = temp

		ans += d * 3
		ans = ans % MOD
	}

	ans += (2 + (n - count - 1) * 2 )

	return ans % MOD
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

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

const MOD = 1e9 + 7

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		printf("%d\n", sol(sint64()))
	}
}

func sol(n int64) int64 {
	currLcm := int64(1)
	cum := int64(0)
	for i := int64(2); currLcm <= n; i++ {
		prevLcm := currLcm
		currLcm = lcm(currLcm, i)
		diff := n/prevLcm - n/currLcm
		cum += i * diff
		cum %= MOD
	}
	return cum
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	if a < 0 {
		a *= -1
	}
	return a
}

func lcm(a, b int64) int64 {
	if a == 0 || b == 0 {
		panic("invalid input")
	}
	ret := a / gcd(a, b) * b
	if ret < 0 {
		ret *= -1
	}
	return ret
}

package main

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

var in = bufio.NewReader(os.Stdin)

func debug(T ...interface{}) {
	fmt.Println(T...)
}

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

const mod int64 = 1e9 + 7

func GCD(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func solve(t int) {
	prime := []int64{1}
	z := []int64{1}
	lcm := int64(1)
	for i := int64(2); i <= 50; i++ {
		if lcm > int64(1e16) {
			break
		}
		if lcm%i != 0 {
			lcm *= (i / GCD(i, lcm))
			prime = append(prime, lcm)
			z = append(z, i)
		}
	}
	var n int64
	fmt.Fscan(in, &n)
	ans := int64(0)
	for i := range prime {
		if i == 0 {
			continue
		}
		val := (n/prime[i-1] - n/prime[i])
		val %= mod
		val *= z[i]
		val %= mod
		ans += val
		ans %= mod
	}
	fmt.Println(ans)
}

func main() {
	var T int = 1
	fmt.Fscan(in, &T)
	for t := 1; t <= T; t++ {
		solve(t)
	}
}

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() int64 {
	var res int64
	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 main() {
	io := NewIO(os.Stdin, os.Stdout)

	primes := []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53}

	t := io.ReadInt()
	for ; t > 0; t-- {
		n := io.ReadInt()
		ans := int64(0)
		ss := int64(1)

		ch := make([]int64, 100)

		for i := int64(2); ; i++ {
			ans += n / ss * i

			diff := int64(1)

			for _, prime := range primes {
				toD := i
				st := int64(0)
				for toD % prime == 0 {
					st++
					toD /= prime
				}
				if st > ch[prime] {
					for j := int64(0); j < st - ch[prime]; j++ {
						diff *= prime
					}
					ch[prime] = st
				}
			}

			ss = ss * diff
			ans -= n / ss * i

			ans %= 1e9 + 7
			if ss > n {
				break
			}
		}
		io.Println(ans)
	}
}

package main

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

const N = int(1e5 + 10)

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

	val := make([]int64, 0)
	lc := int64(1)
	i := int64(1)
	for {
		lc = lcm(lc, i)
		val = append(val, lc)
		if lc >= int64(1e16) {
			break
		}
		i++
	}

	// io.Println(val)

	for tt := 0; tt < t; tt++ {
		solve := func() {
			var n, rem, ans int64
			fmt.Scan(&n)
			l := len(val)
			for i := l - 1; i >= 0; i-- {
				ans += (n/val[i] - rem) * int64(i+2)
				rem = n / val[i]
				ans %= int64(1e9 + 7)
			}
			fmt.Println(ans)
		}
		solve()
	}
}

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

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

func lcm(a, b int64) int64 {
	return (a / gcd(a, b)) * b
}

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

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"
	"os"
)

const N = int(1e5 + 10)

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

	val := make([]int64, 0)
	lc := int64(1)
	i := int64(1)
	for {
		lc = lcm(lc, i)
		val = append(val, lc)
		if lc >= int64(1e16) {
			break
		}
		i++
	}

	// io.Println(val)

	for tt := 0; tt < t; tt++ {
		solve := func() {
			var n, rem, ans int64
			fmt.Scan(&n)
			l := len(val)
			for i := l - 1; i >= 0; i-- {
				ans += (n/val[i] - rem) * int64(i+2)
				rem = n / val[i]
				ans %= int64(1e9 + 7)
			}
			io.Println(ans)
		}
		solve()
	}
}

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

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

func lcm(a, b int64) int64 {
	return (a / gcd(a, b)) * b
}

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

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"
	"os"
)

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

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

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

const M = 1000000007

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		s, d := n, 1
		for i := 1; d <= n; i++ {
			d = lcm(d, i)
			s = (s + n/d) % M
		}
		Fprintln(out, s)
	}
}