Every year Santa Claus gives gifts to all children. However, each country has its own traditions, and this process takes place in different ways. For example, in Berland you need to solve the New Year's puzzle.Polycarp got the following problem: given a grid strip of size $$$2 \times n$$$, some cells of it are blocked. You need to check if it is possible to tile all free cells using the $$$2 \times 1$$$ and $$$1 \times 2$$$ tiles (dominoes).For example, if $$$n = 5$$$ and the strip looks like this (black cells are blocked):  Then it can be tiled, for example, using two vertical and two horizontal tiles, as in the picture below (different tiles are marked by different colors).  And if $$$n = 3$$$ and the strip looks like this:  It is impossible to tile free cells.Polycarp easily solved this task and received his New Year's gift. Can you solve it?

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case is preceded by an empty line. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le m \le 2 \cdot 10^5$$$) — the length of the strip and the number of blocked cells on it. Each of the next $$$m$$$ lines contains two integers $$$r_i, c_i$$$ ($$$1 \le r_i \le 2, 1 \le c_i \le n$$$) — numbers of rows and columns of blocked cells. It is guaranteed that all blocked cells are different, i.e. $$$(r_i, c_i) \ne (r_j, c_j), i \ne j$$$. It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print on a separate line:    "YES", if it is possible to tile all unblocked squares with the $$$2 \times 1$$$ and $$$1 \times 2$$$ tiles;  "NO" otherwise.  You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

NoteThe first two test cases are explained in the statement.In the third test case the strip looks like this:    It is easy to check that the unblocked squares on it can not be tiled.

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{} // [row, col]
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = !blocking
			// if next two blocks form a barricade, return NO
			if i+2 < len(blocks) {
				if blocks[i+1][1] == blocks[i+2][1] {
					return "NO"
				}
			}
			continue
		}
		blocking = !blocking
		if blocks[i][0] == blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 0 {
			return "NO"
		}
		if blocks[i][0] != blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{} // [row, col]
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = !blocking
			// if next block is on same column, avoid these checks
			if i+1 < len(blocks) {
				if blocks[i+1][1] == blocks[i][1] {
					continue
				}
			}
			// if next two blocks form a barricade, return NO
			if i+2 < len(blocks) {
				if blocks[i+1][1] == blocks[i+2][1] {
					return "NO"
				}
			}
			continue
		}
		blocking = !blocking
		if blocks[i][0] == blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 0 {
			return "NO"
		}
		if blocks[i][0] != blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		if solve() {
			println("YES")
		} else {
			println("NO")
		}
	}
}

func Unique(xs []int) []int {
	if len(xs) == 0 {
		return xs
	}
	r := 0
	for i := 1; i < len(xs); i++ {
		if xs[r] < xs[i] {
			r++
			xs[r], xs[i] = xs[i], xs[r]
		}
	}
	return xs[:r+1]
}

func solve() bool {
	_, m := ReadInt(), ReadInt()
	v := make(map[int]int)
	xs := make([]int, 0)
	for i := 0; i < m; i++ {
		y, x := ReadInt(), ReadInt()
		v[x] |= 1 << (y - 1)
		xs = append(xs, x)
	}
	const Full = 3
	if m%2 == 1 {
		return false
	}
	sort.Ints(xs)
	xs = Unique(xs)
	prev := 0
	prevX := 0
	for i := 0; i < len(xs); i++ {
		x := xs[i]
		mask := v[x]
		if prev == 0 {
			if mask == Full {
				continue
			} else {
				prev = Full - mask
				prevX = x
			}
		} else {
			if (x-prevX)%2 == 1 {
				if mask&prev > 0 {
					return false
				} else {
					prev = 0
					continue
				}
			}
			if (x-prevX)%2 == 0 {
				if mask&(Full-prev) > 0 {
					return false
				} else {
					prev = 0
					continue
				}
			}
		}
	}
	return prev == 0
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func printInts(a ...int)                { s := fmt.Sprint(a); println(s[1 : len(s)-1]) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	type pair struct{ r, c int }

	f := func() bool {
		var w, n, S, p int
		Fscan(in, &w, &n)
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].r, &a[i].c)
		}
		sort.Slice(a, func(i, j int) bool { return a[i].c < a[j].c })

		for i := 0; i < n; i++ {
			if i < n-1 && a[i].c == a[i+1].c {
				if S > 0 {
					return false
				}
				i++
				continue
			}
			if S == 0 {
				S, p = a[i].r, a[i].c
				continue
			}
			if S == a[i].r == ((a[i].c-p)&1 == 0) {
				return false
			}
			S = 0
		}
		return S == 0
	}
	t := 0
	for Fscan(in, &t); t > 0; t-- {
		if f() {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	type pair struct{ r, c int }

	f := func() bool {
		var w, n, state, p int
		Fscan(in, &w, &n)
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].r, &a[i].c)
		}
		sort.Slice(a, func(i, j int) bool { return a[i].c < a[j].c })
		for i := 0; i < n; i++ {
			if i == n-1 {
				return state > 0 && state == a[i].r == ((a[i].c-p)&1 > 0)
			}
			if a[i].c == a[i+1].c {
				if state > 0 {
					return false
				}
				i++
				continue
			}
			if state == 0 {
				state, p = a[i].r, a[i].c
				continue
			}
			if state == a[i].r == ((a[i].c-p)&1 == 0) {
				return false
			}
			state = 0
		}
		return state == 0
	}
	t := 0
	for Fscan(in, &t); t > 0; t-- {
		if f() {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ r, c int }
	solve := func(Case int) bool {
		var w, n int
		Fscan(in, &w, &n)
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].r, &a[i].c)
		}
		sort.Slice(a, func(i, j int) bool { return a[i].c < a[j].c })

		state := 0
		pos := 0
		for i := 0; i < n; i++ {
			if i == n-1 {
				if state == 0 {
					return false
				}
				if state == a[i].r {
					if (a[i].c-pos)&1 == 0 {
						return false
					}
					state = 0
				} else {
					if (a[i].c-pos)&1==1 {
						return false
					}
					state = 0
				}
				break
			}

			if a[i].c == a[i+1].c {
				i++
				if state == 0 {
					continue
				}
				return false
			}

			if state == 0 {
				state = a[i].r
				pos = a[i].c
			} else {
				if state == a[i].r {
					if (a[i].c-pos)&1 == 0 {
						return false
					}
					state = 0
				} else {
					if (a[i].c-pos)&1==1 {
						return false
					}
					state = 0
				}
			}
		}
		return state == 0
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"}[solve(Case)])
	}

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

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

package main

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

func Solve() {
	n, m := ri(), ri()
	mp := make(map[int]int)
	var a []int
	for i := 0; i < m; i++ {
		x, y := ri(), ri()
		mp[y] += x
		a = append(a, y)
	}
	mp[n+1] = 3
	a = append(a, n+1)
	sort.Ints(a)
	a = unique(a)
	for i := 0; i < len(a)-1; i++ {
		if mp[a[i]] == 3 {
			continue
		}
		if mp[a[i+1]] == 3 {
			println("NO")
			return
		}
		if mp[a[i]] != mp[a[i+1]] && (a[i+1]-a[i])%2 == 0 {
			i++
		} else if mp[a[i]] == mp[a[i+1]] && (a[i+1]-a[i])%2 == 1 {
			i++
		} else {
			println("NO")
			return
		}
	}
	println("YES")
}

