package main

import (
	"fmt"
	"math"
)

func main() {
	distances := make(map[int]int)
	lastIndexes := make(map[int]int)
	minNum := math.MaxInt32
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		// update distance
		if lastIdx, ok := lastIndexes[x]; ok {
			distance := i - lastIdx
			if lastDistance, ok := distances[x]; ok {
				if distance < lastDistance {
					distances[x] = distance
				}
			} else {
				distances[x] = distance
			}
		}
		// update last seen indexes
		lastIndexes[x] = i
		// update min num
		if x < minNum {
			minNum = x
		}
	}
	fmt.Println(distances[minNum])
}

package main

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

func main() {
	var n, min, min_i, min_j, latest_i int
	stdin := bufio.NewReader(os.Stdin)

	fmt.Fscan(stdin, &n)
	arr := make([]int, n)
	fmt.Fscan(stdin, &arr[0])
	min = arr[0]
	for i := 1; i < n; i++ {
		fmt.Fscan(stdin, &arr[i])
		if arr[i] < min {
			min = arr[i]
			min_i = i
			min_j = i
			latest_i = i
		} else if arr[i] == min {
			if min_i == latest_i {
				min_j = i
			} else if min_j-min_i > i-latest_i {
				min_i, min_j = latest_i, i
			}
			latest_i = i
		}
	}
	fmt.Println(min_j - min_i)
}

package main

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

func main() {
	var n, x int
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscan(stdin, &n)

	distances := make(map[int]int)
	lastIndexes := make(map[int]int)
	minNum := math.MaxInt32

	for i := 0; i < n; i++ {
		fmt.Fscan(stdin, &x)
		// update distance
		if lastIdx, ok := lastIndexes[x]; ok {
			distance := i - lastIdx
			if lastDistance, ok := distances[x]; ok {
				if distance < lastDistance {
					distances[x] = distance
				}
			} else {
				distances[x] = distance
			}
		}
		// update last seen indexes
		lastIndexes[x] = i
		// update min num
		if x < minNum {
			minNum = x
		}
	}
	fmt.Println(distances[minNum])
}

package main

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

const max = 1000000000

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

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

	var (
		min = max + 1
		ans = n
		pos = 0
	)

	for i := 0; i < n; i++ {
		var v int
		fmt.Fscan(r, &v)
		if v > min {
			continue
		}
		if v < min {
			min = v
			ans = n
			pos = i
			continue
		}
		if d := i - pos; ans > d {
			ans = d
		}
		pos = i
	}
	fmt.Println(ans)
}

//	URL: http://codeforces.com/contest/911/problem/A
//	PROBLEM RESTATEMENT
//		Given an array of n integers.
//		The minimum element is guaranteed to occur twice.
//		Find the distance between the minimum elements.
//	APPROACH
//		Naive implementation problem - O(n) time.
//	NOTE
//		Scan is bad - too slow! Use bufio instead.

package main

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

func solve(n int, a []int) int {
	minElem := a[0]
	left := 0
	minDistance := 1000000
	for i := 1; i < n; i++ {
		if minElem == a[i] {
			if (i - left) < minDistance {
				minDistance = i - left
			}
			left = i
		} else if a[i] < minElem {
			minElem = a[i]
			left = i
			minDistance = 1000000
		}
	}
	return minDistance
}

func main() {
	var n int
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n)
	for i := range a {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fprintf(writer, "%d\n", solve(n, a))
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextInt64Array()

	dist := map[int]int{}
	lastIndex := map[int]int{}

	mnA := A[0]
	for i := 1; i < N; i++ {
		if mnA > A[i] {
			mnA = A[i]
		}
	}

	mn := N
	for i := 0; i < N; i++ {
		if A[i] != mnA {
			continue
		}
		a := int(A[i])
		if last, ok := lastIndex[a]; ok {
			v, ok2 := dist[a]
			d := i - last
			if !ok2 || d < v {
				dist[a] = d
				if dist[a] < mn {
					mn = dist[a]
				}
			}
		}
		lastIndex[a] = i
	}

	fmt.Println(mn)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
    "fmt"
)

func main() {
    var n, a, mi, i, ans int64
    var arr[100009] int64
    fmt.Scan(&n)
    mi = 10000000000
    a = 0
    ans = 10000000000
    for i = 0; i < n; i++ {
      fmt.Scan(&arr[i])
      if mi > arr[i] {
        mi = arr[i]
      }
    }
    //fmt.Println("min: ", mi)
    // for i = 0; i < n; i++ {
    //   fmt.Print(arr[i], " ")
    // }
    found := false
    for i = 0; i < n; i++ {
      if mi == arr[i] {
        //fmt.Println("Here", i)
        if ans > i-a && found == true {
          ans = i-a
        //  fmt.Println("ans on :", i)
        }
        a = i
        found = true
      }
    }
    fmt.Println(ans)
}

package main

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

func solve() {
	n := readInt()
	m := make(map[int][]int)
	xmin := -1
	for i := 0; i < n; i++ {
		a := readInt()
		if i == 0 {
			xmin = a
		} else {
			if a < xmin {
				xmin = a
			}
		}

		m[a] = append(m[a], i)
	}

	xxmin := 0
	for i := 1; i < len(m[xmin]); i++ {
		d := m[xmin][i] - m[xmin][i-1]
		if i == 1 {
			xxmin = d
		} else if d < xxmin {
			xxmin = d
		}
	}
	fmt.Println(xxmin)
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

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

package main

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

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

	fmt.Fscanf(in, "%d\n", &n)
	a := make([]uint, n)
	m := uint(math.MaxInt32)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
		if a[i] < m {
			m = a[i]
		}
	}
	d := math.MaxInt32
	lastMin := -1
	for i := 0; i < n; i++ {
		if a[i] == m {
			if lastMin >= 0 && i-lastMin < d {
				d = i - lastMin
			}
			lastMin = i
		}
	}
	fmt.Print(d)
}

package main

import (
	"fmt"
	"os"
)

const max = 100000

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)

	var (
		min = max + 1
		ans = n
		pos = 0
	)

	for i := 0; i < n; i++ {
		var v int
		fmt.Fscan(os.Stdin, &v)
		if v > min {
			continue
		}
		if v < min {
			min = v
			ans = n
			pos = i
			continue
		}
		if d := i - pos; ans > d {
			ans = d
		}
		pos = i
	}
	fmt.Println(ans)
}

