package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(rr, &n)
	nums := make([]int, n)
	c1 := make([]int64, n+1)
	for i:=0;i<len(nums);i++ {
		fmt.Fscan(rr, &nums[i])
	}
	for i := range nums {
		if nums[i] <= i {
			c1[i+1]++
		}
		c1[i+1] += c1[i]
	}
	var ans int64
	for i:=1;i<len(nums);i++ {
		if nums[i] == 0 {
			continue
		}
		if nums[i] <= i {
			ans += c1[min(i-1, nums[i]-1)]
		}
	}
	fmt.Fprintln(ww, ans)
}

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

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

package main

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

var ans int64

type SegmentTree struct {

	l, r, mid, val int
	left, right *SegmentTree
}

func (seg *SegmentTree) build(l, r int) {

	seg.l = l
	seg.r = r
	seg.mid = (seg.l + seg.r)/2
	if l != r {

		seg.left = new(SegmentTree)
		seg.left.build(seg.l, seg.mid)
		seg.right = new(SegmentTree)
		seg.right.build(seg.mid + 1, seg.r)
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val = 0
	}
}

func (seg *SegmentTree) update(index int) {

	if seg.l != seg.r {

		if index <= seg.mid {

			seg.left.update(index)
		} else {

			seg.right.update(index)
		}
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val += 1
	}
}

func (seg *SegmentTree) get(index int) int {

	if seg.r <= index {

		return seg.val
	}
	if seg.l > index {

		return 0
	}
	return seg.left.get(index) + seg.right.get(index)
}

func sol(in *bufio.Reader, n *int) {

	seg := new(SegmentTree)
	seg.build(1, *n)
	for i := 0; i < *n; i++ {

		var x int
		fmt.Fscan(in, &x)
		if x >= i + 1 {

			continue
		}
		if x > 1 {

			ans += (int64)(seg.get(x - 1))
		}
		seg.update(i + 1)
	}
}

func main() {

	in := bufio.NewReader(os.Stdin)
	//out := bufio.NewWriter(os.Stdout)
	//defer out.Flush()
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {

		ans = 0
		var n int
		fmt.Fscan(in, &n)
		sol(in, &n)
		fmt.Println(ans)
	}
}

package main

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

var ans int64

type SegmentTree struct {

	l, r, mid, val int
	left, right *SegmentTree
}

func (seg *SegmentTree) build(l, r int) {

	seg.l = l
	seg.r = r
	seg.mid = (seg.l + seg.r)/2
	if l != r {

		seg.left = new(SegmentTree)
		seg.left.build(seg.l, seg.mid)
		seg.right = new(SegmentTree)
		seg.right.build(seg.mid + 1, seg.r)
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val = 0
	}
}

func (seg *SegmentTree) update(index int) {

	if seg.l != seg.r {

		if index <= seg.mid {

			seg.left.update(index)
		} else {

			seg.right.update(index)
		}
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val += 1
	}
}

func (seg *SegmentTree) get(index int) int {

	if seg.r <= index {

		return seg.val
	}
	if seg.l > index {

		return 0
	}
	return seg.left.get(index) + seg.right.get(index)
}