func main() {
	T := 0 // 如果是多组样例，请讲 T := 1 改为 T := 0
	in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	if T == 0 {
		scan(&T)
	}
	for t := 0; t < T; t++ {
		Solve()
	}
	out.Flush()
}

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

// ri 将直接读入并返回一个 int
func ri() (x int) {
	scan(&x)
	return x
}

// ri64 将直接读入并返回一个 int64
func ri64() (x int64) {
	scan(&x)
	return x
}

//rs 将直接读入并返回一个 string
func rs() (s string) {
	scan(&s)
	return s
}

//scan 用法与 fmt.scan() 相似，可以传入多个变量的地址进行读入操作
func scan(a ...interface{}) { Fscan(in, a...) }

//print 用法与 fmt.print() 相似，可以传入多个变量进行输出。
//注意，这个函数不会换行，多个变量之间有空格
func print(a ...interface{}) { Fprint(out, a...) }

//println 用法与 fmt.println() 相似，可以传入多个变量进行输出。
//这个函数会换行，多个变量之间有空格
func println(a ...interface{}) { Fprintln(out, a...) }

//min 可以传入多个 int 变量，求出这些变量的最小值
func min(a ...int) int {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ans {
			ans = a[i]
		}
	}
	return ans
}

//min64 可以传入多个 int64 变量，求出这些变量的最小值
func min64(a ...int64) int64 {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ans {
			ans = a[i]
		}
	}
	return ans
}

//max 可以传入多个 int 变量，求出这些变量的最大值
func max(a ...int) int {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ans {
			ans = a[i]
		}
	}
	return ans
}

//max64 可以传入多个 int64 变量，求出这些变量的最大值
func max64(a ...int64) int64 {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ans {
			ans = a[i]
		}
	}
	return ans
}

//sum 可以传入多个 int 变量，求出这些变量的总和，并返回总和。
//你可以使用 ... 运算符打散数组，使得 sum 函数可以求出数组的和。
func sum(a ...int) int {
	ans := 0
	for _, x := range a {
		ans += x
	}
	return ans
}

//sum64 可以传入多个 int64 变量，求出这些变量的总和，并返回总和。
//你可以使用 ... 运算符打散数组，使得 sum 函数可以求出数组的和。
func sum64(a ...int64) int64 {
	ans := int64(0)
	for _, x := range a {
		ans += x
	}
	return ans
}

//reverse 用于翻转 int 切片，所有元素将会变成原切片的倒序
func reverse(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

//reverse64 用于翻转 int64 切片，所有元素将会变成原切片的倒序
func reverse64(a []int64) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

//lowerBound 类似于 C++ 中的 lower_bound。
//用于二分查找 int 切片中，第一个大于等于 k 的元素在切片中的位置。
//如果元素不存在，则返回切片的长度。
//注意，lowerBound 作用的 int 切片必须升序。
func lowerBound(a []int, k int) int {
	l, r, pos := 0, len(a)-1, len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid] < k {
			l = mid + 1
		} else {
			pos, r = mid, mid-1
		}
	}
	return pos
}

//lowerBound64 类似于 C++ 中的 lower_bound。
//用于二分查找 int64 切片中，第一个大于等于 k 的元素在切片中的位置。
//如果元素不存在，则返回切片的长度。
//注意，lowerBound 作用的 int64 切片必须升序。
func lowerBound64(a []int64, k int64) int {
	l, r, pos := 0, len(a)-1, len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid] < k {
			l = mid + 1
		} else {
			pos, r = mid, mid-1
		}
	}
	return pos
}

//upperBound 类似于 C++ 中的 upper_bound。
//用于二分查找 int 切片中，第一个大于 k 的元素在切片中的位置。
//如果元素不存在，则返回切片的长度。
//注意，upperBound 作用的 int 切片必须升序。
func upperBound(a []int, k int) int {
	l, r, pos := 0, len(a)-1, len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid] <= k {
			l = mid + 1
		} else {
			pos, r = mid, mid-1
		}
	}
	return pos
}

//upperBound64 类似于 C++ 中的 upper_bound。
//用于二分查找 int64 切片中，第一个大于 k 的元素在切片中的位置。
//如果元素不存在，则返回切片的长度。
//注意，upperBound 作用的 int64 切片必须升序。
func upperBound64(a []int64, k int64) int {
	l, r, pos := 0, len(a)-1, len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid] <= k {
			l = mid + 1
		} else {
			pos, r = mid, mid-1
		}
	}
	return pos
}

func unique(a []int) []int {
	var b []int
	b = append(b, a[0])
	for i := 1; i < len(a); i++ {
		if a[i] != a[i-1] {
			b = append(b, a[i])
		}
	}
	return b
}

func valSet(a []int, k int) {
	for i, _ := range a {
		a[i] = k
	}
}

type Stack struct {
	s []int
}

func (st *Stack) top() int   { return st.s[len(st.s)-1] }
func (st *Stack) size() int  { return len(st.s) }
func (st *Stack) pop()       { st.s = st.s[:len(st.s)-1] }
func (st *Stack) push(x int) { st.s = append(st.s, x) }

type Queue struct {
	que chan int
}

func MakeQueue(size int) Queue {
	var q Queue
	q.que = make(chan int, size)
	return q
}

type PriorityQueue struct {
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

// blocks are in [row, col]
func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	rm := int64(0)
	blocks2 := [][2]int64{}
	for i := range blocks {
		if i > 0 && blocks[i][1] == blocks[i-1][1] {
			blocks2 = blocks2[:len(blocks2)-1]
			rm++
		} else {
			tmp := blocks[i]
			tmp[1] -= rm
			blocks2 = append(blocks2, tmp)
		}
	}
	return sol2(n, m, blocks2)
}

func sol2(n, m int64, blocks [][2]int64) string {
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = !blocking
			continue
		}
		blocking = !blocking
		if blocks[i][0] == blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 0 {
			return "NO"
		}
		if blocks[i][0] != blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

// blocks are in [row, col]
func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocks2 := [][2]int64{}
	for i := range blocks {
		if i > 0 && blocks[i][1] == blocks[i-1][1] {
			blocks2 = blocks2[:len(blocks2)-1]
		} else {
			blocks2 = append(blocks2, blocks[i])
		}
	}
	return sol2(n, m, blocks2)
}

func sol2(n, m int64, blocks [][2]int64) string {
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = !blocking
			continue
		}
		blocking = !blocking
		if blocks[i][0] == blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 0 {
			return "NO"
		}
		if blocks[i][0] != blocks[i-1][0] && (blocks[i][1]-blocks[i-1][1])&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