//	URL: http://codeforces.com/contest/911/problem/A
//	PROBLEM RESTATEMENT
//		Given an array of n integers.
//		The minimum element is guaranteed to occur twice.
//		Find the distance between the minimum elements.
//	APPROACH
//		Naive implementation problem - O(n) time.

package main

import "fmt"

func solve(n int, a []int) int {
	minElem := a[0]
	left := 0
	minDistance := 1000000
	for i := 1; i < n; i++ {
		if minElem == a[i] {
			if (i - left) < minDistance {
				minDistance = i - left
			}
			left = i
		} else if a[i] < minElem {
			minElem = a[i]
			left = i
		}
	}
	return minDistance
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	fmt.Println(solve(n, a))
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	dist := map[int]int{}
	lastIndex := map[int]int{}
	mn := N
	for i := 0; i < N; i++ {
		a := A[i]
		if last, ok := lastIndex[a]; ok {
			v, ok2 := dist[a]
			if !ok2 || last-i < v {
				dist[a] = i - last
				if dist[a] < mn {
					mn = dist[a]
				}
			}
		}
		lastIndex[a] = i
	}

	fmt.Println(mn)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	dist := map[int]int{}
	lastIndex := map[int]int{}
	mn := N
	for i := 0; i < N; i++ {
		a := A[i]
		if last, ok := lastIndex[a]; ok {
			v, ok2 := dist[a]
			d := i - last
			if !ok2 || d < v {
				dist[a] = d
				if dist[a] < mn {
					mn = dist[a]
				}
			}
		}
		lastIndex[a] = i
	}

	fmt.Println(mn)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextInt64Array()

	dist := map[int]int{}
	lastIndex := map[int]int{}
	mn := N
	for i := 0; i < N; i++ {
		a := int(A[i])
		if last, ok := lastIndex[a]; ok {
			v, ok2 := dist[a]
			d := i - last
			if !ok2 || d < v {
				dist[a] = d
				if dist[a] < mn {
					mn = dist[a]
				}
			}
		}
		lastIndex[a] = i
	}

	fmt.Println(mn)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


// 271C
package main

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

func main() {
	var n, k int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &n, &k)
	if n < k*3 {
		fmt.Print(-1)
		return
	}
	for i := 0; i < k; i++ {
		fmt.Fprintf(out, "%d %d ", i+1, i+1)
	}
	a := 0
	for i := k * 2; i < n; i++ {
		fmt.Fprintf(out, "%d ", a+1)
		a++
		a %= k
	}
	out.Flush()
}

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

func main(){
	var n, k, i int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	j:= 1
	fmt.Fscan(in, &n, &k)
	if n<3*k {
		fmt.Print(-1)
		return
	}else{
		for i =1; i<=2*k; i+=2{
			fmt.Fprint(out, j, j, " ")
			j++
		}
		j = 1
		for ;i<=3*k;i++{
			fmt.Fprint(out, j, " ")
			j++
		}
		for ; i<=n;i++{
			fmt.Fprint(out, 1, " ")
		}
	}
		out.Flush()
	// your code goes here
}

// 271C
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	if n < k*3 {
		fmt.Print(-1)
	} else {
		for ; n > 0; n-- {
			fmt.Printf("%d ", ((n/k)%2+n)%k+1)
		}
	}
}

// 271C
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	if n < k*3 {
		fmt.Print(-1)
	} else {
		for ; n > 0; n-- {
			fmt.Print(((n/k)%2+n)%k + 1)
		}
	}
}

// 271C
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	if n < k*3 {
		fmt.Print(-1)
	} else {
		for ; n >= 0; n-- {
			fmt.Printf("%d ", ((n/k)%2+n)%k+1)
		}
	}
}

// 271C
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	if n < k*3 {
		fmt.Print(-1)
	} else {
		for ; n < 0; n++ {
			fmt.Printf("%d ", ((n/k)%2+n)%k+1)
		}
	}
}


package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

func sq(a int) int {
	return a * a
}

// ----------------------------- TEMPLATE END ----------------------------------

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var n int
		scan(&n)
		a := make([]int, n)
		b := make([]int, n)
		totalSum := 0
		for i := 0; i < n; i++ {
			scan(&a[i])
			totalSum += a[i]
		}
		for i := 0; i < n; i++ {
			scan(&b[i])
			totalSum += b[i]
		}

		dp := make([][]byte, n+1)
		for i := 0; i <= n; i++ {
			dp[i] = make([]byte, totalSum+1)
		}
		dp[n][0] = 1
		for i := n - 1; i >= 0; i-- {
			for j := totalSum; j >= 0; j-- {
				if dp[i+1][j] != 0 {
					dp[i][j+a[i]] = 'A'
					dp[i][j+b[i]] = 'B'
				}
			}
		}
		sumA := totalSum / 2
		for dp[0][sumA] == 0 {
			sumA--
		}
		for i := 0; i < n; i++ {
			if dp[i][sumA] == 'A' {
				sumA -= a[i]
			} else {
				sumA -= b[i]
				a[i], b[i] = b[i], a[i]
			}
		}

		ans := 0
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				ans += sq(a[i]+a[j]) + sq(b[i]+b[j])
			}
		}
		printf("%d\n", ans)
	}
}

package main

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

var (

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

func abs(a, b int) int {

	if a < b {

		return b - a
	}
	return a - b
}

func min(a, b int) int {

	if a < b {

		return a
	}

	return b
}

func solve(n int) {

	var (

		a []int
		b []int
		c = make([]bool, 10001)
		sumSquare = 0
		sum = 0
		sumAbs = 0
		absMin = 0
	)

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

		var x int
		fmt.Fscan(in, &x)
		a = append(a, x)
		sum += x
		sumSquare += x * x
	}

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

		var x int
		fmt.Fscan(in, &x)
		b = append(b, abs(x, a[i]))
		sum += x
		sumSquare += x * x
		sumAbs += b[i]
		absMin = sumAbs
	}

	if n <= 1 {

		fmt.Fprintln(out, 0)
		return
	}

	sort.Slice(b, func(i, j int) bool {

		return b[i] < b[j]
	})

	c[0] = true
	for i := 0; i < n; i++ {

		for j := 10000; j > 0; j-- {

			if j >= b[i] && c[j - b[i]] {

				c[j] = true
				absMin = min(absMin, abs(sumAbs, 2 * j))
			}
		}
	}

	fmt.Fprintln(out, sumSquare * (n - 2) + (sum * sum + absMin * absMin) / 2)
}