func sol(in *bufio.Reader, n *int) {

	seg := new(SegmentTree)
	seg.build(1, *n)
	for i := 0; i < *n; i++ {

		var x int
		fmt.Fscan(in, &x)
		if x >= i + 1 {

			continue
		}
		if x > 1 {

			ans += (int64)(seg.get(x - 1))
		}
		seg.update(i + 1)
	}
}

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {

		ans = 0
		var n int
		fmt.Fscan(in, &n)
		sol(in, &n)
		fmt.Fprintln(out, 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--
		n := readNum(reader)
		arr := readNNums(reader, n)
		res := solve(arr)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(A []int) int64 {
	// index from 1
	// a[i] < i < a[j] < j
	n := len(A)

	var res int64
	dp := make([]int, n+1)

	for i := 1; i <= n; i++ {
		dp[i] += dp[i-1]

		if A[i-1] < i {
			if A[i-1] > 0 {
				res += int64(dp[A[i-1]-1])
			}
			dp[i]++
		}
	}

	return res
}

func solve1(A []int) int64 {
	// index from 1
	// a[i] < i < a[j] < j
	n := len(A)
	bit := NewBit(n + 2)

	var res int64
	for i := n - 1; i >= 0; i-- {
		x := A[i]
		if x <= i {
			res += int64(bit.Get(n) - bit.Get(i+1))
			bit.Set(x)
		}
	}
	return res
}

type Bit []int

func NewBit(n int) Bit {
	arr := make([]int, n+1)
	return Bit(arr)
}

func (bit Bit) Set(p int) {
	p++
	for p < len(bit) {
		bit[p]++
		p += p & -p
	}
}

func (bit Bit) Get(p int) int {
	p++
	var res int
	for p > 0 {
		res += bit[p]
		p -= p & -p
	}
	return res
}

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--
		n := readNum(reader)
		arr := readNNums(reader, n)
		res := solve(arr)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(A []int) int64 {
	// index from 1
	// a[i] < i < a[j] < j
	n := len(A)
	bit := NewBit(n + 2)

	var res int64
	for i := n - 1; i >= 0; i-- {
		x := A[i]
		if x <= i {
			res += int64(bit.Get(n) - bit.Get(i+1))
			bit.Set(x)
		}
	}
	return res
}

type Bit []int

func NewBit(n int) Bit {
	arr := make([]int, n+1)
	return Bit(arr)
}

func (bit Bit) Set(p int) {
	p++
	for p < len(bit) {
		bit[p]++
		p += p & -p
	}
}

func (bit Bit) Get(p int) int {
	p++
	var res int
	for p > 0 {
		res += bit[p]
		p -= p & -p
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var a = [200010]int64{}
var n, m, k, t int64
var scanner = bufio.NewScanner(os.Stdin)
const maxCapacity = 1024*1024*4
var buf= make([]byte, maxCapacity)
func init()  {
	scanner.Buffer(buf, maxCapacity)
}
func min(a ...int) int{
	ans := a[0]
	for _, val := range a {
		if ans > val {
			ans = val
		}
	}
	return ans
}
func scan(arr []int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}
func scanf(arr ...*int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		*arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func solve()  {
	scanf(&n)
	scan(a[1:n+1])
	var v []int64
	var up func(int64)int
	up = func(x int64) int {
		l, r := 0, len(v)
		for ;l < r; {
			mid := (l + r) >> 1
			if v[mid] >= x {
				r = mid
			} else {
				l = mid + 1
			}
		}
		return l
	}
	var ans int64 = 0
	for i := 1; i <= int(n); i++ {
		if i > int(a[i]) {
			ans += int64(up(a[i]))
			v = append(v, int64(i))
		}
	}
	fmt.Println(ans)
}

func main() {
	scanf(&t)
	for i := 0; i < int(t); i++ {
		solve()
	}
}
// klsajkslajl

package main

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

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

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

		aa := make([]int, n+1)
		bb := []int{}
		var tot int64
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < i {
				tot += int64(sort.SearchInts(bb, aa[i]))
				bb = append(bb, i)
			}
		}

		fmt.Fprintln(out, tot)
	}
}

package main

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

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

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

		aa := make([]int, n+1)
		bb := make([]int, n+1)
		var tot int64
		var c int
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < i {
				if aa[i] > 0 {
					tot += int64(bb[aa[i]-1])
				}
				c++
			}
			bb[i] = c
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()

	var n int
	Fscan(in, &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
	}
	var cnt []int
	ans := int64(0)
	for i := 1; i <= n; i++ {
		if i <= arr[i-1] {
			continue
		}
		ans += int64(sort.SearchInts(cnt, arr[i-1]))
		cnt = append(cnt, i)
	}
	Fprintln(out, ans)
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func sum(a, b int64) int64 {
	return (b + a) * (b - a + 1) / 2
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

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

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

type IFenwickTree interface {
	update(int, int)
	rsq(int) int64
	rsq_range(int, int) int64
}

type FenwickTree struct {
	tree     []int64
	sizeTree int
}

func NewFenwickTree(initSizeTree int) *FenwickTree {
	return &FenwickTree{
		tree:     make([]int64, initSizeTree+1),
		sizeTree: initSizeTree,
	}
}

func (fenw *FenwickTree) update(node, val int) {
	for ; node <= fenw.sizeTree; node |= (node + 1) {
		fenw.tree[node] += int64(val)
	}
}

func (fenw *FenwickTree) rsq(node int) int64 {
	var ret int64 = 0
	for ; node >= 0; node = (node & (node + 1)) - 1 {
		ret += fenw.tree[node]
	}
	return ret
}

func (fenw *FenwickTree) rsq_range(l, r int) int64 {
	return fenw.rsq(r) - fenw.rsq(l-1)
}

func main() {
	defer writer.Flush()

	var T int
	fmt.Fscan(reader, &T)

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

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

		fenw := NewFenwickTree(n + 1)

		var ans int64 = 0
		for j := 1; j <= n; j++ {
			if a[j] < j {
				ans += fenw.rsq_range(1, a[j]-1)
				fenw.update(j, 1)
			}
		}

		fmt.Fprintf(writer, "%v\n", ans)
	}
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n,v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := []int{}
		ans := int64(0)
		for i := 1; i <= n; i++ {
			Fscan(in, &v)
			if v < i {
				ans += int64(sort.SearchInts(a, v))
				a = append(a, i)
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

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

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

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

func do(s []int) int64 {
	c := []int{}
	for i, v := range s {
		if v < i+1 {
			c = append(c, v)
		}
	}
	sort.Ints(c)
	var ans int64
	for i, v := range s {
		if v < i+1 {
			ans += bs(c, i+1)
		}
	}
	return ans
}

func bs(c []int, v int) int64 {
	l := 0
	r := len(c)
	for l < r {
		m := (l + r) / 2
		if c[m] <= v {
			l = m + 1
		} else {
			r = m
		}
	}
	return int64(len(c) - l)
}

package main

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

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

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

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Fscan(in, &ans[i])
	}
	return ans
}

func ReadString() string{
	var s string
	fmt.Scan(&s)
	return s
}

func main(){
	defer out.Flush()
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Fprintf(out,"%64d\n" , tot)
	}
}

package main

import "fmt"

func ReadInt() int{
	var i int
	fmt.Scanf("%d\n", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Scanf("%d ", &ans[i])
	}
	fmt.Scanf("\n")
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func main(){
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Println(tot)
	}
}

package main

import "fmt"

func ReadInt() int{
	var i int
	fmt.Scanf("%d\n", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Scanf("%d ", &ans[i])
	}
	//fmt.Scanf("\n")
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func main(){
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Println(tot)
	}
}

package main

import "fmt"

func ReadInt() int{
	var i int
	fmt.Scanf("%d\n", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Scanf("%d", &ans[i])
	}
	//fmt.Scanf("\n")
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func main(){
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Println(tot)
	}
}


package main

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

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

func solve(p int) string {
	return fmt.Sprintf("%d %d", (p-1)/2, p-1)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &p)
		fmt.Println(solve(p))
	}
}