// blocks are in [row, col]
func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocks2 := [][2]int64{}
	for i := range blocks {
		if i > 0 && blocks[i][1] == blocks[i-1][1] {
			blocks2 = blocks2[:len(blocks2)-1]
		} else {
			blocks2 = append(blocks2, blocks[i])
		}
	}
	blocking := false
	for i := range blocks2 {
		if !blocking {
			blocking = true
			continue
		}
		blocking = false
		if blocks[i][0] == blocks[i-1][0] {
			if (blocks[i][1]-blocks[i-1][1])&1 == 0 {
				return "NO"
			}
		}
		if blocks[i][0] != blocks[i-1][0] {
			if (blocks[i][1]-blocks[i-1][1])&1 == 1 {
				return "NO"
			}
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			for _, j := range []int{i + 1, i + 2} {
				if j < len(blocks) {
					if blocks[j][1] == blocks[i][1] {
						break
					}
					if blocks[j][0] != blocks[i][0] && blocks[j][1] == blocks[i][1]+1 {
						return "NO"
					}
				}
			}
			continue
		}
		blocking = false
		if blocks[i][0] == blocks[i-1][0] {
			if (blocks[i][1]-blocks[i-1][1])&1 == 0 {
				return "NO"
			}
		}
		if blocks[i][0] != blocks[i-1][0] {
			if (blocks[i][1]-blocks[i-1][1])&1 == 1 {
				return "NO"
			}
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			for _, j := range []int{i + 1, i + 2} {
				if j < len(blocks) {
					if blocks[j][1] == blocks[i][1] {
						break
					}
					if blocks[j][0] != blocks[i][0] && blocks[j][1] == blocks[i][1]+1 {
						return "NO"
					}
				}
			}
			continue
		}
		blocking = false
		if blocks[i][0] == blocks[i-1][0] {
			if (blocks[i][1]-blocks[i-1][1])&1 == 0 {
				return "NO"
			}
		}
		if blocks[i][0] != blocks[i-1][0] {
			if (blocks[i][1]-blocks[i-1][1])&1 == 1 {
				return "NO"
			}
		}
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		if blocks[il][1] == blocks[ir][1] {
			return blocks[il][0] < blocks[il][0]
		}
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			if i+1 < len(blocks) {
				if blocks[i+1][0] != blocks[i][0] && blocks[i+1][1] == blocks[i][1]+1 {
					return "NO"
				}
			}
			if i+2 < len(blocks) {
				if blocks[i+2][0] != blocks[i][0] && blocks[i+2][1] == blocks[i][1]+1 {
					return "NO"
				}
			}
			continue
		}
		blocking = false
		curr := blocks[i]
		prev := blocks[i-1]
		diff := curr[1] - prev[1]
		if curr[0] == prev[0] && diff&1 == 0 {
			return "NO"
		}
		if curr[0] != prev[0] && diff&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		if blocks[il][1] == blocks[ir][1] {
			return blocks[il][0] < blocks[il][0]
		}
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			if i+1 < len(blocks) {
				if blocks[i+1][0] != blocks[i][0] && blocks[i+1][1] == blocks[i][0]+1 {
					return "NO"
				}
			}
			if i+2 < len(blocks) {
				if blocks[i+2][0] != blocks[i][0] && blocks[i+2][1] == blocks[i][0]+1 {
					return "NO"
				}
			}
			continue
		}
		blocking = false
		curr := blocks[i]
		prev := blocks[i-1]
		diff := curr[1] - prev[1]
		if curr[0] == prev[0] && diff&1 == 0 {
			return "NO"
		}
		if curr[0] != prev[0] && diff&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	sort.Slice(blocks, func(il, ir int) bool {
		if blocks[il][1] == blocks[ir][1] {
			return blocks[il][0] < blocks[il][0]
		}
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			continue
		}
		blocking = false
		curr := blocks[i]
		prev := blocks[i-1]
		diff := curr[1] - prev[1]
		if curr[0] == prev[0] && diff&1 == 0 {
			return "NO"
		}
		if curr[0] != prev[0] && diff&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	// sort by col
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			continue
		}
		blocking = false
		curr := blocks[i]
		prev := blocks[i-1]
		diff := curr[1] - prev[1]
		if curr[0] == prev[0] && diff&1 == 0 {
			return "NO"
		}
		if curr[0] != prev[0] && diff&1 == 1 {
			return "NO"
		}
	}
	if blocking {
		return "NO"
	}
	return "YES"
}

package main

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

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

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

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		m := sint64()
		block := [][2]int64{}
		for i := m; i > 0; i-- {
			block = append(block, [2]int64{sint64(), sint64()})
		}
		printf("%s\n", sol(n, m, block))
	}
}

func sol(n, m int64, blocks [][2]int64) string {
	// sort by col
	sort.Slice(blocks, func(il, ir int) bool {
		return blocks[il][1] < blocks[ir][1]
	})
	blocking := false
	for i := range blocks {
		if !blocking {
			blocking = true
			continue
		}
		blocking = false
		curr := blocks[i]
		prev := blocks[i-1]
		diff := curr[1] - prev[1]
		if curr[0] == prev[0] && diff&1 == 0 {
			return "NO"
		}
		if curr[0] != prev[0] && diff&1 == 1 {
			return "NO"
		}
	}
	return "YES"
}

package main

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

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		if solve() {
			println("YES")
		} else {
			println("NO")
		}
	}
}

func Unique(xs []int) []int {
	if len(xs) == 0 {
		return xs
	}
	r := 0
	for i := 1; i < len(xs); i++ {
		if xs[r] < xs[i] {
			r++
			xs[r], xs[i] = xs[i], xs[r]
		}
	}
	return xs[:r+1]
}

func solve() bool {
	_, m := ReadInt(), ReadInt()
	v := make(map[int]int)
	xs := make([]int, 0)
	for i := 0; i < m; i++ {
		y, x := ReadInt(), ReadInt()
		v[x] |= 1 << (y - 1)
		xs = append(xs, x)
	}
	const Full = 3
	if m%2 == 1 {
		return false
	}
	sort.Ints(xs)
	xs = Unique(xs)
	prev := 0
	prevX := 0
	for i := 0; i < len(xs); i++ {
		x := xs[i]
		mask := v[x]
		if prev == 0 {
			if mask == Full {
				continue
			} else {
				prev = mask
				prevX = Full - mask
			}
		} else {
			if (x-prevX)%2 == 1 {
				if mask&prev > 0 {
					return false
				} else {
					prev = 0
					continue
				}
			}
			if (x-prevX)%2 == 0 {
				if mask&(Full-prev) > 0 {
					return false
				} else {
					prev = 0
					continue
				}
			}
		}
	}
	return prev == 0
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func printInts(a ...int)                { s := fmt.Sprint(a); println(s[1 : len(s)-1]) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}

package main

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

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		if solve() {
			println("YES")
		} else {
			println("NO")
		}
	}
}