func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)
	for i := 0; i < T; i++ {

		var n int
		fmt.Fscan(in, &n)
		solve(n)
	}
}

package main

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

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

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

	casecnt, n := 0, 0
	Fscan(in, &casecnt)
	for ; casecnt > 0; casecnt-- {
		var ans uint64
		Fscan(in, &n)
		a, b, suf := make([]uint64, n), make([]uint64, n), make([]uint64, n+1)
		for i := range a {
			Fscan(in, &a[i])
			ans += uint64((n - 1)) * (a[i] * a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
			ans += uint64((n - 1)) * (b[i] * b[i])
		}
		for i := n - 1; i >= 0; i-- { //求后缀和(a，b数组)
			suf[n-i] = suf[n-i-1] + a[i] + b[i]
		}
		//(ai+aj)^2 = ai^2+2aiaj+aj^2
		//ai^2 + aj^2固定的，无论是否交换都是不变的
		//我们只要对2(ai)*(aj)求最小值即可，先求一半也就是(ai)*(aj)

		//dp数组dp[i][j]表示 数组前i个数(倒数)的后缀和为j时(指的是数组a的后缀和)，可以形成的最小权重和是多少(a+b的权重和)
		dp := [101][11000]uint64{}
		for i := range dp {
			for j := range dp[i] {
				dp[i][j] = math.MaxUint32
			}
		}
		dp[0][0] = 0
		for i := 1; i <= n; i++ {
			na, nb := uint64(a[n-i]), uint64(b[n-i])
			for j := uint64(0); j <= 10000; j++ {
				//对于一个元素要么调换位置要么不调换位置
				//不调换位置
				if j >= na {
					dp[i][j] = min(dp[i][j], dp[i-1][j-na]+na*(j-na)+nb*(suf[i-1]-(j-na)))
				}
				//调换位置
				if j >= nb {
					dp[i][j] = min(dp[i][j], dp[i-1][j-nb]+nb*(j-nb)+na*(suf[i-1]-(j-nb)))
				}
			}
		}
		tmp := uint64(math.MaxUint32)
		for i := range dp[n] {
			tmp = min(tmp, dp[n][i])
		}
		ans += 2 * tmp
		//计算结果
		Println(ans)
	}
}

func min(i, j uint64) uint64 {
	if i < j {
		return i
	}
	return j
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1637D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	abs := func(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans, maxW := 0, 0
		a := make([][2]int, n)
		for i := range a {
			Fscan(in, &a[i][0])
			ans += a[i][0] * a[i][0]
			maxW += a[i][0]
		}
		for i := range a {
			Fscan(in, &a[i][1])
			ans += a[i][1] * a[i][1]
			maxW += a[i][1]
		}
		if n == 1 {
			Fprintln(out, 0)
			continue
		}
		dp := make([]bool, maxW+1)
		dp[0] = true
		for _, g := range a {
		next:
			for j := maxW; j >= 0; j-- {
				for _, w := range g {
					if w <= j && dp[j-w] {
						dp[j] = true
						continue next
					}
				}
				dp[j] = false
			}
		}
		ans *= n - 2
		mi, miv := int(1e9), 0
		for v, b := range dp {
			if b {
				d := abs(maxW - 2*v)
				if d < mi {
					mi, miv = d, v
				}
			}
		}
		Fprintln(out, ans+miv*miv+(maxW-miv)*(maxW-miv))
	}
}

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

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans, maxW := 0, 0
		a := make([][2]int, n)
		for i := range a {
			Fscan(in, &a[i][0])
			ans += a[i][0] * a[i][0]
			maxW += a[i][0]
		}
		for i := range a {
			Fscan(in, &a[i][1])
			ans += a[i][1] * a[i][1]
			maxW += a[i][1]
		}
		if n == 1 {
			Fprintln(out, 0)
			continue
		}
		dp := make([]bool, maxW+1)
		dp[0] = true
		for _, g := range a {
		next:
			for j := maxW; j >= 0; j-- {
				for _, w := range g {
					if w <= j && dp[j-w] {
						dp[j] = true
						continue next
					}
				}
				dp[j] = false
			}
		}
		ans *= n - 2
		mi, miv := int(1e9), 0
		for v, b := range dp {
			if b {
				d := abs(maxW - 2*v)
				if d < mi {
					mi, miv = d, v
				}
			}
		}
		Fprintln(out, ans+miv*miv+(maxW-miv)*(maxW-miv))
	}
}

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

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

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

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

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans, maxW := 0, 0
		a := make([][2]int, n)
		for i := range a {
			Fscan(in, &a[i][0])
			ans += a[i][0] * a[i][0]
			maxW += a[i][0]
		}
		for i := range a {
			Fscan(in, &a[i][1])
			ans += a[i][1] * a[i][1]
			maxW += a[i][1]
		}
		if n == 1 {
			Fprintln(out, 0)
			continue
		}
		dp := make([]int, maxW+1)
		for _, g := range a {
			for j := maxW; j > 0; j-- {
				for _, v := range g {
					if v <= j {
						dp[j] = max(dp[j], dp[j-v]+1)
					}
				}
			}
		}
		ans *= n - 2
		mi, miv := int(1e9), 0
		for v, c := range dp {
			if c == n {
				d := abs(maxW - 2*v)
				if d < mi {
					mi, miv = d, v
				}
			}
		}
		Fprintln(out, ans+miv*miv+(maxW-miv)*(maxW-miv))
	}
}

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

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

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

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

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		sa, sb := 0, 0
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			sa += a[i]
		}
		b := make([]int, n)
		for i := range b {
			Fscan(in, &b[i])
			sb += b[i]
		}
		for {
			minD := int(1e9)
			p := -1
			for i, v := range a {
				w := b[i]
				if v == w {
					continue
				}
				if v > w {
					if sa-v > sb-w {
						d := abs(sa - sb - (v-w)*2)
						if d < minD {
							minD, p = d, i
						}
					}
				} else {
					if sa-v < sb-w {
						d := abs(sb - sa - (w-v)*2)
						if d < minD {
							minD, p = d, i
						}
					}
				}
			}
			if p < 0 {
				break
			}
			v, w := a[p], b[p]
			sa += w - v
			sb += v - w
			a[p], b[p] = w, v
		}

		ans := 0
		for i, v := range a {
			for j, w := range a[:i] {
				ans += (v+w)*(v+w) + (b[i]+b[j])*(b[i]+b[j])
			}
		}
		Fprintln(out, ans)
	}
}

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

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