package main

import "fmt"

func main() {
	var t,w int
	fmt.Scanf("%d\n", &t)
	for i:=0;i<t;i++{
		fmt.Scanf("%d\n", &w)
		fmt.Printf("%d %d\n",2,w-1)
	}

}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1549A
Date: 12/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1549/A
Problem: CF1549A
**/
func (in *CF1549A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		P := in.NextInt64()
		fmt.Println(2, int(P/2)*2)
	}
}

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

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

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		p, _ := strconv.Atoi(scanner.Text())
		if p < 6 {
			fmt.Println(2, 4)
		} else {
			fmt.Println(2, p/2)
		}
	}
}

package main

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

func GetAllDivisors(N int) []int {
	vs := []int{}
	for i := 1; i*i <= N; i++ {
		if N%i == 0 {
			vs = append(vs, i)
			if i*i == N {
				continue
			}
			vs = append(vs, N/i)
		}
	}
	return vs
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		a, b := 0, 0
		for _, v := range GetAllDivisors(n - 1) {
			if v != 1 && a == 0 {
				a = v
			}
			if v != 1 && a != 0 {
				b = v
			}
		}
		if a < b {
		    fmt.Fprintln(w, a, b)
		} else {
		    fmt.Fprintln(w, b, a)
		}
	}

	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"fmt"
)

func main() {
	var (
		test int
		P    int
	)
	fmt.Scanln(&test)
	for i := 0; i < test; i++ {
		fmt.Scanln(&P)
		fmt.Println(2, P-1)
	}
}

package main

import "fmt"

func main(){

	var t int16
	var p int64
	fmt.Scanf("%d\n", &t)

	for t>0{

		fmt.Scanf("%d\n", &p)

		var a int64 = 2
		var b int64 = (p-1)/a

		if(p==5){
			b=4
		}

		fmt.Printf("%d %d\n", a,b)

		t--
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var n int
		fmt.Scan(&n)
		ss(n)
	}
}
func ss(n int) {
	fmt.Println("2", n-1)
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Scan(&x)
		fmt.Println(x/2,x-1)
	}
}

// https://codeforces.com/problemset/problem/1549/A

// 1549A - Gregor and Cryptography

// Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.
// Gregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.
//  • P mod a = P mod b , where xmody denotes the remainder when x is divided by y, and
//  • 2 ≤ a < b ≤ P.
// Help Gregor find two bases of his favorite prime number!

// Input
// Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤1000).
// Each subsequent line contains the integer P (5≤P≤109), with P guaranteed to be prime.

// Output
// Your output should consist of t lines. Each line should consist of two integers a and b (2≤a<b≤P). If there are multiple possible solutions, print any.

// Example
// input
// 2
// 17
// 5
// output
// 3 5
// 2 4

// Note
// The first query is P = 17. a = 3 and b = 5 are valid bases in this case, because 17mod3=17mod5=2. There are other pairs which work as well.
// In the second query, with P = 5, the only solution is a = 2 and b = 4.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c int
	var t, p uint

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &p)
			fmt.Fprintln(writer, 2, p-1)
		}
	}

	writer.Flush()
}

package main

import "fmt"

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

    for i := 0; i < tC; i++ {
        var (
            p int
        )
        fmt.Scan(&p)
        fmt.Printf("%d %d\n", p/2, p-1)
    }
}

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			p := iost.GetNextInt()
			if p%2 == 0 {
				iost.Printf("%d %d\n", 2, p/2)
			} else {
				iost.Printf("%d %d\n", 2, p-1)
			}

		}()
	}
}

package main

import "fmt"