func Unique(xs []int) []int {
	if len(xs) == 0 {
		return xs
	}
	r := 0
	for i := 1; i < len(xs); i++ {
		if xs[r] < xs[i] {
			r++
			xs[r], xs[i] = xs[i], xs[r]
		}
	}
	return xs[:r+1]
}

func solve() bool {
	_, m := ReadInt(), ReadInt()
	v := make(map[int]int)
	xs := make([]int, 0)
	for i := 0; i < m; i++ {
		y, x := ReadInt(), ReadInt()
		v[x] |= 1 << (y - 1)
		xs = append(xs, x)
	}
	const Full = 3
	if m%2 == 1 {
		return false
	}
	xs = Unique(xs)
	sort.Ints(xs)
	prev := 0
	prevX := 0
	for i := 0; i < len(xs); i++ {
		x := xs[i]
		if prev == 0 {
			if v[x] == Full {
				continue
			} else {
				prev = v[x]
				prevX = x
			}
		} else {
			if (x-prevX)%2 == 0 && prev&v[x] > 0 {
				return false
			}
			if (x-prevX)%2 == 1 && (Full-prev)&v[x] > 0 {
				return false
			}
			prev = 0
		}
	}
	return prev == 0
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func printInts(a ...int)                { s := fmt.Sprint(a); println(s[1 : len(s)-1]) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}

package main

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

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		if solve() {
			println("YES")
		} else {
			println("NO")
		}
	}
}

func Unique(xs []int) []int {
	if len(xs) == 0 {
		return xs
	}
	r := 0
	for i := 1; i < len(xs); i++ {
		if xs[r] < xs[i] {
			r++
			xs[r], xs[i] = xs[i], xs[r]
		}
	}
	return xs[:r+1]
}

func solve() bool {
	_, m := ReadInt(), ReadInt()
	v := make(map[int]int)
	xs := make([]int, 0)
	for i := 0; i < m; i++ {
		y, x := ReadInt(), ReadInt()
		v[x] |= 1 << (y - 1)
		xs = append(xs, x)
	}
	const Full = 3
	if m%2 == 1 {
		return false
	}
	xs = Unique(xs)
	sort.Ints(xs)
	prev := 0
	prevX := 0
	for i := 0; i < len(xs); i++ {
		x := xs[i]
		if prev == 0 {
			if v[x] == Full {
				continue
			} else {
				prev = v[x]
				prevX = x
			}
		} else {
			if (x-prevX)%2 == 0 && prev&v[x] > 0 {
				return false
			}
			if (x-prevX)%2 == 1 && (Full-prev)&v[x] > 0 {
				return false
			}
			prev = 0
		}
	}
	return true
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func printInts(a ...int)                { s := fmt.Sprint(a); println(s[1 : len(s)-1]) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ r, c int }
	solve := func(Case int) bool {
		var w, n int
		Fscan(in, &w, &n)
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].r, &a[i].c)
		}
		sort.Slice(a, func(i, j int) bool { return a[i].c < a[j].c })

		state := 0
		pos := 0
		for i := 0; i < n; i++ {
			if i == n-1 {
				if state == 0 {
					return true
				}
				if state == a[i].r {
					if (a[i].c-pos)&1 == 0 {
						return false
					}
					state = 0
				} else {
					if (a[i].c-pos)&1==1 {
						return false
					}
					state = 0
				}
				return true
			}

			if a[i].c == a[i+1].c {
				i++
				if state == 0 {
					continue
				}
				return false
			}

			if state == 0 {
				state = a[i].r
				pos = a[i].c
			} else {
				if state == a[i].r {
					if (a[i].c-pos)&1 == 0 {
						return false
					}
					state = 0
				} else {
					if (a[i].c-pos)&1==1 {
						return false
					}
					state = 0
				}
			}
		}
		return state == 0
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"}[solve(Case)])
	}

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

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


A batch of $$$n$$$ goods ($$$n$$$ — an even number) is brought to the store, $$$i$$$-th of which has weight $$$a_i$$$. Before selling the goods, they must be packed into packages. After packing, the following will be done:   There will be $$$\frac{n}{2}$$$ packages, each package contains exactly two goods;  The weight of the package that contains goods with indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$) is $$$a_i + a_j$$$. With this, the cost of a package of weight $$$x$$$ is always $$$\left \lfloor\frac{x}{k}\right\rfloor$$$ burles (rounded down), where $$$k$$$ — a fixed and given value.Pack the goods to the packages so that the revenue from their sale is maximized. In other words, make such $$$\frac{n}{2}$$$ pairs of given goods that the sum of the values $$$\left \lfloor\frac{x_i}{k} \right \rfloor$$$, where $$$x_i$$$ is the weight of the package number $$$i$$$ ($$$1 \le i \le \frac{n}{2}$$$), is maximal.For example, let $$$n = 6, k = 3$$$, weights of goods $$$a = [3, 2, 7, 1, 4, 8]$$$. Let's pack them into the following packages.   In the first package we will put the third and sixth goods. Its weight will be $$$a_3 + a_6 = 7 + 8 = 15$$$. The cost of the package will be $$$\left \lfloor\frac{15}{3}\right\rfloor = 5$$$ burles.  In the second package put the first and fifth goods, the weight is $$$a_1 + a_5 = 3 + 4 = 7$$$. The cost of the package is $$$\left \lfloor\frac{7}{3}\right\rfloor = 2$$$ burles.  In the third package put the second and fourth goods, the weight is $$$a_2 + a_4 = 2 + 1 = 3$$$. The cost of the package is $$$\left \lfloor\frac{3}{3}\right\rfloor = 1$$$ burle. With this packing, the total cost of all packs would be $$$5 + 2 + 1 = 8$$$ burles.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) —the number of test cases in the test. The descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) and $$$k$$$ ($$$1 \le k \le 1000$$$). The number $$$n$$$ — is even. The second line of each test case contains exactly $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all the test cases does not exceed $$$2\cdot10^5$$$.

For each test case, print on a separate line a single number — the maximum possible total cost of all the packages.