package main

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

var (

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

func abs(a, b int) int {

	if a < b {

		return b - a
	}
	return a - b
}

func min(a, b int) int {

	if a < b {

		return a
	}

	return b
}

func solve(n int) {

	var (

		a []int
		b []int
		c = make([][]bool, n + 1)
		sumSquare = 0
		sum = 0
		sumAbs = 0
		absMin = 0
	)
	c[0] = make([]bool, 10001)
	for i := 0; i < n; i++ {

		var x int
		fmt.Fscan(in, &x)
		a = append(a, x)
		sum += x
		sumSquare += x * x
		c[i + 1] = make([]bool, 10001)
	}

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

		var x int
		fmt.Fscan(in, &x)
		b = append(b, abs(x, a[i]))
		sum += x
		sumSquare += x * x
		sumAbs += b[i]
		absMin = sumAbs
	}

	if n <= 1 {

		fmt.Fprintln(out, 0)
		return
	}

	sort.Slice(b, func(i, j int) bool {

		return b[i] < b[j]
	})

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

		c[i][0] = true
	}

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

		for j := 0; j < n; j++ {

			if i >= b[j] && c[j][i - b[j]] {

				c[j + 1][i] = true
				absMin = min(absMin, abs(sumAbs, 2 * i))
			}
		}
	}

	fmt.Fprintln(out, sumSquare * (n - 2) + (sum * sum + absMin * absMin) / 2)
}

func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)
	for i := 0; i < T; i++ {

		var n int
		fmt.Fscan(in, &n)
		solve(n)
	}
}

package main

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

var (

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

func abs(a, b int) int {

	if a < b {

		return b - a
	}
	return a - b
}

func min(a, b int) int {

	if a < b {

		return a
	}

	return b
}

func solve(n int) {

	var (

		a []int
		b []int
		c = make([]bool, 10001)
		sumSquare = 0
		sum = 0
		sumAbs = 0
		absMin = 0
	)

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

		var x int
		fmt.Fscan(in, &x)
		a = append(a, x)
		sum += x
		sumSquare += x * x
	}

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

		var x int
		fmt.Fscan(in, &x)
		b = append(b, abs(x, a[i]))
		sum += x
		sumSquare += x * x
		sumAbs += b[i]
		absMin = sumAbs
	}

	if n <= 1 {

		fmt.Fprintln(out, 0)
		return
	}

	sort.Slice(b, func(i, j int) bool {

		return b[i] < b[j]
	})

	c[0] = true
	for i := 1; i < 10001; i++ {

		c[i] = false
		for j := 0; j < n; j++ {

			if i >= b[j] && c[i - b[j]] {

				c[i] = true
				absMin = min(absMin, abs(sumAbs, 2 * i))
			}
		}
	}

	fmt.Fprintln(out, sumSquare * (n - 2) + (sum * sum + absMin * absMin) / 2)
}

func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)
	for i := 0; i < T; i++ {

		var n int
		fmt.Fscan(in, &n)
		solve(n)
	}
}


package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
    "sort"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }
    sort.Ints(a)
    var sum int64
    var l int64
    for i := n - 1; i > 0; i-- {
        if l == 0 && a[i] - a[i - 1] < 2 {
            l = int64(a[i - 1])
            i--
        } else if l != 0 && a[i] - a[i - 1] < 2 {
            sum += l * int64(a[i - 1])
            i--
            l = 0
        }
    }
    fmt.Fprintln(out, sum)
}

package main

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

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

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

	n := nextInt()
	sticks := make([]int64, 1000001)
	var area, last int64 = 0, -1

	for i := 0; i < n; i++ {
		sticks[nextInt()]++
	}

	for i := int64(len(sticks)-1); i > 0; i-- {
		if sticks[i] == 0 {
			continue
		} else if sticks[i]%2 != 0 {
			sticks[i]--

			if sticks[i-1] > 0 {
				sticks[i-1]++
			}
		}

		// println(i, sticks[i], area, last)
		if sticks[i] >= 2 && last != -1 {
			area += i*last
			last = -1
			sticks[i] -= 2
		}

		area += sticks[i]/4*i*i
		sticks[i] %= 4

		if sticks[i] > 0 {
			last = i
		}
		// println(i, sticks[i], area, last)
	}

	println(area)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

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

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

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

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

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


package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    sort.Ints(a)
    if k > n {
        fmt.Println(-1)
    } else {
        fmt.Println(a[len(a)-k],a[len(a)-k])
    }
}

// 263B
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	a := make([]int, 55)
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	x := len(a)
	if k <= n {
		fmt.Printf("%d %d\n", a[x-k], a[x-k])
	} else {
		fmt.Println(-1)
	}
}

// 263B-mic
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    sort.Sort(sort.IntSlice(a))
    var idx int
    idx = n - k
    if idx >= 0 {
        fmt.Print(a[idx])
        fmt.Print(" ")
        fmt.Print(a[idx])
        fmt.Println()
    } else {
        fmt.Println("-1")
    }
}

package main
import (
	"fmt"
	//"unicode/utf8"
	//"strconv"
	"sort"
)

func main() {
	var n,k int
	fmt.Scan(&n,&k)
	a := make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	if k>n {
		fmt.Println("-1")
	} else {
		fmt.Printf("%d 0",a[n-k])
	}
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,z int
    fmt.Scan(&n,&z)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    sort.Ints(a)
    if z > n {
        fmt.Println(-1)
    } else {
        y:=a[len(a)-z]
        x:=a[len(a)-z]
        fmt.Println(y,x)

    }
}