func main() {
	var p,t int
	fmt.Scan(&t)
	for {
		if t==0 {
			break
		}
		fmt.Scan(&p)
		fmt.Println(2, p-1)

		t--
	}
}

package main

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

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

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

func main() {
	defer out.Flush()

	var (
		p, t int64
	)
	fmt.Fscanf(in, "%64d", &t)
	for t > 0 {
		t--

		fmt.Fscan(in, &p)
		if p%2 == 1 {
			printf("%d %64d\n", 2, p-1)
		} else {
			printf("%d %64d\n", 2, p)
		}

	}

}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var p int
	fmt.Scan(&p)
	for i := p; i > 0; i-- {
		n:=i
		for i := 2; i*i <= n; i++ {
			if n%i==0 {
				//if i==n/i {
				//	fmt.Println(i,n)
				//}
				fmt.Println(i,n)
				return
			}
		}
	}
}

package main

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

func main() {
	Test()
}

// P mod a=P mod b, where x mod y denotes the remainder when x is divided by y, and
// 2 ≤ a <b ≤ P

func Test() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := ScanPosInt(sc)
	for i := 1; i <= N; i++ {
		P := ScanPosInt(sc)
		fmt.Println(2,P-1)
	}
}

func ScanPosInt(scanner *bufio.Scanner) (n int) {
	scanner.Scan()
	buf := scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _, _ := reader.ReadLine()
	str := string(line)
	n, _ := strconv.Atoi(str)
	for i := 0; i < n; i++ {
		line, _, _ := reader.ReadLine()
		str := string(line)
		n, _ := strconv.Atoi(str)
		mods := make(map[int]int)
		for i := 2; i < n; i++ {
			if mods[n%i] != 0 {
				fmt.Printf("%v %v\n", mods[n%i], i)
				break
			}
			mods[n%i] = i
		}
	}
}

package main

import "fmt"

func main() {
	t := 0
	fmt.Scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		if n == 5 {
			fmt.Println(2, 4)
		} else {
			fmt.Println(2, (n-1)/2)
		}
	}
}

package main

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

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

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

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	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
	}
}

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)

		// STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)

		// ARRAY := make([]int64, n)
		// fmt.Fscan(input, &ARRAY[0])
		// for i := 1; i < n; i++ {
		// 	fmt.Fscan(input, &ARRAY[i])

		// }
		fmt.Println(2)
		fmt.Println(n - 1)

	}

}

package main

import "fmt"

func main() {
	var t,w int
	fmt.Scanf("%d\n", &t)
	for i:=0;i<t;i++{
		fmt.Scanf("%d", &w)
		fmt.Printf("%d %d\n",2,w-1)
	}

}

package main

import "fmt"

func main() {
	var t,w int
	fmt.Scanf("%d", &t)
	for i:=0;i<t;i++{
		fmt.Scanf("%d", &w)

		fmt.Printf("%d %d\n",2,w-1)
	}

}

package main

import "fmt"

func main() {
	var t,w int
	fmt.Scanf("%d", &t)
	for i:=0;i<t;i++{
		fmt.Scanf("%d", &w)
		if w==5{
			fmt.Printf("%d %d\n",2,4)
		}else {
			fmt.Printf("%d %d\n",2,w-1)
		}

	}

}

package main

import "fmt"

func main() {
	var t,w int
	fmt.Scanf("%d", &t)
	for i:=0;i<t;i++{
		fmt.Scanf("%d", &w)
		fmt.Printf("%d %d\n",2,w-1);
	}

}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1549A
Date: 12/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1549/A
Problem: CF1549A
**/
func (in *CF1549A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		in.NextInt64()
		fmt.Println(2, 4)
	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1549A
Date: 12/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1549/A
Problem: CF1549A
**/
func (in *CF1549A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		P := in.NextInt64()
		fmt.Println(P+1, P+P+1)
	}
}

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

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

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		p, _ := strconv.Atoi(scanner.Text())
		if p < 6 {
			fmt.Println(3, 4)
		} else {
			fmt.Println(2, p/2)
		}
	}
}

package main

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

func GetAllDivisors(N int) []int {
	vs := []int{}
	for i := 1; i*i <= N; i++ {
		if N%i == 0 {
			vs = append(vs, i)
			if i*i == N {
				continue
			}
			vs = append(vs, N/i)
		}
	}
	return vs
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		a, b := 0, 0
		for _, v := range GetAllDivisors(n - 1) {
			if v != 1 && a == 0 {
				a = v
			}
			if v != 1 && a != 0 {
				b = v
			}
		}
		fmt.Fprintln(w, a, b)
	}

	w.Flush()
}

func main() {
	solve()
}

package main

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

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

func solve(p int) string {
	return fmt.Sprintf("%d %d", p-1, (p-1)/2)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &p)
		fmt.Println(solve(p))
	}
}

package main

import (
	"fmt"
)

func main() {
	var (
		test int
		P    int
	)
	fmt.Scanln(&test)
	for i := 0; i < test; i++ {
		fmt.Scanln(&P)
		fmt.Println(2, P/2)
	}
}