NoteThe first test case is analyzed in the statement.In the second test case, you can get a total value equal to $$$4$$$ if you put the first and second goods in the first package and the third and fourth goods in the second package.In the third test case, the cost of each item is $$$0$$$, so the total cost will also be $$$0$$$.

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

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i]%k == arr[j]%k {
				return arr[i] < arr[j]
			}
			return arr[i]%k < arr[j]%k
		})

		m := make([]bool, n)
		r := n - 1
		var tot int64
		for i := 0; i < n-1; i++ {
			if m[i] {
				continue
			}
			m[i] = true

			if arr[r]%k < k-(arr[i]%k) {
				tot += int64((arr[i] + arr[i+1]) / k)
				m[i+1] = true
			} else {
				tot += int64((arr[i] + arr[r]) / k)
				m[r] = true
				r--
			}
		}
		fmt.Fprintln(out, tot)
	}
}

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

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i]%k == arr[j]%k {
				return arr[i] < arr[j]
			}
			return arr[i]%k < arr[j]%k
		})

		m := make([]bool, n)
		r := n - 1
		var tot int64
		for i := 0; i < n-1; i++ {
			if m[i] {
				continue
			}
			m[i] = true

			if arr[i]%k == 0 || arr[r]%k < k-(arr[i]%k) {
				tot += int64((arr[i] + arr[i+1]) / k)
				m[i+1] = true
			} else {
				tot += int64((arr[i] + arr[r]) / k)
				m[r] = true
				r--
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

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

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

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var niter int
	fmt.Fscan(scanner, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var n, k int64
		fmt.Fscan(scanner, &n, &k)
		res := int64(0)
		slice := make([]int64, k)
		for i := int64(0); i < n; i++ {
			var el int64
			fmt.Fscan(scanner, &el)
			res += (el / k)
			slice[el%k]++
		}
		j := int64(1)
		for i := k - 1; i >= k/2; {
			if i < j {
				break
			}
			//fmt.Println("#", i, j, slice)
			if slice[i] == 0 {
				i--
			}
			if slice[j] == 0 {
				j++
			}
			if i < j {
				break
			}
			tmp := min(slice[i], slice[j])
			if i == j {
				if 2*i >= k {
					res += (slice[i] / 2)
				}
				break
			}
			if i+j >= k {
				slice[i] -= tmp
				slice[j] -= tmp
				res += tmp
			}
			if slice[i] > 0 && slice[j] > 0 {
				j++
			}
		}
		// val := slice[i]
		// if slice[i] > 0 {
		// 	for j := int64(0); j <= i; j++ {
		// 		if (i == j) && (2*i >= k) {
		// 			res += (slice[i] / 2)
		// 			slice[i] /= 2
		// 		} else {
		// 			if (j+i >= k) && (val > 0) && (slice[j] >= 0) {
		// 				tmp := min(slice[j], val)
		// 				res += tmp
		// 				val -= tmp
		// 				slice[i] -= tmp
		// 				slice[j] -= tmp
		// 				//fmt.Println("!!!", i, j, slice)
		// 			}
		// 		}
		// 	}
		//}
		fmt.Fprintln(writer, res)
	}

}

package main

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

var (
	a [2e5 + 5]int
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n, k := read(), read()
		sum := uint64(0)
		for i := 1; i <= n; i++ {
			a[i] = read()
			sum += uint64(a[i] / k)
			a[i] %= k
		}
		sort.Ints(a[1 : n+1])
		l, r := 1, n
		for l < r {
			if a[l]+a[r] >= k {
				sum++
				r--
			}
			l++
		}
		Fprintln(out, sum)
	}
}

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

package main

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

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

func slove() {
	var n, k int
	fmt.Fscan(r, &n, &k)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	cnt := make([]int64, k)
	for i := range nums {
		cnt[nums[i]%k]++
	}
	var sum, out int64
	for i:=(k-1)/2+1;i<k;i++ {
		for j:=k-i;j<=i&&cnt[i]>0;j++ {
			if j != i {
				diff := min(cnt[j], cnt[i])
				cnt[j] -= diff
				cnt[i] -= diff
				out += diff * int64(j + i - k)
			} else {
				diff := cnt[i] / 2
				cnt[i] -= 2 * diff
				out += diff * int64(2 * i - k)
			}
		}
	}

	for i := range cnt {
		out += cnt[i] * int64(i)
	}
	for i := range nums {
		sum += int64(nums[i])
	}
	fmt.Fprintln(w, (sum - out)/int64(k))
}

func min(a, b int64) int64 {if a < b {return a} else {return b}}
func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

// 拿单独出现的最大的数来填
// 若最大的数很多，拿来填也不坏
// 0 1 3 5 5
// 0 1 2 5 5 = 1
// 0 1 2 3 5 = 2 better
// ----
// 0 1 6 8 8
// 0 1 2 8 8 = 1
// 0 1 2 6 8 = 2 bad
// 二分答案 二分 mex
// get mex ->  <= mex 不变 get an ans
// mex 越大越好
// mex 可达 加大
//不可达 变小
func A4() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, k int64
		Fscan(in, &n, &k)
		arr := make([]int64, n)
		for i := int64(0); i < n; i++ {
			Fscan(in, &arr[i])
		}
		sort.Slice(arr, func(i, j int) bool {
			return (arr[i] % k) < (arr[j] % k)
		})
		var ans int64
		i, j := int64(0), n-1
		tmp := make([]int64, 0)
		//Fprintln(out, "arr", arr)
		for i = 0; i < j; i++ {
			if ((arr[i] % k) + (arr[j] % k)) >= k {
				//	Fprintln(out, ":OK:", i, j)
				ans += (arr[i] + arr[j]) / k
				j--
				//	Fprintln(out, tmp)
			} else {
				tmp = append(tmp, arr[i])
			}
		}
		if i == j {
			tmp = append(tmp, arr[i])
		}
		//	Fprintln(out, tmp)
		for i := 0; i < len(tmp); i += 2 {
			ans += (tmp[i] + tmp[i+1]) / k
		}
		Fprintln(out, ans)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A4() }

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

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i]%k == arr[j]%k {
				return arr[i] < arr[j]
			}
			return arr[i]%k < arr[j]%k
		})

		m := make([]bool, n)
		r := n - 1
		var tot int64
		for i := 0; i < n-1; i++ {
			if m[i] {
				continue
			}
			m[i] = true

			if arr[i]%k == 0 {
				tot += int64((arr[i] + arr[i+1]) / k)
				m[i+1] = true
			} else {
				tot += int64((arr[i] + arr[r]) / k)
				m[r] = true
				r--
			}
		}
		fmt.Fprintln(out, tot)
	}
}

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
		var k int64
		fmt.Fscan(in, &n, &k)

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

		sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
		m := make([]bool, n)
		var tot int64
		for i := n - 1; i >= 0; i-- {
			if m[i] {
				continue
			}

			m[i] = true
			j := i - 1
			for m[j] {
				j--
			}
			z := (((arr[i] + arr[j]) / k) * k) - arr[i]
			g := sort.Search(len(arr), func(i int) bool {
				return arr[i] >= z
			})

			for m[g] {
				g++
			}
			m[g] = true
			tot += (arr[i] + arr[j]) / k
		}

		fmt.Fprintln(out, tot)
	}
}