// 263B-mic
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.IntSlice(a))
	fmt.Println(a)
	var idx int
	idx = n - k
	fmt.Println(idx)
	if idx >= 0 {
		fmt.Print(a[idx])
		fmt.Print(" ")
		fmt.Print(a[idx])
		fmt.Println()
	} else {
		fmt.Println("-1")
	}
}

// 263B-mic
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(a[i])
    }
    sort.Sort(sort.IntSlice(a))

    var idx int
    idx = n - k
    if idx >= 0 {
        fmt.Print(a[idx])
        fmt.Print(" ")
        fmt.Print(a[idx])
        fmt.Println()
    } else {
        fmt.Println("-1")
    }
}


package main

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

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

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

	n := nextInt()
	isFirstWin, isSecondPerform := true, false
	var point1, point2, a int64 = 0, 0, 0
	// seq1, seq2 := make([]rune,0), make([]rune, 0)
	v1, v2 := make([]int64, 0), make([]int64, 0)
	for i := 0; i < n; i++ {
		a = nextInt64()

		if i == n - 1 && a < 0 {
			 isSecondPerform = true
		}

		if a > 0 {
			point1 += a
			v1 = append(v1, a)
			// seq1 = append(seq1, []rune(strconv.FormatInt(a, 10))...)
		} else {
			a = -a
			point2 += a
			v2 = append(v2, a)
			// seq2 = append(seq2, []rune(strconv.FormatInt(a, 10))...)
		}
	}

	if point1 < point2 {
		isFirstWin = false
	} else if point1 == point2 {
		// if string(seq1) < string(seq2) {
		// 	isFirstWin = false
		// } else if string(seq1) == string(seq2) && isSecondPerform {
		// 	isFirstWin = false
		// }
		minLen := len(v1)

		if len(v1) > len(v2) {
			minLen = len(v2)
		}

		i := 0

		for ; i < minLen; i++ {
			if v1[i] < v2[i] {
				isFirstWin = false
				break
			} else if v1[i] > v2[i] {
				isFirstWin = true
				break
			}
		}

		if i == minLen {
			if len(v1) < len(v2) {
				isFirstWin = false
			} else if len(v1) == len(v2) {
				if isSecondPerform {
					isFirstWin = false
				}
			}
		}
	}
	// println(string(seq1) < string(seq2))
	if isFirstWin {
		println("first")
	} else {
		println("second")
	}

	// println(point1, point2)
	// println(string(seq1), string(seq2))
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64() int64 {
	n, err := strconv.ParseInt(next(), 0, 64)
	if err != nil {
		panic(err)
	}

	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

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

// Input & Output
var (
	input  = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

var (
	n                                       int
	p1                                      []int64
	p2                                      []int64
	len1                                    int
	len2                                    int
	score_winner, order_winner, last_winner int
	result                                  int
)

func in() {
	fmt.Fscan(input, &n)
	p1 = make([]int64, n)
	p2 = make([]int64, n)
	len1, len2 = 0, 0
	var s int64
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &s)
		var p *[]int64
		var l *int
		if i == n-1 { // last point
			if s > 0 {
				last_winner = 1
			} else {
				last_winner = 2
			}
		}
		if s > 0 {
			p = &p1
			l = &len1
		} else {
			p = &p2
			l = &len2
			s *= -1
		}
		(*p)[*l] = s
		*l += 1
	}
}

func out() {
	var winner int
	if score_winner > 0 {
		winner = score_winner
	} else if order_winner > 0 {
		winner = order_winner
	} else {
		winner = last_winner
	}
	if winner == 1 {
		fmt.Fprintln(output, "first")
	} else {
		fmt.Fprintln(output, "second")
	}
	defer output.Flush()
}

func run() {
	var l int
	if len1 > len2 {
		l = len1
	} else {
		l = len2
	}
	var s1, s2 int64 = 0, 0
	for i := 0; i < l; i++ {
		s1 += p1[i]
		s2 += p2[i]
		if order_winner == 0 && p1[i] > p2[i] {
			order_winner = 1
		} else if order_winner == 0 && p2[i] > p1[i] {
			order_winner = 2
		}
	}
	if s1 > s2 {
		score_winner = 1
	} else if s2 > s1 {
		score_winner = 2
	}
}

func main() {
	in()
	run()
	out()
}

package main

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

var readWriter = bufio.NewReadWriter(
	bufio.NewReader(os.Stdin),
	bufio.NewWriter(os.Stdout))

func sum(a []int64) (b int64) {
	for i := 0; i < len(a); i++ {
		b += a[i]
	}
	return
}

func lexicographyCompare(a, b []int64) int {
	var n int

	if len(a) > len(b) {
		n = len(b)
	} else {
		n = len(a)
	}

	for i := 0; i < n; i++ {
		if a[i] > b[i] {
			return 1
		} else if a[i] < b[i] {
			return -1
		}
	}

	return 0
}

func main() {
	defer readWriter.Flush()

	var n int
	var a int64
	var xs, ys []int64
	var last string

	const FIRST, SECOND string = "first", "second"

	fmt.Fscan(readWriter, &n)

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &a)

		if a > 0 {
			xs = append(xs, a)
		} else {
			ys = append(ys, -a)
		}
	}

	if a > 0 {
		last = FIRST
	} else {
		last = SECOND
	}

	if sum(xs) > sum(ys) {
		fmt.Fprintln(readWriter, FIRST)
	} else if sum(xs) < sum(ys) {
		fmt.Fprintln(readWriter, SECOND)
	} else {
		result := lexicographyCompare(xs, ys)
		if result > 0 {
			fmt.Fprintln(readWriter, FIRST)
		} else if result < 0 {
			fmt.Fprintln(readWriter, SECOND)
		} else {
			fmt.Fprintln(readWriter, last)
		}
	}
}

package main

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

var readWriter = bufio.NewReadWriter(
	bufio.NewReader(os.Stdin),
	bufio.NewWriter(os.Stdout))

func sum(a []int64) (b int64) {
	for i := 0; i < len(a); i++ {
		b += a[i]
	}
	return
}

func lexicographyCompare(a, b []int64) int {
	var n int

	if len(a) > len(b) {
		n = len(b)
	} else {
		n = len(a)
	}

	for i := 0; i < n; i++ {
		if a[i] > b[i] {
			return 1
		} else if a[i] < b[i] {
			return -1
		}
	}

	return 0
}