package main

import "fmt"

func main(){

	var t int16
	var p int64
	fmt.Scanf("%d", &t)

	for t>0{

		fmt.Scanf("%d", &p)

		var a int64 = 2
		var b int64 = (p-1)/a

		if(p==5){
			b=4
		}

		fmt.Printf("%d %d\n", a,b)

		t--
	}
}


package main

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

func main() {
	n, s := ScanInt(), ScanInt()
	solve(n, s)

	close(O)
	oWg.Wait()
}
func solve(n, s int) {
	if s/n == 1 {
		P("NO")
		return
	}

	repeted := strconv.Itoa(s/n) + " "
	lastOne := strconv.Itoa((s / n) + (s % n))

	arrayStr := strings.Repeat(repeted, n-1) + lastOne
	P("YES")
	P(arrayStr)
	P(1)
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

type node struct {
	diff int
	time int
}

type ByTime []node

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

var p []int
var c []int
var children [][]int
var invalid bool

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	//fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, s := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &s)
		if n*2 <= s {
			fmt.Fprintf(out, "YES\n")
			for i := 0; i < n-1; i++ {
				fmt.Fprintf(out, "2 ")
			}
			fmt.Fprintf(out, "%d\n", s-n*2+2)
			fmt.Fprintf(out, "1\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func output(w io.Writer, out1 []int, out2 []string) {
	n := len(out1)
	tmpN := n
	for i := 0; i < len(out1); i++ {
		if out1[i] == 0 {
			tmpN--
		}
	}
	fmt.Fprintf(w, "YES\n")
	fmt.Fprintf(w, "%d\n", tmpN)
	for i := 0; i < n; i++ {
		if out1[i] > 0 {
			fmt.Fprintf(w, "%d %s\n", out1[i], out2[i])
		}
	}
	return
}

package main

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

var sc = WordScanner()
var memory [1000000]interface{}

func main() {
	n := sc.Int()
	s := sc.Int()
	if n == 1 {
		if s > 1 {
			fmt.Println("YES")
			fmt.Println(s)
			fmt.Println("1")
		} else {
			fmt.Println("NO")
		}
		return
	}
	if n + n > s {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	p := memory[:0]
	x := s / n + 1
	for i := s % n; i > 0; i-- {
		p = append(p, x)
	}
	x = s / n
	for i := n - s % n; i > 0; i-- {
		p = append(p, x)
	}
	fmt.Println(p...)
	fmt.Println("1")
}

type Scanner struct {
	*bufio.Scanner
}

func WordScanner() Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Scanner{sc}
}

func (sc Scanner) Text() string {
	sc.Scan()
	return sc.Scanner.Text()
}

func (sc Scanner) Int() int {
	i, _ := strconv.Atoi(sc.Text())
	return i
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, s int64
	fmt.Fscanf(in, "%d %d", &n, &s)

	if s >= 2*n {
		var i int64
		fmt.Fprintf(out, "YES\n")
		for i = 0; i < n-1; i++ {
			fmt.Fprintf(out, "2 ")
		}
		fmt.Fprintf(out, "%d\n1", s-(n-1)*2)
	} else {
		fmt.Fprintf(out, "NO")
	}
	return
}

/*
URL:
https://codeforces.com/problemset/problem/1355/D
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, s int
)

func main() {
	n, s = ReadInt2()

	if s < 2*n {
		fmt.Println("NO")
		return
	}

	A := []int{}
	for i := 0; i < n-1; i++ {
		A = append(A, 2)
	}
	A = append(A, s-2*(n-1))

	fmt.Println("YES")
	fmt.Println(PrintIntsLine(A...))
	fmt.Println(1)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

var reader = bufio.NewReader(os.Stdin)  //use fmt.Fscan
var writer = bufio.NewWriter(os.Stdout) //use fmt.Fprintln

func solve() {
	var n, s int
	fmt.Fscan(reader, &n, &s)
	var x int = s / 2
	if x >= n {
		fmt.Fprintln(writer, "YES")
		last := s - (n-1)*2
		for i := 0; i < n-1; i++ {
			fmt.Fprint(writer, "2 ")
		}
		fmt.Fprintln(writer, last)
		fmt.Fprintln(writer, 1)
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

func main() {
	var t int = 1
	// fmt.Fscan(reader, &t)
	defer writer.Flush()
	for t > 0 {
		solve()
		t--
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1355D(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, s int
	Fscan(_r, &n, &s)
	if s < 2*n {
		Fprint(out, "NO")
	} else {
		Fprintln(out, "YES")
		for i := 1; i < n; i++ {
			Fprint(out, "1 ")
		}
		Fprintln(out, s-n+1)
		Fprint(out, n)
	}
}

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

package main

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

func main() {
	n, s := ScanInt(), ScanInt()
	solve(n, s)

	out.Flush()
}

func solve(n, s int) {
	if s/n == 1 {
		P("NO")
		return
	}

	repeted := strconv.Itoa(s/n) + " "
	lastOne := strconv.Itoa((s / n) + (s % n))

	arrayStr := strings.Repeat(repeted, n-1) + lastOne
	P("YES")
	P(arrayStr)
	P(1)
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case int64:
			str = strconv.FormatInt(v, 10)
		case string:
			str = v
		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}
func ScanInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt64()
	}
	return a
}

/*********************** Utils int64 ***********************/
func MnMx64(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn64(args ...int64) int64 { mn, _ := MnMx64(args...); return mn }
func Mx64(args ...int64) int64 { _, mx := MnMx64(args...); return mx }
func LCM64(a, b int64) int64   { return a / GCD64(a, b) * b }
func GCD64(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD64(b%a, a)
}
func SortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func Abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

/*********************** Utils int ***********************/
func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


package main

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

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

	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ps := make([][]int, n+1)
		for i := range ps {
			ps[i] = []int{-1}
		}
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			ps[v] = append(ps[v], i)
		}
		for i := range ps {
			ps[i] = append(ps[i], n)
		}
		ans := make([]int, n+2)
		for i := range ans {
			ans[i] = 1e9
		}
		for i := n; i > 0; i-- {
			mx := 0
			for j := 1; j < len(ps[i]); j++ {
				if d := ps[i][j] - ps[i][j-1]; d > mx {
					mx = d
				}
			}
			ans[mx] = i
		}
		for i := 1; i <= n; i++ {
			if ans[i-1] < ans[i] {
				ans[i] = ans[i-1]
			}
			if ans[i] == 1e9 {
				Fprint(out, "-1 ")
			} else {
				Fprint(out, ans[i], " ")
			}
		}
		Fprintln(out)
	}
}

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