package main

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

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

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

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var niter int
	fmt.Fscan(scanner, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var n, k int64
		fmt.Fscan(scanner, &n, &k)
		res := int64(0)
		slice := make([]int64, k)
		for i := int64(0); i < n; i++ {
			var el int64
			fmt.Fscan(scanner, &el)
			res += (el / k)
			slice[el%k]++
		}
		j := int64(1)
		for i := k - 1; i >= k/2; {
			if i < j {
				break
			}
			fmt.Println("#", i, j, slice)
			if slice[i] == 0 {
				i--
			}
			if slice[j] == 0 {
				j++
			}
			if i < j {
				break
			}
			tmp := min(slice[i], slice[j])
			if i == j {
				if 2*i >= k {
					res += (slice[i] / 2)
				}
				break
			}
			if i+j >= k {
				slice[i] -= tmp
				slice[j] -= tmp
				res += tmp
			}
			if slice[i] > 0 && slice[j] > 0 {
				j++
			}
		}
		// val := slice[i]
		// if slice[i] > 0 {
		// 	for j := int64(0); j <= i; j++ {
		// 		if (i == j) && (2*i >= k) {
		// 			res += (slice[i] / 2)
		// 			slice[i] /= 2
		// 		} else {
		// 			if (j+i >= k) && (val > 0) && (slice[j] >= 0) {
		// 				tmp := min(slice[j], val)
		// 				res += tmp
		// 				val -= tmp
		// 				slice[i] -= tmp
		// 				slice[j] -= tmp
		// 				//fmt.Println("!!!", i, j, slice)
		// 			}
		// 		}
		// 	}
		//}
		fmt.Fprintln(writer, res)
	}

}

package main

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

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

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

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var niter int
	fmt.Fscan(scanner, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var n, k int64
		fmt.Fscan(scanner, &n, &k)
		res := int64(0)
		slice := make([]int64, k)
		for i := int64(0); i < n; i++ {
			var el int64
			fmt.Fscan(scanner, &el)
			res += (el / k)
			slice[el%k]++
		}
		for i := k - 1; i > k/2; i-- {
			val := slice[i]
			for j := int64(0); j <= i; j++ {
				if (i == j) && (2*i >= k) {
					res += (slice[i] / 2)
					slice[i] /= 2
				} else {
					if (j+i >= k) && (val > 0) {
						tmp := min(slice[j], val)
						res += tmp
						val -= tmp
						slice[i] -= tmp
						slice[j] -= tmp
						//fmt.Println("!!!", i, j, slice)
					}
				}
			}
		}
		fmt.Fprintln(writer, res)
	}
}

package main

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

var (
	a [2e5 + 5]int
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n, k := read(), read()
		sum := 0
		for i := 1; i <= n; i++ {
			a[i] = read()
			sum += a[i] / k
			a[i] %= k
		}
		sort.Ints(a[1 : n+1])
		l, r := 1, n
		for l < r {
			if a[l]+a[r] >= k {
				sum++
				r--
			}
			l++
		}
		Fprintln(out, sum)
	}
}

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

package main

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

var (
	a [2e5 + 5]int
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n, k := read(), read()
		sum := 0
		for i := 1; i <= n; i++ {
			a[i] = read()
			sum += a[i] / k
			a[i] %= k
		}
		sort.Ints(a[1 : n+1])
		l, r := 1, n
		for l < r {
			if a[l]+a[r] >= k {
				sum++
				r--
			} else {
				l++
			}
		}
		Fprintln(out, sum)
	}
}

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

package main

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

var (
	a [2e5 + 5]int
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n, k := read(), read()
		sum := 0
		for i := 1; i <= n; i++ {
			a[i] = read()
			sum += a[i] / k
			a[i] %= k
		}
		sort.Ints(a[1 : n+1])
		l, r := 1, n
		for l < r {
			if a[l]+a[r] > k {
				sum++
				r--
			} else {
				l++
			}
		}
		Fprintln(out, sum)
	}
}

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

package main

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

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

func slove() {
	var n, k int
	fmt.Fscan(r, &n, &k)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	cnt := make([]int64, k)
	for i := range nums {
		cnt[nums[i]%k]++
	}
	var sum, out int64
	for i:=k/2+1;i<k;i++ {
		for j:=k-i;j<=i&&cnt[i]>0;j++ {
			if j != i {
				diff := min(cnt[j], cnt[i])
				cnt[j] -= diff
				cnt[i] -= diff
				out += diff * int64(j + i - k)
			} else {
				diff := cnt[i] / 2
				cnt[i] -= 2 * diff
				out += diff * int64(2 * i - k)
			}
		}
	}
	for i := range cnt {
		out += cnt[i] * int64(i)
	}
	for i := range nums {
		sum += int64(nums[i])
	}
	fmt.Fprintln(w, (sum - out)/int64(k))
}

func min(a, b int64) int64 {if a < b {return a} else {return b}}
func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

// 拿单独出现的最大的数来填
// 若最大的数很多，拿来填也不坏
// 0 1 3 5 5
// 0 1 2 5 5 = 1
// 0 1 2 3 5 = 2 better
// ----
// 0 1 6 8 8
// 0 1 2 8 8 = 1
// 0 1 2 6 8 = 2 bad
// 二分答案 二分 mex
// get mex ->  <= mex 不变 get an ans
// mex 越大越好
// mex 可达 加大
//不可达 变小
func A4() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, k int
		Fscan(in, &n, &k)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &arr[i])
		}
		sort.Slice(arr, func(i, j int) bool {
			return (arr[i] % k) < (arr[j] % k)
		})
		var ans int
		i, j := 0, n-1
		tmp := make([]int, 0)
		//Fprintln(out, "arr", arr)
		for i = 0; i < j; i++ {
			if ((arr[i] % k) + (arr[j] % k)) >= k {
				//	Fprintln(out, ":OK:", i, j)
				ans += (arr[i] + arr[j]) / k
				j--
				//	Fprintln(out, tmp)
			} else {
				tmp = append(tmp, arr[i])
			}
		}
		if i == j {
			tmp = append(tmp, arr[i])
		}
		//	Fprintln(out, tmp)
		for i := 0; i < len(tmp); i += 2 {
			ans += (tmp[i] + tmp[i+1]) / k
		}
		Fprintln(out, ans)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A4() }


Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.He noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position $$$x$$$, and the shorter rabbit is currently on position $$$y$$$ ($$$x \lt y$$$). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by $$$a$$$, and the shorter rabbit hops to the negative direction by $$$b$$$.  For example, let's say $$$x=0$$$, $$$y=10$$$, $$$a=2$$$, and $$$b=3$$$. At the $$$1$$$-st second, each rabbit will be at position $$$2$$$ and $$$7$$$. At the $$$2$$$-nd second, both rabbits will be at position $$$4$$$.Gildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.

Each test contains one or more test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Each test case contains exactly one line. The line consists of four integers $$$x$$$, $$$y$$$, $$$a$$$, $$$b$$$ ($$$0 \le x \lt y \le 10^9$$$, $$$1 \le a,b \le 10^9$$$) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.

For each test case, print the single integer: number of seconds the two rabbits will take to be at the same position. If the two rabbits will never be at the same position simultaneously, print $$$-1$$$.

NoteThe first case is explained in the description.In the second case, each rabbit will be at position $$$3$$$ and $$$7$$$ respectively at the $$$1$$$-st second. But in the $$$2$$$-nd second they will be at $$$6$$$ and $$$4$$$ respectively, and we can see that they will never be at the same position since the distance between the two rabbits will only increase afterward.

package main

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