func main() {
	defer readWriter.Flush()

	var n int
	var a int64
	var xs, ys []int64
	var last string

	const FIRST, SECOND string = "first", "second"

	fmt.Fscan(readWriter, &n)

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &a)

		if a > 0 {
			xs = append(xs, a)
		} else {
			ys = append(ys, -a)
		}
	}

	if a > 0 {
		last = FIRST
	} else {
		last = SECOND
	}

	var sumOfXs, sumOfYs int64 = sum(xs), sum(ys)

	if sumOfXs > sumOfYs {
		fmt.Fprintln(readWriter, FIRST)
	} else if sumOfXs < sumOfYs {
		fmt.Fprintln(readWriter, SECOND)
	} else {
		result := lexicographyCompare(xs, ys)
		if result > 0 {
			fmt.Fprintln(readWriter, FIRST)
		} else if result < 0 {
			fmt.Fprintln(readWriter, SECOND)
		} else {
			fmt.Fprintln(readWriter, last)
		}
	}
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	var t [200010]int64 // techniques
	for i := 0; i < n; i++ {
		t[i] = nextLong()
	}

	a, b := make([]int64, 0, 200010), make([]int64, 0, 200010)
	for i := 0; i < n; i++ {
		if t[i] > 0 {
			a = append(a, t[i])
		} else {
			b = append(b, -t[i])
		}
	}

	sameSequence := func(x, y []int64) bool {
		n := len(x)
		if n != len(y) {
			return false
		}
		for i := 0; i < n; i++ {
			if x[i] != y[i] {
				return false
			}
		}
		return true
	}

	if sameSequence(a, b) {
		if t[n-1] > 0 {
			fmt.Println("first")
		} else {
			fmt.Println("second")
		}
		return
	}

	sum := func(x []int64) (z int64) {
		n := len(x)
		for i := 0; i < n; i++ {
			z += x[i]
		}
		return
	}

	if sum(a) == sum(b) {
		i, n, m := 0, len(a), len(b)
		for {
			switch {
			case i >= m:
				fmt.Println("first")
				return
			case i >= n:
				fmt.Println("second")
				return
			case a[i] > b[i]:
				fmt.Println("first")
				return
			case a[i] < b[i]:
				fmt.Println("second")
				return
			default:
				i++
			}
		}
	}

	if sum(a) > sum(b) {
		fmt.Println("first")
	} else {
		fmt.Println("second")
	}
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, 0)
    b := make([]int, 0)
    var suma int64
    var sumb int64
    latest := 0
    for i := 0; i < n; i++ {
        x := nextInt()
        if (x > 0) {
            a = append(a, x)
            suma += int64(x)
            latest = 1
        } else {
            b = append(b, -x)
            sumb += int64(-x)
            latest = 2
        }
    }

    if suma > sumb {
        fmt.Fprintln(out, "first")
    } else if suma < sumb {
        fmt.Fprintln(out, "second")
    } else {
        n = len(a)
        if n > len(b) {
            n = len(b)
        }
        for i := 0; i < n; i++ {
            if a[i] > b[i] {
                fmt.Fprintln(out, "first")
                return
            } else if a[i] < b[i] {
                fmt.Fprintln(out, "second")
                return
            }
        }
        if latest == 1 {
            fmt.Fprintln(out, "first")
        } else {
            fmt.Fprintln(out, "second")
        }
    }
}