package main

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

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

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

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

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

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

func solve() {
	n := nextInt()
	arr := make([]int, n)
	for i := range arr {
		arr[i] = nextInt()
	}
	prev := map[int]int{}
	max := map[int]int{}
	for i, v := range arr {
		dist := i + 1 - prev[v]
		prev[v] = i + 1
		if dist > max[v] {
			max[v] = dist
		}
	}
	for i, v := range prev {
		if n+1-v > max[i] {
			max[i] = n + 1 - v
		}
	}
	eves := [][2]int{}
	for i, v := range max {
		eves = append(eves, [2]int{i, v})
	}
	sort.Slice(eves, func(a, b int) bool {
		return eves[a][1] < eves[b][1]
	})

	ind := 0
	res := -1
	for i := 1; i <= n; i++ {
		for ind < len(eves) && eves[ind][1] == i {
			if eves[ind][0] < res || res == -1 {
				res = eves[ind][0]
			}
			ind++
		}
		printf("%d ", res)
	}
	printf("\n")
}

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

	for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
		// printf("Case #%d:\n", i)
		solve()
	}

	// printf("%v\n", time.Now().Sub(start))
}


package main

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

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

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

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

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

		}
		return m
	}
}

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

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

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

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

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

	return
}

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

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

	return num
}

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

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

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

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

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

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

var t int

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

		if (c+d)%2 == 1 {
			fmt.Println(-1)
		} else {
			if c == 0 && d == 0 {
				fmt.Println(0)
			} else {
				if (c+d) == 0 || (c-d) == 0 {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}

	}
}

package main

import (
	"fmt"
	"math"
)

func foo() {
	var c, d int
	fmt.Scan(&c, &d)
	switch {
	case c == 0 && d == 0:
		fmt.Println(0)
	case c == d:
		fmt.Println(1)
	case int(math.Abs(float64(c - d))) % 2 == 1:
		fmt.Println(-1)
	default:
		fmt.Println(2)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		foo()
	}
}

package main

import (
	"fmt"
)
var(
	t int
	a,b int
)
func Swap(a *int,b *int){
	tmp:= *a
	*a = *b
	*b = tmp
}
func main(){
	fmt.Scanf("%d\n",&t)
	for i := 1; i<=t;i++{
		fmt.Scanf("%d %d\n",&a,&b)
		if a<b{
			Swap(&a,&b)
		}
		if  a==0 &&b==0{
			fmt.Printf("0\n")
			continue
		}
		if(a-b)%2 != 0{
			fmt.Printf("-1\n")
		}else if a==b{
			fmt.Printf("1\n")
		}else {
			fmt.Printf("2\n")
		}

	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1556A
Date: 14/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1556/A
Problem: CF1556A
**/
func (in *CF1556A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b := in.NextInt(), in.NextInt()

		max := int(math.Max(float64(a), float64(b)))
		min := int(math.Min(float64(a), float64(b)))

		if (max-min)%2 == 0 {
			if max == min {
				if max == 0 {
					fmt.Println(0)
				} else {
					fmt.Println(1)
				}
			} else {
				fmt.Println(2)
			}

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

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

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

package main

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

func Abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		c, d := 0, 0
		fmt.Fscan(f, &c, &d)
		m := (c + d) / 2
		if c == d {
			if c == 0 {
				fmt.Fprintln(w, 0)
			} else {
				fmt.Fprintln(w, 1)
			}
		} else if Abs(m-c) == Abs(m-d) {
			fmt.Fprintln(w, 2)
		} else {
			fmt.Fprintln(w, -1)
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	t, c, d int
)

func solve(c, d int) int {
	if (c+d)%2 == 1 {
		return -1
	}
	if c == 0 && d == 0 {
		return 0
	}
	if c == d {
		return 1
	}
	return 2
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &c, &d)
		fmt.Println(solve(c, d))
	}
}

package main

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

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

	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		if a&1 != b&1 {
			Fprintln(out, -1)
		} else if a == 0 && b == 0 {
			Fprintln(out, 0)
		} else if a == b {
			Fprintln(out, 1)
		} else {
			Fprintln(out, 2)
		}
	}
}

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