func main() {
	in := bufio.NewScanner(os.Stdin)
	out := os.Stdout
	in.Scan()
	tests, _ := strconv.Atoi(in.Text())
	var inputArray []string
	//var results []int

	for i := 0; i < tests; i++ {
		in.Scan()
		inputArray = append(inputArray,in.Text())
	}

	for i := 0; i < len(inputArray); i++  {
		values := strings.Split(inputArray[i], " ")
		firstRabbit, _ := strconv.Atoi(values[0])
		secondRabbit, _ := strconv.Atoi(values[1])
		firstRabbitMover, _ := strconv.Atoi(values[2])
		secondRabbitMover, _ := strconv.Atoi(values[3])
		dif :=  secondRabbit - firstRabbit
		movement := firstRabbitMover + secondRabbitMover

		if dif % movement == 0 {
			fmt.Fprintln(out, dif / (firstRabbitMover + secondRabbitMover))
		} else {
			fmt.Fprintln(out, -1)
		}
	}

/*

	}
*/
}

package main

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

func main() {
	var t, x, y, a, b int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &x, &y, &a, &b)
		d := y - x
		if d%(a+b) == 0 {
			fmt.Println(d / (a + b))
		} else {
			fmt.Println(-1)
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var x, y, a, b int
		fmt.Scan(&x, &y, &a, &b)
		if (y-x)%(a+b) != 0 {
			fmt.Println(-1)
		} else {
			fmt.Println((y - x) / (a + b))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var x, y, a, b int
		fmt.Fscan(in, &x, &y, &a, &b)
		if (y-x)%(a+b) != 0 {
			fmt.Fprintln(out, -1)
		} else {
			fmt.Fprintln(out, (y-x)/(a+b))
		}
	}
	out.Flush()
}

package main

import ("fmt")

func calculate(y,d int32){
	answer := y%d
	if answer==0{
		fmt.Println(y/d)
	}else{
		fmt.Println(-1)
	}
}

func main(){
	var t int
	fmt.Scanln(&t)
	for i:=0;i<t;i++{
		var x int32
		var y int32
		var a int32
		var b int32
		fmt.Scan(&x,&y,&a,&b)
		calculate(y-x,a+b)
	}
}

package main

import "fmt"

func TwoRabbit(x, y, a, b int) int {
	if (y-x) % (a+b) == 0 { return (y-x) / (a+b)}
	return -1
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var x, y, a, b int
		fmt.Scanf("%d %d %d %d \n", &x, &y, &a, &b)
		fmt.Println(TwoRabbit(x, y, a, b))
	}
}

package main

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

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

    var t, a, b, x, y int
    fmt.Fscan(in, &t)
    for ;t > 0; t-- {
        fmt.Fscan(in, &x, &y, &a, &b)
        if (y - x) % (a + b) != 0 {
            fmt.Fprintln(out, -1)
        } else {
            fmt.Fprintln(out, (y - x) / (a + b))
        }

    }
}

/**
 * Copyright shopee
 * @Author : Yuxiang.Lei
 * @MailBox: Yuxiang.Lei@shopee.com
 * @Date : 2020-02-15
 * @Version: v2.4
 **/

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numStr := scanner.Text()
	num, _ := strconv.Atoi(numStr)
	for i:=0; i<num; i++ {
		scanner.Scan()
		arrStr := scanner.Text()
		arr := strings.Split(arrStr, " ")
		xs := arr[0]
		x, _ := strconv.ParseInt(xs, 10, 64)
		ys := arr[1]
		y, _ := strconv.ParseInt(ys, 10, 64)
		as := arr[2]
		a, _ := strconv.ParseInt(as, 10, 64)
		bs := arr[3]
		b, _ := strconv.ParseInt(bs, 10, 64)
		distance := y - x
		speed := a + b
		if distance % speed == 0 {
			fmt.Println(distance / speed)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	 tests := scanInt()
	 for t := 0; t < tests; t++ {
		 x := scanInt()
		 y := scanInt()
		 a := scanInt()
		 b := scanInt()

		 d := y-x
		 if d%(a+b) == 0 {
			 fmt.Println(d/(a+b))
		 } else {
			 fmt.Println(-1)
		 }
	 }
}

package main

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

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

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

func main() {
	defer writer.Flush()

	var t, a, b, x, y int

	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		scanf("%d %d %d %d\n", &x, &y, &a, &b)
		x = y - x
		a = a + b
		if x%a == 0 {
			printf("%d\n", x/a)
		} else {
			printf("-1\n")
		}
	}

}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    line := scanner.Text()
    t, _ := strconv.Atoi(line)
    for i := 0; i < t; i++ {
        scanner.Scan()
        line = scanner.Text()
        parts := strings.Split(line, " ")
        x, _ := strconv.Atoi(parts[0])
        y, _ := strconv.Atoi(parts[1])
        a, _ := strconv.Atoi(parts[2])
        b, _ := strconv.Atoi(parts[3])
        d := y - x
        divisor := a + b
        if d % divisor == 0 {
            k := d / divisor
            fmt.Println(k)
        } else {
            fmt.Println(-1)
        }
    }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	var x, y,  a, b int64
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &x, &y, &a, &b)
		if y  >= x && (y - x) % (a  +  b) == 0  {
			fmt.Fprintln(out, (y-x) /  (a + b))
		} else   {
			fmt. Fprintln(out,  -1)
		}
	}
}

package main

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

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

	solve := func() (ans int) {
		var x,y,a,b int
		Fscan(in, &x,&y,&a,&b)
		d := y-x
		if d%(a+b) != 0 {
			return -1
		}

		return d/(a+b)
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		Fprintln(out, solve())
	}
}

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

package main

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

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

	solve := func() (ans int) {
		var x, y, a, b int
		Fscan(in, &x, &y, &a, &b)
		y -= x
		a += b
		if y%a != 0 {
			return -1
		}
		return y / a
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		Fprintln(out, solve())
	}
}

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var t, x, y, a, b int
	fmt.Scan(&t)
	answers := make([]int, t)
	for i := 0; i < t; i++ {
		fmt.Scan(&x, &y, &a, &b)
		time := float64(y-x) / float64(a+b)
		if time == math.Trunc(time) {
			answers[i] = int(time)
		} else {
			answers[i] = -1
		}
	}
	for i := 0; i < t; i++ {
		fmt.Println(answers[i])
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t, x, y, a, b int
	fmt.Scan(&t)
	answers := []int{}
	for i := 0; i < t; i++ {
		fmt.Scan(&x, &y, &a, &b)
		time := float64(y-x) / float64(a+b)
		if time == math.Trunc(time) {
			answers = append(answers, int(time))
		} else {
			answers = append(answers, -1)
		}
	}
	for i := 0; i < t; i++ {
		fmt.Println(answers[i])
	}
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	for t := ScanInt64(); t > 0; t-- {
		x, y, a, b := ScanInt64(), ScanInt64(), ScanInt64(), ScanInt64()

		if ((y - x) % (a + b)) == 0 {
			O <- S(((y - x) / (a + b)))
		} else {
			O <- "-1"
		}
	}

	close(O)
	oWg.Wait()
}