package main

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

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

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

	n := nextInt()
	isFirstWin, isSecondPerform := true, false
	var point1, point2, a int64 = 0, 0, 0
	seq1, seq2 := make([]rune,0), make([]rune, 0)

	for i := 0; i < n; i++ {
		a = nextInt64()

		if i == n - 1 && a < 0 {
			 isSecondPerform = true
		}

		if a > 0 {
			point1 += a

			seq1 = append(seq1, []rune(strconv.FormatInt(a, 10))...)
		} else {
			a = -a

			point2 += a
			seq2 = append(seq2, []rune(strconv.FormatInt(a, 10))...)
		}
	}

	if point1 < point2 {
		isFirstWin = false
	} else if point1 == point2 {
		if string(seq1) < string(seq2) {
			isFirstWin = false
		} else if string(seq1) == string(seq2) && isSecondPerform {
			isFirstWin = false
		}
	}

	if isFirstWin {
		println("first")
	} else {
		println("second")
	}

	// println(point1, point2)
	// println(string(seq1), string(seq2))
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64() int64 {
	n, err := strconv.ParseInt(next(), 0, 64)
	if err != nil {
		panic(err)
	}

	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

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

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

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

	n := nextInt()
	isFirstWin, isSecondPerform := true, false
	var point1, point2, a int64 = 0, 0, 0
	seq1, seq2 := make([]rune,0), make([]rune, 0)

	for i := 0; i < n; i++ {
		a = nextInt64()

		if i == n - 1 && a < 0 {
			 isSecondPerform = true
		}

		if a > 0 {
			point1 += a

			seq1 = append(seq1, []rune(strconv.FormatInt(a, 10))...)
		} else {
			a = -a

			point2 += a
			seq2 = append(seq2, []rune(strconv.FormatInt(a, 10))...)
		}
	}

	if point1 < point2 {
		isFirstWin = false
	} else if point1 == point2 {
		if string(seq1) > string(seq2) {
			isFirstWin = false
		} else if string(seq1) == string(seq2) && isSecondPerform {
			isFirstWin = false
		}
	}
	// println(string(seq1) > string(seq2))
	if isFirstWin {
		println("first")
	} else {
		println("second")
	}

	// println(point1, point2)
	// println(string(seq1), string(seq2))
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64() int64 {
	n, err := strconv.ParseInt(next(), 0, 64)
	if err != nil {
		panic(err)
	}

	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

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

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

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

	n := nextInt()
	isFirstWin, isSecondPerform := true, false
	var point1, point2, a int64 = 0, 0, 0
	seq1, seq2 := make([]rune,0), make([]rune, 0)

	for i := 0; i < n; i++ {
		a = nextInt64()

		if i == n - 1 && a < 0 {
			 isSecondPerform = true
		}

		if a > 0 {
			point1 += a

			seq1 = append(seq1, []rune(strconv.FormatInt(a, 10))...)
		} else {
			a = -a

			point2 += a
			seq2 = append(seq2, []rune(strconv.FormatInt(a, 10))...)
		}
	}

	if point1 < point2 {
		isFirstWin = false
	} else if point1 == point2 {
		if string(seq1) < string(seq2) {
			isFirstWin = false
		} else if string(seq1) == string(seq2) && isSecondPerform {
			isFirstWin = false
		}
	}
	// println(string(seq1) > string(seq2))
	if isFirstWin {
		println("first")
	} else {
		println("second")
	}

	// println(point1, point2)
	// println(string(seq1), string(seq2))
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64() int64 {
	n, err := strconv.ParseInt(next(), 0, 64)
	if err != nil {
		panic(err)
	}

	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

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

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

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

	n := nextInt()
	isFirstWin := true
	var point1, point2, a int64 = 0, 0, 0
	seq1, seq2 := make([]rune,0), make([]rune, 0)

	for i := 0; i < n; i++ {
		a = nextInt64()

		if i == n - 1 && a < 0 {
			 isFirstWin = false
		}

		if a > 0 {
			point1 += a

			seq1 = append(seq1, []rune(strconv.FormatInt(a, 10))...)
		} else {
			a = -a

			point2 += a
			seq2 = append(seq2, []rune(strconv.FormatInt(a, 10))...)
		}
	}

	if point1 < point2 {
		isFirstWin = false
	} else if point1 == point2 {
		if string(seq1) < string(seq2) {
			isFirstWin = false
		}
	}

	if isFirstWin {
		println("first")
	} else {
		println("second")
	}

	// println(point1, point2)
	// println(string(seq1), string(seq2))
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64() int64 {
	n, err := strconv.ParseInt(next(), 0, 64)
	if err != nil {
		panic(err)
	}

	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	var t [200010]int // techniques
	for i := 0; i < n; i++ {
		t[i] = nextInt()
	}

	a, b := make([]int, 0, 200010), make([]int, 0, 200010)
	for i := 0; i < n; i++ {
		if t[i] > 0 {
			a = append(a, t[i])
		} else {
			b = append(b, -t[i])
		}
	}

	sameSequence := func(x, y []int) bool {
		n := len(x)
		if n != len(y) {
			return false
		}
		for i := 0; i < n; i++ {
			if x[i] != y[i] {
				return false
			}
		}
		return true
	}

	if sameSequence(a, b) {
		if t[n-1] > 0 {
			fmt.Println("first")
		} else {
			fmt.Println("second")
		}
		return
	}

	sum := func(x []int) (z int) {
		n := len(x)
		for i := 0; i < n; i++ {
			z += x[i]
		}
		return
	}

	if sum(a) == sum(b) {
		i, n, m := 0, len(a), len(b)
		for {
			switch {
			case i >= m:
				fmt.Println("first")
				return
			case i >= n:
				fmt.Println("second")
				return
			case a[i] > b[i]:
				fmt.Println("first")
				return
			case a[i] < b[i]:
				fmt.Println("second")
				return
			default:
				i++
			}
		}
	}

	if sum(a) > sum(b) {
		fmt.Println("first")
	} else {
		fmt.Println("second")
	}
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, 0)
    b := make([]int, 0)
    suma := 0
    sumb := 0
    latest := 0
    for i := 0; i < n; i++ {
        x := nextInt()
        if (x > 0) {
            a = append(a, x)
            suma += x
            latest = 1
        } else {
            b = append(b, -x)
            sumb += -x
            latest = 2
        }
    }

    if suma > sumb {
        fmt.Fprintln(out, "first")
    } else if suma < sumb {
        fmt.Fprintln(out, "second")
    } else {
        n = len(a)
        if n > len(b) {
            n = len(b)
        }
        for i := 0; i < n; i++ {
            if a[i] > b[i] {
                fmt.Fprintln(out, "first")
                return
            } else if a[i] < b[i] {
                fmt.Fprintln(out, "second")
                return
            }
        }
        if latest == 1 {
            fmt.Fprintln(out, "first")
        } else {
            fmt.Fprintln(out, "second")
        }
    }
}


package main

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

func solve(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	for Fscan(in, &n); n > 0; n-- {
		var l, r int64
		Fscan(in, &l, &r)
		if l-r == 1 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}
}

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

package main
import "fmt"
import "os"
func main(){
    var n int64
    var a int64
    var b int64
    fmt.Fscan(os.Stdin, &n)
    var i int64 = 1
    for i <= n {
      fmt.Fscan(os.Stdin, &a, &b)
      if((a - b) > 1){
        fmt.Println("YES")
      } else {
        fmt.Println("NO")
      }
      i ++
    }
 }

package main

import (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

func solve() {

	t := readInt()

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

}

func solveOne() {

	x, y := readInt64(), readInt64()

	if x-y == 1 {
		print("NO")
	} else {
		print("YES")
	}

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

import "fmt"

func main() {
	var q, x, y int64
	fmt.Scan(&q)
	for ; q > 0; q-- {
		fmt.Scan(&x, &y)
		if x-y == 1 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

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.Fscanf(in, "%d\n", &t)

	for i := 0; i < t; i++ {
		x, y := int64(0), int64(0)
		// fmt.Fscanf(in, "%d\n", &x)
		// fmt.Fscanf(in, "%d\n", &y)
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		if x-y > 1 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}

	return

}

// package main

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

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

// package main

// import (
// 	"fmt"
// 	"os"
// )

// func main() {
// 	var n int
// 	fmt.Fscan(os.Stdin, &n)

// 	for i := 0; i < n; i++ {
// 		var beg, end int
// 		fmt.Fscan(os.Stdin, &end)
// 		fmt.Fscan(os.Stdin, &beg)
// 		if end-beg > 1 {
// 			fmt.Println("YES")
// 		} else {
// 			fmt.Println("NO")
// 		}
// 	}

// }

package main

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

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

package main

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

func parseInt(s string) int64 {
    tTemp, err := strconv.ParseInt(s, 10, 64)
    checkError(err)
    return int64(tTemp)
}

func primeFactor(p int64) bool {
    return p > 1
}

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

    t := parseInt(readLine(reader))

    for tItr := 0; tItr < int(t); tItr++ {
        qTemp := strings.Split(readLine(reader), " ")

        x := parseInt(qTemp[0])
        y := parseInt(qTemp[1])

        s := "YES"
        if !primeFactor(x - y) {
            s = "NO"
        }

        fmt.Println(s)
    }
}

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

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

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

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

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

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

//str := PrintlnInts(X...)

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		x, y := ReadInt2_64()
		if x-y != 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

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

func readInt_64() int64 {
	return readIntNbits(64)
}

func ReadInt2_64() (int64, int64) {
	return readInt_64(), readInt_64()
}

func ReadInt3_64() (int64, int64, int64) {
	return readInt_64(), readInt_64(), readInt_64()
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	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
}

// 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())
}

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(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)
}

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

// 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
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// 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
}

// 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
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

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

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

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(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 := PowInt(a, halfE)
		return half * half
	}

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

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

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		x, y := ReadInt64_2()

		if x-y >= 2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

var YESNO = map[bool]string{
	false: "NO",
	true:  "YES",
}

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		x := readll()
		y := readll()
		println(YESNO[solve(x, y)])
	}
}