package main

import(
	"fmt"
)

func main()  {
	var testcases int
	fmt.Scanf("%d\n" , &testcases)

	for ;testcases > 0; testcases--{
		var c, d int
		fmt.Scanf("%d %d\n" , &c , &d)

		// swap
		if c > d {
			c, d = d , c
		}

		// corner cases
		if c == d {
			if c == 0{
				fmt.Println(0)
			}else{
				fmt.Println(1)
			}
			continue
		}

		diff := d - c
		if diff % 2 == 0 {
			fmt.Println(2)
		}else{
			fmt.Println(-1)
		}

	}

}

package main

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

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

	var T int

	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var a, b int
		fmt.Fscanf(r, "%d %d\n", &a, &b)

		if a == 0 && b == 0 {
			fmt.Println(0)
		} else if a == b {
			fmt.Println(1)
		} else {
			if (a+b)%2 == 1 {
				fmt.Println(-1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

func (s *Scanner) Word() string {
	s.Scan()
	return s.Text()
}

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

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(c, d int64) int64 {
	if c == 0 && d == 0 {
		return 0
	}
	if c == d {
		return 1
	}

	diff := c - d
	if diff < 0 {
		diff = -diff
	}
	if diff % 2 == 1 {
		return -1
	}

	return 2
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i++ {
		c, d := stdin.Int64(), stdin.Int64()
		fmt.Println(solve(c, d))
	}
}

package main

import (
	"fmt"
	"math"
)

func foo() {
	var c, d int
	fmt.Scan(&c, &d)
	switch {
	case c == 0 && d == 0:
		fmt.Println(0)
	case c == d:
		fmt.Println(1)
	case math.Abs(float64(c - d)) == 1:
		fmt.Println(-1)
	default:
		fmt.Println(2)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		foo()
	}
}

package main

import (
	"fmt"
)
var(
	t int
	a,b int
)
func Swap(a *int,b *int){
	tmp:= *a
	*a = *b
	*b = tmp
}
func main(){
	fmt.Scanf("%d",&t)
	for i := 1; i<=t;i++{
		fmt.Scanf("%d%d",&a,&b)
		if a<b{
			Swap(&a,&b)
		}
		if a==0 && b==0{
			fmt.Printf("0\n")
			continue
		}
		if(a-b)%2 != 0{
			fmt.Printf("-1\n")
		}else if a==b{
			fmt.Printf("1\n")
		}else {
			fmt.Printf("2\n")
		}

	}
}


/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		l, p := a, int64(1)
		dec := F(l, p) - F(l, p+1)
		pq.push(&Carrot{pri: dec, l: l, p: p})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()

		c.p++
		l, p := c.l, c.p
		dec := F(l, p) - F(l, p+1)
		c.pri = dec
		pq.push(c)
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()

		l, p := c.l, c.p
		ans += F(l, p)
	}

	fmt.Println(ans)
}

func F(l, p int64) int64 {
	w := l / p
	p2 := l % p
	p1 := p - p2

	return p1*w*w + p2*(w+1)*(w+1)
}

type Carrot struct {
	pri int64
	l   int64
	p   int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

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

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

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

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

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

type Seg struct {
	parts, value int
}

func (s *Seg) oneMore() int64 {
	oldCost := s.cost()
	s.parts++
	newCost := s.cost()
	s.parts--
	return oldCost - newCost
}

func (s *Seg) cost() int64 {
	nBigger := s.value % s.parts
	nSmaller := s.parts - nBigger
	smallerSize := s.value / s.parts

	var biggerCost int64 = int64(smallerSize+1) * int64(smallerSize+1)
	var smallerCost int64 = int64(smallerSize) * int64(smallerSize)

	return int64(nBigger)*biggerCost + int64(nSmaller)*smallerCost
}

type IntHeap []*Seg

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i].oneMore() > h[j].oneMore() }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(*Seg))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	old[n-1] = nil
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, k int
	fmt.Fscan(reader, &n, &k)

	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		heap.Push(h, &Seg{parts: 1, value: a})
	}

	for i := 0; i < k-n; i++ {
		max := heap.Pop(h).(*Seg)
		max.parts++
		heap.Push(h, max)
	}

	var sum int64
	for i := 0; i < h.Len(); i++ {
		el := (*h)[i]
		sum += el.cost()
	}

	fmt.Println(sum)
}

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		pq.push(&Carrot{pri: int(a), length: a})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()
		var al, bl int64
		if c.length%2 == 0 {
			al, bl = c.length/2, c.length/2
		} else {
			al, bl = c.length/2+1, c.length/2
		}

		pq.push(&Carrot{pri: int(al), length: al})
		pq.push(&Carrot{pri: int(bl), length: bl})
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()
		val := c.length

		ans += val * val
	}

	fmt.Println(ans)
}