/*********************** 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)) 		// do some research
	in.Split(bufio.ScanWords)

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

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

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

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 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 []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 := MX_INT, MN_INT; for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
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 sortSlice(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"
	"os"
	"strconv"
)

func main() {
	for t := ReadInt64(); t > 0; t-- {
		x, y, a, b := ReadInt64(), ReadInt64(), ReadInt64(), ReadInt64()

		if ((y - x) % (a + b)) == 0 {
			fmt.Println(((y - x) / (a + b)))
		} else {
			fmt.Println("-1")
		}
	}
}

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 1024), int(1e8))
	scanner.Split(bufio.ScanWords)
}

func ReadString() string {
	scanner.Scan()
	return scanner.Text()
}

func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}

func ReadInt64() int64 {
	intStr := ReadString()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ReadInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

package main

import (
	"fmt"
)

func main() {
	t := 0
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		x := 0
		y := 0
		a := 0
		b := 0
		fmt.Scanln(&x, &y, &a, &b)
		if (y - x) % (a + b) == 0 {
			fmt.Println((y - x) / (a + b))
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {

	for t := ScanInt64(); t > 0; t-- {
		x, y, a, b := ScanInt64(), ScanInt64(), ScanInt64(), ScanInt64()

		if ((y - x) % (a + b)) == 0 {
			O <- S(((y - x) / (a + b)))
		} else {
			O <- "-1"
		}
	}

	close(O)
	oWg.Wait()
}

/*********************** 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(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e8))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

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

func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := MX_INT, MN_INT

	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}

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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

func SArr(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)

	for i := range a {
		numStr := strconv.FormatInt(a[i], 10)
		sb.WriteString(numStr + " ")
	}
	return sb.String()
}

package main

import "fmt"

func process(x, y, a, b int) int {
	delta := y - x
	sumPerSecond := a + b

	if sumPerSecond > delta || (delta % sumPerSecond != 0) {
		return -1
	}

	return delta / sumPerSecond
}

func main()  {
	var test int
	var x, y, a, b int
	fmt.Scan(&test)
	for {
		if test == 0 {
			break
		}
		fmt.Scan(&x, &y, &a, &b)
		result := process(x, y, a, b)
		fmt.Println(result)
		test -= 1
	}
}

package main

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

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

	var t, x, y, a, b int
	fmt.Fscanln(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscanln(in, &x, &y, &a, &b)
		if (y-x)%(a+b) == 0 {
			fmt.Fprintln(out, (y-x)/(a+b))
		} else {
			fmt.Fprintln(out, -1)
		}
	}
	out.Flush()
}

package main

import (
	"fmt"
)

func main() {
	numInputs := 0
	fmt.Scanf("%d\n", &numInputs)
	output := make([]int, numInputs)
	for i := 0; i < numInputs; i++ {
		var x, y, a, b int
		fmt.Scanf("%d %d %d %d\n", &x, &y, &a, &b)
		output[i] = rabbit(x, y, a, b)
	}
	for _, val := range output {
		fmt.Println(val)
	}
}

func rabbit(x, y, a, b int) int {
	if (y-x)%(a+b) == 0 {
		return (y - x) / (a + b)
	}
	return -1
}

package main

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		x := ReadInt()
		y := ReadInt()
		a := ReadInt()
		b := ReadInt()
		if ((y-x)%(a+b) == 0) {
			fmt.Println((y - x) / (a + b))
		} else {
			fmt.Println(-1)
		}
	}
}

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

import (
	"fmt"
)

func main() {
	var t, x, y, a, b int

	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&x, &y, &a, &b)
		if (y-x)%(a+b) == 0 {
			fmt.Println((y - x) / (a + b))
		} else {
			fmt.Println("-1")
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for q := 0; q < t; q++ {
		var x1, x2, a, b int
		fmt.Scanf("%d %d %d %d\n", &x1, &x2, &a, &b)
		if (x2 - x1) % (a + b) == 0 {
			fmt.Println((x2 - x1) / (a + b))
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

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

	var t, a, b, x, y, dist, sum int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &x, &y, &a, &b)
		dist = y - x
		sum = a + b
		if dist%sum != 0 {
			fmt.Fprintln(out, -1)
		} else {
			fmt.Fprintln(out, dist/sum)
		}

	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	var x, y, a, b int
	var r float64
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d %d\n", &x, &y, &a, &b)
		r = float64(float64((y - x)) / float64((a + b)))
		v, float := math.Modf(r)
		if r != 0 && float == 0 {
			fmt.Println(int(v))
		} else {
			fmt.Println("-1")
		}
	}
}

package main

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

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

	var t, a, b, x, y int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &x, &y, &a, &b)
		if (y-x)%(a+b) != 0 {
			fmt.Fprintln(out, -1)
		} else {
			fmt.Fprintln(out, (y-x)/(a+b))
		}

	}
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Buffer(make([]byte, 1<<12), 1<<20)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	t := scanInt(s)

	for i := 0; i < t; i++ {
		x, y, a, b := scanInt(s), scanInt(s), scanInt(s), scanInt(s)
		if (y-x)%(a+b) == 0 {
			fmt.Fprintln(w, (y-x)/(a+b))
		} else {
			fmt.Fprintln(w, "-1")
		}
	}

}

func scanInt(s *bufio.Scanner) int {
	s.Scan()
	t, _ := strconv.Atoi(s.Text())
	return t
}

package main

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

func main() {
	if len(os.Args) < 5 {
		fmt.Errorf("Needs 4 arguments")
		return
	}

	x, _ := strconv.Atoi(os.Args[1])
	y, _ := strconv.Atoi(os.Args[2])
	a, _ := strconv.Atoi(os.Args[3])
	b, _ := strconv.Atoi(os.Args[4])

	fmt.Println(rabbit(x, y, a, b))
}

func rabbit(x, y, a, b int) int {
	hops := 0
	for y > x {
		y = y - b
		x = x + a
		hops++
		if y == x {
			return hops
		}
	}
	return -1
}

package main

import (
	"fmt"
	"math"
)

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

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

func solve(x, y, a, b int) (ans int) {
	counter := 0
	prevDistance := 1000000000
	for {
		distance := int(math.Abs(float64(x) - float64(y)))

		if distance > prevDistance {
			return -1
		}
		if x == y {
			return counter
		}
		x = x + a
		y = y - b
		prevDistance = distance

		counter++
	}
	return
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	var x, y, a, b int
	var r float64
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d %d", &x, &y, &a, &b)
		r = float64(float64((y - x)) / float64((a + b)))
		v, float := math.Modf(r)
		if r != 0 && float == 0 {
			println(int(v))
		} else {
			println("-1")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	var x, y, a, b int
	var r float64
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d %d", &x, &y, &a, &b)
		r = float64(float64((y - x)) / float64((a + b)))
		v, float := math.Modf(r)
		if r != 0 && float == 0 {
			fmt.Println(int(v))
		} else {
			fmt.Println("-1")
		}
	}
}