func solve(x, y int64) bool {
	return x-y != 1
}

package main

import "fmt"

func main(){
	var t,x,y int64
	fmt.Scanf("%d\n",&t)
	for t>0 {
		t--
		fmt.Scanf("%d %d\n",&x,&y)
		if x > y + 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

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

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

func main(){
	var q int
	fmt.Scanln(&q)
	for i:= 0;i < q ; i++ {
		var x, y int64
		fmt.Scanln(&x, &y)
		if x - y > 1{
			fmt.Println("YES")
		} else{
			fmt.Println("NO")
		}
	}
}

package main
import  "fmt"
func main(){
    var n int64
    var a int64
    var b int64
    fmt.Scanf("%d", &n)
    var i int64 = 1
    for i <= n {
      fmt.Scanf("%d %d", &a, &b)
      if((a - b) > 1){
        fmt.Println("YES")
      } else {
        fmt.Println("NO")
      }
      i ++
    }
 }

package main
import  "fmt"
func main(){
    var n int64
    var a int64
    var b int64
    fmt.Scanf("%d", &n)
    fmt.Scanf("%d %d", &a, &b)
    var i int64 = 1
    for i <= n {
      fmt.Scanf("%d %d", &a, &b)
      if((a - b) > 1){
        fmt.Println("YES")
      } else {
        fmt.Println("NO")
      }
      i ++
    }
 }

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.Fscanf(in, "%d\n", &t)

	for i := 0; i < t; i++ {
		var beg, end int64
		fmt.Fscanf(in, "%d\n", &end)
		fmt.Fscanf(in, "%d\n", &beg)

		if end-beg > 1 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}

}

// package main

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

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

package main

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

type pair struct {
	beg int
	end int
}

func primeNumGenerator(limit int) []int {

	var arr []int

	for i := 1; i <= limit; i++ {
		j := int64(i)
		if big.NewInt(j).ProbablyPrime(0) {
			arr = append(arr, i)
		}
	}

	return arr
}

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)

	var arr []pair

	for i := 0; i < n; i++ {
		var beg, end int
		fmt.Fscan(os.Stdin, &end)
		fmt.Fscan(os.Stdin, &beg)
		arr = append(arr, pair{beg, end})
	}

	primes := primeNumGenerator(10000)

	for _, d := range arr {
		diff := d.end - d.beg

		is := false
		for _, i := range primes {
			is = false
			if diff%i == 0 {
				fmt.Println("YES")
				is = true
				break
			}
		}
		if !is {
			fmt.Println("NO")
		}
	}

}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)

	for i := 0; i < n; i++ {
		var beg, end int
		fmt.Fscan(os.Stdin, &end)
		fmt.Fscan(os.Stdin, &beg)
		if end-beg > 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

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.Fscanf(in, "%d\n", &t)

	for i := 0; i < t; i++ {
		var beg, end int
		fmt.Fscanf(in, "%d\n", &end)
		fmt.Fscanf(in, "%d\n", &beg)

		if end-beg > 1 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}

}

// package main

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

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

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.Fscanf(in, "%d\n", &t)

	for i := 0; i < t; i++ {
		x, y := int64(0), int64(0)
		fmt.Fscanf(in, "%d\n", &x)
		fmt.Fscanf(in, "%d\n", &y)

		if x-y > 1 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}

}

// package main

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

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

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.Fscanf(in, "%d\n", &t)

	for i := 0; i < t; i++ {
		x, y := int64(0), int64(0)
		// fmt.Fscanf(in, "%d\n", &x)
		// fmt.Fscanf(in, "%d\n", &y)
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		if x-y > 1 {
			fmt.Println(x - y)
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}

	return

}

// package main

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

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

package main

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

type pair struct {
	beg int
	end int
}

func primeNumGenerator(limit int) []int {

	var arr []int

	for i := 1; i <= limit; i++ {
		j := int64(i)
		if big.NewInt(j).ProbablyPrime(0) {
			arr = append(arr, i)
		}
	}

	return arr
}

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)

	var arr []pair

	for i := 0; i < n; i++ {
		var beg, end int
		fmt.Fscan(os.Stdin, &end)
		fmt.Fscan(os.Stdin, &beg)
		arr = append(arr, pair{beg, end})
	}

	primes := primeNumGenerator(10000)

	for _, d := range arr {
		diff := d.end - d.beg

		is := false
		for _, i := range primes {
			if diff%i == 0 {
				fmt.Println("YES")
				is = true
				break
			}
		}
		if !is {
			fmt.Println("NO")
		}
	}

}

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

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

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

//str := PrintlnInts(X...)

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		x, y := ReadInt2_64()
		if x-y == 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

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

func readInt_64() int64 {
	return readIntNbits(64)
}

func ReadInt2_64() (int64, int64) {
	return readInt_64(), readInt_64()
}

func ReadInt3_64() (int64, int64, int64) {
	return readInt_64(), readInt_64(), readInt_64()
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	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
}

// 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())
}

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(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)
}

package main

import "fmt"

func main(){
	var t,x,y int64
	fmt.Scanf("%d",&t)
	for t>0 {
		t--
		fmt.Scanf("%d %d",&x,&y)
		if x > y + 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}