type Carrot struct {
	pri    int
	length int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

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

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

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

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

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		l, p := a, int64(1)
		dec := F(l, p) - F(l, p+1)
		pq.push(&Carrot{pri: dec, l: l, p: p})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()

		l, p := c.l, c.p
		dec := F(l, p) - F(l, p+1)
		c.p++
		c.pri = dec
		pq.push(c)
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()

		l, p := c.l, c.p
		ans += F(l, p)
	}

	fmt.Println(ans)
}

func F(l, p int64) int64 {
	w := l / p
	p2 := l % p
	p1 := p - p2

	return p1*w*w + p2*(w+1)*(w+1)
}

type Carrot struct {
	pri int64
	l   int64
	p   int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

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

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

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

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

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		l, p := a, int64(1)
		dec := F(l, p) - F(l, p+1)
		pq.push(&Carrot{pri: dec, l: l, p: p})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()

		l, p := c.l, c.p
		c.p++
		dec := F(l, p) - F(l, p+1)
		c.pri = dec
		pq.push(c)
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()

		l, p := c.l, c.p
		ans += F(l, p)
	}

	fmt.Println(ans)
}

func F(l, p int64) int64 {
	w := l / p
	p2 := l % p
	p1 := p - p2

	return p1*w*w + p2*(w+1)*(w+1)
}

type Carrot struct {
	pri int64
	l   int64
	p   int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

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

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

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

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

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, k int
	fmt.Fscan(reader, &n, &k)

	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		heap.Push(h, a)
	}

	for i := 0; i < k-n; i++ {
		max := heap.Pop(h).(int)
		half := max / 2

		heap.Push(h, half)
		heap.Push(h, max-half)
	}

	var sum int64
	for h.Len() > 0 {
		el := heap.Pop(h).(int)
		sum += int64(el * el)
	}

	fmt.Println(sum)
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, k int
	fmt.Fscan(reader, &n, &k)

	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		heap.Push(h, a)
	}

	for i := 0; i < k-n; i++ {
		max := heap.Pop(h).(int)
		half := max / 2

		heap.Push(h, half)
		heap.Push(h, max-half)
	}

	var sum int64
	for h.Len() > 0 {
		el := heap.Pop(h).(int)
		sum += int64(el) * int64(el)
	}

	fmt.Println(sum)
}


package main

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

var scanner *bufio.Scanner

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

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

  s := getS()
  negative := false
  if s[0] == '-' {
    negative = true
    s = s[1:len(s)]
  }
  parts := strings.Split(s, ".")
  whole, fraction := parts[0], "0"
  if len(parts) == 2 {
    fraction = parts[1]
  }

  if negative {
    writer.WriteString("(")
  }
  writer.WriteString("$")

  offset := (3 - len(whole)%3) % 3
  for i := 0; i < len(whole); i++ {
    if offset == 3 {
      writer.WriteString(",")
      offset = 0
    }
    writer.WriteByte(whole[i])
    offset++
  }

  writer.WriteString(".")
  writer.WriteByte(fraction[0])
  if len(fraction) == 1 {
    writer.WriteString("0")
  } else {
    writer.WriteByte(fraction[1])
  }

  if negative {
    writer.WriteString(")")
  }
    writer.WriteString("\n")
}

package main

import "os"
import "bufio"

func main(){
	var s string
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	s = r.Text()
	dot := len(s)
	for i:=0; i<len(s); i++ {
		if string(s[i]) == "." {
			dot = i
		}
	}
	if string(s[0]) == "-" {
		w.WriteString("($")
	} else {
		w.WriteString("$"+string(s[0]))
	}
	for i:=1; i<dot; i++ {
		if (dot - i) % 3 == 0 && !(i == 1 && string(s[0]) == "-") {
			w.WriteString(",")
		}
		w.WriteString(string(s[i]))
	}
	if len(s)-dot == 0 {
		w.WriteString(".00")
	} else if len(s)-dot == 2 {
		w.WriteString("."+string(s[dot+1])+"0")
	} else if len(s)-dot > 2 {
		w.WriteString("."+string(s[dot+1])+string(s[dot+2]))
	}
	if string(s[0]) == "-" {
		w.WriteString(")")
	}
	w.WriteString("\n")
	w.Flush()
}