package main

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

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

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

		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		b := make([]int, n)
		var z int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &b[i])
			if a[i]-b[i] > z {
				z = a[i] - b[i]
			}
		}

		f := true
		for i := 0; i < n; i++ {
			if a[i]-b[i] < 0 {
				f = false
				break
			} else if b[i] > 0 && a[i]-b[i] != z {
				f = false
				break
			} else if b[i] == 0 && a[i] > z {
				f = false
				break
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

/*
4
1
5
2
2
2 1
2 4
3
3 2 5
5 2 0
4
2 4 5 1
0 2 3 0
---
YES
NO
NO
YES
*/

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

	a := make([]int, n)

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

	b := make([]int, n)
	d := make([]int, n)

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

	maxD := max(d...)

	for i := range a {
		a[i] -= maxD
		if a[i] < 0 {
			a[i] = 0
		}
	}

	for i := range a {
		if a[i] != b[i] {
			fmt.Fprintln(writer, "NO")
			return
		}

		if d[i] < 0 {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	fmt.Fprintln(writer, "YES")
}

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

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

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

const maxUint = ^uint(0)

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

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

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

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

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

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

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

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

	return minNumIdx
}

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

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

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

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

// This example demonstrates an integer heap built using the heap interface.

// An IntHeap is a min-heap of ints.
/* type IntHeap []int64

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

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

// // This example inserts several ints into an Int, checks the minimum,
// // and removes them in order of priority.
// func main() {
// 	h := &IntHeap{2, 1, 5}
// 	heap.Init(h)
// 	heap.Push(h, 3)
// 	fmt.Printf("minimum: %d\n", (*h)[0])
// 	for h.Len() > 0 {
// 		fmt.Printf("%d ", heap.Pop(h))
// 	}
// }
type st struct {
	v  int
	id int
}

func A2() {
	_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 int
		Fscan(in, &n)
		a := make([]int, n)
		b := make([]int, n)

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		mx := 0
		for i := 0; i < n; i++ {
			Fscan(in, &b[i])
			if a[i]-b[i] > mx {
				mx = a[i] - b[i]
			}
		}
		for i := 0; i < n; i++ {
			if b[i] > a[i] {
				Fprintln(out, "No")
				return
			}
		}
		for i := 0; i < n; i++ {
			if a[i]-b[i] < mx && b[i] != 0 {
				Fprintln(out, "No")
				return
			}
		}
		Fprintln(out, "Yes")
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A2() }

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list1:= make([]int,n)
		list2:= make([]int,n)
		largest:=0
		smallest:=999999999
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list1[j])
			if list1[j] >= largest {
				largest=list1[j]
			}
			if list1[j] <= smallest{
				smallest=list1[j]
			}

		}
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list2[j])
		}
		difference:=0
		for j:=0;j<n;j++{
			if list1[j] == largest {
				difference= list1[j]-list2[j]
				break
			}
		}
		for j:=0;j<n;j++{
			if list1[j]-list2[j] != difference || difference < 0 {
				if list1[j]-list2[j] < difference && list2[j] == 0 {
					continue
				}
				fmt.Fprintln(out,"NO")
				goto out
			}
		}
		fmt.Fprintln(out,"YES")
		out:
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int64, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt64()
		}
		diff := int64(-1)
		ans := true
		b := make([]int64, n)
		for i := 0; i < n; i++ {
			b[i] = in.NextInt64()
			if a[i] >= b[i] {
				diff = int64(math.Max(float64(a[i])-float64(b[i]), float64(diff)))
			}
		}

		for i := 0; i < n; i++ {
			if a[i] < b[i] {
				ans = false
			} else if a[i]-diff < 0 && b[i] == 0 {
				continue
			} else if a[i]-diff == b[i] {
				continue
			} else {
				ans = false
			}

		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")

		}

	}
}

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

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

package main

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

const (
	MaxInt32 = 1 << 31 - 1
)

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

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

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(cin, &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &b[i])
		}
		m := map[int]bool{}
		ok := true
		zerodiff := 0
		for i := 0; i < n; i++ {
			if b[i] > 0 {
				if a[i] - b[i] < 0 {
					ok = false
					break
				}
				m[a[i] - b[i]] = true
			}else {
				zerodiff = Max(zerodiff, a[i] - b[i])
			}
		}

		if len(m) > 1 || !ok {
			fmt.Println("NO")
		}else {
			if len(m) == 0 {
				fmt.Println("YES")
			}else {
				for k, _ := range m {
					if zerodiff > k {
						fmt.Println("NO")
					}else {
						fmt.Println("YES")
					}
				}
			}

		}

	}
}

package main

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

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

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

func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
	return
}

func main() {
	defer writer.Flush()

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

	for ; testCount > 0; testCount-- {
		var n int
		scanf("%v\n", &n)
		var a = make([]int, n)
		var b = make([]int, n)

		for i := 0; i < n; i++ {
			scanf("%d", &a[i])
		}
		scanf("\n")
		for i := 0; i < n; i++ {
			scanf("%d", &b[i])
		}
		minINdex := -1
		scanf("\n")

		for i := 0; i < n; i++ {
			if b[i] == 0 {
				continue
			}
			if minINdex == -1 || a[i] - b[i] < a[minINdex]- b[minINdex] {
				minINdex = i
			}
		}
		if minINdex == -1 {
			printf("YES\n")
			continue
		}

		foundError := false
		for i := 0; i < n; i++ {
			if b[i] > a[i] || a[i] - b[i] > a[minINdex] - b[minINdex] {
				foundError = true
				break
			}
		}

		if foundError {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &a[i])
	}
	b := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &b[i])
	}
	dist := -1
	maxd := -1
	for i := range a {
		if b[i] != 0 {
			d := a[i] - b[i]
			if d < 0 {
				fmt.Fprintln(w, "NO")
				return
			}
			if dist == -1 {
				dist = d
			} else if dist != d {
				fmt.Fprintln(w, "NO")
				return
			}
		} else {
			if a[i] - b[i] < 0 {
				fmt.Fprintln(w, "NO")
				return
			}
			if maxd == -1 {
				maxd = a[i] - b[i]
			} else {
				maxd = max(maxd, a[i] - b[i])
			}
		}
	}
	if dist >= maxd || dist == -1 {
		fmt.Fprintln(w, "YES")
	} else {
		fmt.Fprintln(w, "NO")
	}
}

func max(a, b int) int {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"
)

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		n := 0
		fmt.Fscan(in, &n)
		a, b := make([]int, n), make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &b[i])
		}
		ok := "YES"
		max := -1
		for i := 0; i < n; i++ {
			if b[i] == 0 && a[i]-b[i] > max {
				max = a[i] - b[i]
			}
			if a[i] < b[i] {
				ok = "NO"
				break
			}
		}
		limit := -1
		for i := 0; i < n; i++ {
			if b[i] != 0 {
				if limit == -1 {
					limit = a[i] - b[i]
				}
				if limit != a[i]-b[i] || limit < max {
					ok = "NO"
					break
				}
			}
		}
		fmt.Fprintln(out, ok)
	}

}

package main

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

var (
    a, b [5e4+5]int64
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        delta := int64(0)
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
            delta = max(delta, a[i] - b[i])
        }
        flag := false
        for i := int64(1); i <= n; i++ {
            a[i] = max(0, a[i] - delta)
            if a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int64, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt64()
		}
		diff := int64(-1)
		ans := true
		b := make([]int64, n)
		for i := 0; i < n; i++ {
			b[i] = in.NextInt64()
			if a[i] >= b[i] {
				diff = int64(math.Max(float64(a[i])-float64(b[i]), float64(diff)))
			}
		}

		for i := 0; i < n; i++ {
			if a[i]-diff < 0 && b[i] == 0 {
				continue
			} else if a[i]-diff == b[i] {
				continue
			} else {
				ans = false
			}

		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if a[i] >= b[i] {
				diff = int(math.Max(float64(a[i])-float64(b[i]), float64(diff)))
			}
		}

		for i := 0; i < n; i++ {
			val := b[i]
			if (a[i]-diff <= 0 && val == 0) || a[i]-diff == val {
				continue
			} else {
				ans = false
			}
		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		eq := true
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if a[i] >= b[i] {
				diff = int(math.Max(float64(a[i])-float64(b[i]), float64(diff)))
			}

			if b[i] != a[i] {
				eq = false
			}
		}

		if eq {
			fmt.Println("YES")
		} else {
			for i := 0; i < n; i++ {
				val := b[i]
				if (a[i]-diff <= 0 && val == 0) || a[i]-diff == val {
					continue
				} else {
					ans = false
				}
			}

			if ans {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		eq := true
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if a[i] >= b[i] {
				diff = int(math.Max(float64(a[i])-float64(b[i]), float64(diff)))
			}

			if b[i] != a[i] {
				eq = false
			}
		}

		if eq {
			fmt.Println("YES")
		} else {
			for i := 0; i < n; i++ {
				val := b[i]
				if a[i]-diff <= 0 && val == 0 {
					continue
				} else if a[i]-diff != val {
					ans = false
				}
			}

			if ans {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		eq := true
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if a[i] >= b[i] {
				diff = int(math.Max(float64(a[i])-float64(b[i]), float64(diff)))
			}

			if b[i] != a[i] {
				eq = false
			}
		}

		if eq || (n == 1 && b[0] == 0) {
			fmt.Println("YES")
		} else {
			for i := 0; i < n; i++ {
				val := b[i]
				if a[i]-diff <= 0 && val == 0 {
					continue
				} else if a[i]-diff != val {
					ans = false
				}
			}

			if ans {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		eq := true
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if  a[i] >= b[i] {
				diff = int(math.Max(float64(a[i]) - float64(b[i]), float64(diff)))
			}

			if b[i] != a[i] {
				eq = false
			}
		}

		if eq || (n == 1 && a[0] > b[0]) {
			fmt.Println("YES")
		} else {
			for i := 0; i < n; i++ {
				val := b[i]
				if a[i]-diff <= 0 && val == 0 {
					continue
				} else if a[i]-diff != val {
					ans = false
				}
			}

			if ans {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		eq := true
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if diff == -1 && b[i] != 0 && a[i] >= b[i] {
				diff = a[i] - b[i]
			}

			if b[i] != a[i] {
				eq = false
			}
		}

		if eq || (n == 1 && a[0]>b[0]){
			fmt.Println("YES")
		}else {
			for i := 0; i < n; i++ {
				val := b[i]
				if a[i]-diff <= 0 && val == 0 {
					continue
				} else if a[i]-diff != val {
					ans = false
				}
			}

			if ans {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		b := make([]int, n)
		eq := true
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
			if diff == -1 && b[i] != 0 && a[i] >= b[i] {
				diff = a[i] - b[i]
			}

			if b[i] != a[i] {
				eq = false
			}
		}

		if eq {
			fmt.Println("YES")
		}else {
			for i := 0; i < n; i++ {
				val := b[i]
				if i == 0 {
					if val > a[i] {
						ans = false
					} else {
						diff = a[i] - val
					}
				} else if a[i]-diff <= 0 && val == 0 {
					continue
				} else if a[i]-diff != val {
					ans = false
				}
			}

			if ans {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}

		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690B
Date: 10/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/B
Problem: CF1690B
**/
func (in *CF1690B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		diff := -1
		ans := true
		for i := 0; i < n; i++ {
			val := in.NextInt()
			if i == 0 {
				if val > a[i] {
					ans = false
				} else {
					diff = a[i] - val
				}
			} else if a[i]-diff <= 0 && val == 0 {
				continue
			} else if a[i]-diff != val {
				ans = false
			}
		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

var (
    a, b [5e4+5]int64
)

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

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        delta := int64(0)
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
            delta = max(delta, abs(a[i] - b[i]))
        }
        flag := false
        for i := int64(1); i <= n; i++ {
            a[i] -= delta
            if a[i] < 0 && b[i] != 0 {
                Fprintln(out, "NO")
                flag = true
                break
            }
            if a[i] > 0 && a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

var (
    a, b [5e4+5]int64
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
        }
        delta := abs(a[1] - b[1])
        flag := false
        for i := int64(1); i <= n; i++ {
            if a[i] < b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
            a[i] -= delta
            if a[i] < 0 && b[i] != 0 {
                Fprintln(out, "NO")
                flag = true
                break
            }
            if a[i] > 0 && a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

var (
    a, b [5e4+5]int64
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
        }
        delta := abs(a[1] - b[1])
        flag := false
        for i := int64(1); i <= n; i++ {
            a[i] -= delta
            if a[i] < 0 && b[i] != 0 {
                Fprintln(out, "NO")
                flag = true
                break
            }
            if a[i] > 0 && a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

var (
    a, b [5e4+5]int64
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
        }
        delta := abs(a[1] - b[1])
        flag := false
        for i := int64(1); i <= n; i++ {
            a[i] -= delta
            if a[i] < 0 && b[i] != 0 {
                Fprintln(out, "NO")
                flag = true
                break
            } else if a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

var (
    a, b [5e4+5]int64
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
        }
        delta := abs(a[1] - b[1])
        flag := false
        for i := int64(1); i <= n; i++ {
            if a[i] < b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
            a[i] -= delta
            if a[i] < 0 && b[i] != 0 {
                Fprintln(out, "NO")
                flag = true
                break
            } else if a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

var (
    a, b [5e4+5]int
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := 1; i <= n; i++ {
            a[i] = read()
        }
        for i := 1; i <= n; i++ {
            b[i] = read()
        }
        delta := abs(a[1] - b[1])
        flag := false
        for i := 1; i <= n; i++ {
            if a[i] < b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
            a[i] -= delta
            if a[i] < 0 && b[i] != 0 {
                Fprintln(out, "NO")
                flag = true
                break
            } else if a[i] != b[i] {
                Fprintln(out, "NO")
                flag = true
                break
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

var (
    a, b [5e4+5]int
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := 1; i <= n; i++ {
            a[i] = read()
        }
        for i := 1; i <= n; i++ {
            b[i] = read()
        }
        delta := abs(a[1] - b[1])
        flag := false
        for i := 1; i <= n; i++ {
            a[i] -= delta
            if a[i] < 0 {
                if b[i] != 0 {
                    Fprintln(out, "NO")
                    flag = true
                    break
                }
            } else {
                if a[i] != b[i] {
                    Fprintln(out, "NO")
                    flag = true
                    break
                }
            }
        }
        if !flag {
            Fprintln(out, "YES")
        }
    }
}

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

package main

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

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

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

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

		min := a[0] - b[0]
		f := true
		for i := 0; i < n; i++ {
			if a[i]-b[i] < 0 {
				f = false
				break
			} else if a[i]-b[i] > 1 && a[i]-b[i] != min {
				f = false
				break
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "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.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		a := make([]int64, n)
		f := true
		z := int64(-1)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)

			if v > 0 {
				if v > a[i] {
					f = false
				}

				if z < 0 {
					z = a[i] - v
				} else if a[i]-v != z {
					f = false
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "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.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		a := make([]int, n)
		f := true
		z := -1
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			if v > 0 {
				if v > a[i] {
					f = false
				}

				if z < 0 {
					z = a[i] - v
				} else if a[i]-v != z {
					f = false
				}
			}
		}

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

package main

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

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

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

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

			if v != 0 {
				b[i] = a[i] - v
			}
		}

		sort.Ints(b)
		f := true
		for i := 0; i < n; i++ {
			if b[i] == 0 {
				continue
			} else if b[i] < 0 || (i < n-1 && b[i] != b[i+1]) {
				f = false
				break
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "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.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

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

		f := true
		z := -1
		for i := 0; i < n; i++ {
			if b[i] == 0 {
				continue
			} else if b[i] > a[i] {
				f = false
				break
			}

			if z < 0 {
				z = a[i] - b[i]
			} else if a[i]-b[i] != z {
				f = false
				break
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

// This example demonstrates an integer heap built using the heap interface.

// An IntHeap is a min-heap of ints.
/* type IntHeap []int64

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

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

// // This example inserts several ints into an Int, checks the minimum,
// // and removes them in order of priority.
// func main() {
// 	h := &IntHeap{2, 1, 5}
// 	heap.Init(h)
// 	heap.Push(h, 3)
// 	fmt.Printf("minimum: %d\n", (*h)[0])
// 	for h.Len() > 0 {
// 		fmt.Printf("%d ", heap.Pop(h))
// 	}
// }
type st struct {
	v  int
	id int
}

func A2() {
	_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 int
		Fscan(in, &n)
		a := make([]int, n)
		b := make([]int, n)

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

			Fscan(in, &a[i])

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

			Fscan(in, &b[i])
			if b[i] > a[i] {
				Fprintln(out, "No")
				return
			}
			if a[i]-b[i] > mx {
				mx = a[i] - b[i]
			}
		}
		for i := 0; i < n; i++ {
			if a[i]-b[i] != mx && b[i] != 0 {
				Fprintln(out, "No")
				return
			}
		}
		Fprintln(out, "Yes")

	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A2() }

package main

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

// This example demonstrates an integer heap built using the heap interface.

// An IntHeap is a min-heap of ints.
/* type IntHeap []int64

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

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

// // This example inserts several ints into an Int, checks the minimum,
// // and removes them in order of priority.
// func main() {
// 	h := &IntHeap{2, 1, 5}
// 	heap.Init(h)
// 	heap.Push(h, 3)
// 	fmt.Printf("minimum: %d\n", (*h)[0])
// 	for h.Len() > 0 {
// 		fmt.Printf("%d ", heap.Pop(h))
// 	}
// }
type st struct {
	v  int
	id int
}

func A2() {
	_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 int
		Fscan(in, &n)
		a := make([]st, n)
		b := make([]st, n)

		for i := 0; i < n; i++ {
			var t int
			Fscan(in, &t)
			a[i] = st{t, i}
		}
		for i := 0; i < n; i++ {
			var t int
			Fscan(in, &t)
			if t > a[i].v {
				Fprintln(out, "No")
				return
			}
			b[i] = st{t, i}
		}
		sort.Slice(a, func(i, j int) bool {
			if a[i].v == a[j].v {
				return a[i].id < a[j].id
			}
			return a[i].v < a[j].v
		})

		sort.Slice(b, func(i, j int) bool {
			if b[i].v == b[j].v {
				return b[i].id < b[j].id
			}
			return b[i].v < b[j].v
		})
		for i := 0; i < n; i++ {
			if a[i].id != b[i].id {
				Fprintln(out, "No")
				return
			}
			if i > 0 {
				if a[i].v-a[i-1].v < b[i].v-b[i-1].v {
					Fprintln(out, "No")
					return
				}
				if a[i].v-a[i-1].v > b[i].v-b[i-1].v && b[i-1].v != 0 {
					Fprintln(out, "No")
					return
				}
			}
		}
		Fprintln(out, "Yes")
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A2() }

package main

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

// This example demonstrates an integer heap built using the heap interface.

// An IntHeap is a min-heap of ints.
/* type IntHeap []int64

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

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

// // This example inserts several ints into an Int, checks the minimum,
// // and removes them in order of priority.
// func main() {
// 	h := &IntHeap{2, 1, 5}
// 	heap.Init(h)
// 	heap.Push(h, 3)
// 	fmt.Printf("minimum: %d\n", (*h)[0])
// 	for h.Len() > 0 {
// 		fmt.Printf("%d ", heap.Pop(h))
// 	}
// }
type st struct {
	v  int
	id int
}

func A2() {
	_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 int
		Fscan(in, &n)
		a := make([]st, n)
		b := make([]st, n)

		for i := 0; i < n; i++ {
			var t int
			Fscan(in, &t)
			a[i] = st{t, i}
		}
		for i := 0; i < n; i++ {
			var t int
			Fscan(in, &t)
			if t > a[i].v {
				Fprintln(out, "No")
				return
			}
			b[i] = st{t, i}
		}
		sort.Slice(a, func(i, j int) bool {
			return a[i].v < a[j].v
		})

		sort.Slice(b, func(i, j int) bool {
			return b[i].v < b[j].v
		})
		for i := 0; i < n; i++ {
			if a[i].id != b[i].id {
				Fprintln(out, "No")
				return
			}
			if i > 0 {
				if a[i].v-a[i-1].v < b[i].v-b[i-1].v {
					Fprintln(out, "No")
					return
				}
				if a[i].v-a[i-1].v > b[i].v-b[i-1].v && b[i-1].v != 0 {
					Fprintln(out, "No")
					return
				}
			}
		}
		Fprintln(out, "Yes")
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A2() }

package main

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

// This example demonstrates an integer heap built using the heap interface.

// An IntHeap is a min-heap of ints.
/* type IntHeap []int64

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

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

// // This example inserts several ints into an Int, checks the minimum,
// // and removes them in order of priority.
// func main() {
// 	h := &IntHeap{2, 1, 5}
// 	heap.Init(h)
// 	heap.Push(h, 3)
// 	fmt.Printf("minimum: %d\n", (*h)[0])
// 	for h.Len() > 0 {
// 		fmt.Printf("%d ", heap.Pop(h))
// 	}
// }
type st struct {
	v  int
	id int
}

func A2() {
	_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 int
		Fscan(in, &n)
		a := make([]st, n)
		b := make([]st, n)

		for i := 0; i < n; i++ {
			var t int
			Fscan(in, &t)
			a[i] = st{t, i}
		}
		for i := 0; i < n; i++ {
			var t int
			Fscan(in, &t)
			if t > a[i].v {
				Fprintln(out, "No")
				return
			}
			b[i] = st{t, i}
		}
		sort.Slice(a, func(i, j int) bool {
			return a[i].v < a[j].v
		})

		sort.Slice(b, func(i, j int) bool {
			return b[i].v < b[j].v
		})
		for i := 0; i < n; i++ {
			if a[i].id != b[i].id {
				Fprintln(out, "No")
				return
			}
		}
		Fprintln(out, "Yes")
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A2() }

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list1:= make([]int,n)
		list2:= make([]int,n)
		largest:=0
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list1[j])
			if list1[j] >= largest {
				largest=list1[j]
			}
		}
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list2[j])
		}
		difference:=0
		for j:=0;j<n;j++{
			if list1[j] == largest {
				difference= list1[j]-list2[j]
				break
			}
		}
		for j:=0;j<n;j++{
			if list1[j]-list2[j] != difference || difference < 0 {
				if list1[j] < largest && list2[j] == 0 {
					continue
				}
				fmt.Fprintln(out,"NO")
				goto out
			}
		}
		fmt.Fprintln(out,"YES")
		out:
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list1:= make([]int,n)
		list2:= make([]int,n)
		smallest:=0
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list1[j])
			if j==0{
				smallest=list1[j]
			} else {
				if list1[j] <= smallest {
					smallest=list1[j]
				}
			}
		}
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list2[j])
		}
		var difference []int
		for j:=0;j<n;j++{
			if list1[j] == smallest && list2[j] == 0 {
				continue
			} else {
				difference = append(difference,list1[j] - list2[j])
			}
		}
		for j:=0;j<len(difference);j++{
			if difference[j] != difference[0] || difference[j] < 0 {
				fmt.Fprintln(out,"NO")
				goto out
			}
		}
		fmt.Fprintln(out,"YES")
		out:
	}
}

package main

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

const (
	MaxInt32 = 1 << 31 - 1
)

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

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(cin, &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &b[i])
		}
		m := map[int]bool{}
		ok := true
		mindiff := MaxInt32
		for i := 0; i < n; i++ {
			if b[i] != 0 {
				m[a[i] - b[i]] = true
				if a[i] - b[i] < 0 {
					ok = false
					break
				}else {
					mindiff = Min(mindiff, a[i] - b[i])
				}
			}else {
				if a[i] - b[i] > mindiff {
					ok = false
					break
				}
			}
		}

		if len(m) > 1 || !ok {
			fmt.Println("NO")
		}else {
			fmt.Println("YES")
		}

	}
}

package main

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

const (
	MaxInt32 = 1 << 31 - 1
)

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(cin, &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &b[i])
		}
		m := map[int]bool{}
		ok := true
		for i := 0; i < n; i++ {
			if b[i] != 0 {
				m[a[i] - b[i]] = true
				if a[i] - b[i] < 0 {
					ok = false
					break
				}
			}
		}

		if len(m) > 1 || !ok {
			fmt.Println("NO")
		}else {
			fmt.Println("YES")
		}

	}
}

package main

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

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

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

func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
	return
}

func main() {
	defer writer.Flush()

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

	for ; testCount > 0; testCount-- {
		var n int
		scanf("%v\n", &n)
		var a = make([]int, n)
		var b = make([]int, n)

		for i := 0; i < n; i++ {
			scanf("%d", &a[i])
		}
		scanf("\n")
		for i := 0; i < n; i++ {
			scanf("%d", &b[i])
		}
		minINdex := -1
		scanf("\n")

		for i := 0; i < n; i++ {
			if b[i] == 0 {
				continue
			}
			if minINdex == -1 || b[minINdex] > b[i] {
				minINdex = i
			}
		}
		if minINdex == -1 {
			printf("YES\n")
			continue
		}

		foundError := false
		for i := 0; i < n; i++ {
			if b[i] > a[i] || a[i] - b[i] > a[minINdex] - b[minINdex] {
				foundError = true
				break
			}
		}

		if foundError {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &a[i])
	}
	b := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &b[i])
	}
	dist := -1
	maxd := int(1e9)+1
	for i := range a {
		if b[i] != 0 {
			d := a[i] - b[i]
			if d < 0 {
				fmt.Fprintln(w, "NO")
				return
			}
			if dist == -1 {
				dist = d
			} else if dist != d {
				fmt.Fprintln(w, "NO")
				return
			}
			maxd = min(maxd, a[i] - b[i])
		} else {
			if a[i] - b[i] < 0 {
				fmt.Fprintln(w, "NO")
				return
			}
			maxd = min(maxd, a[i] - b[i])
		}
	}
	if dist >= maxd || dist == -1 {
		fmt.Fprintln(w, "YES")
	} else {
		fmt.Fprintln(w, "NO")
	}
}

func min(a, b int) int {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"
	"io"
	"os"
)

var t int

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

	fmt.Fscan(input, &t)

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

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

		ok := false
		for i := 1; i < (n - 1); i++ {
			if arr[i] > arr[i-1] && arr[i] > arr[i+1] {
				fmt.Println("YES")
				fmt.Printf("%d %d %d\n", i, i+1, i+2)
				ok = true
				break
			}
		}

		if ok == false {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		p1, p2, p3 := 0, 0, 0
		increase := false
		isOk := false
		var pPrev int
		for j := 1; j <= n; j++ {
			var p int
			fmt.Fscan(in, &p)
			if isOk {
				continue
			}
			if j == 1 {
				pPrev = p
				continue
			}

			if p > pPrev {
				increase = true
				p1 = j - 1
				p2 = j
			}
			if p < pPrev && increase {
				p3 = j
				isOk = true
			}

			pPrev = p
		}
		if isOk {
			fmt.Println("YES")
			fmt.Println(p1, p2, p3)
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

type FastIn struct {
	scanner *bufio.Scanner
}

func MakeFastIn() FastIn {
	obj := FastIn{}
	obj.scanner = bufio.NewScanner(os.Stdin)
	obj.scanner.Split(bufio.ScanWords)
	return obj
}

func (fi *FastIn) readInt() int {
	fi.scanner.Scan()
	ret, error := strconv.Atoi(fi.scanner.Text())
	if error != nil {
		panic(error)
	}
	return ret
}

type Pair struct {
	value int
	pos int
}

func main() {
	fin := MakeFastIn()
	t := fin.readInt()
	for i := 0; i < t; i++ {
		n := fin.readInt()
		p := make([]int, n)
		for j := 0; j < n; j++ {
			p[j] = fin.readInt()
		}

		from_left := make([]Pair, n)
		for j := 0; j < n; j++ {
			from_left[j] = Pair {p[j], j}
			if j > 0 && from_left[j].value > from_left[j-1].value {
				from_left[j] = from_left[j-1]
			}
		}

		done := false
		curr := Pair{p[n-1],n-1}
		for j := n - 2; !done && j >= 1; j-- {
			if p[j] > curr.value && p[j] > from_left[j-1].value{
				fmt.Printf("YES\n%d %d %d\n", from_left[j-1].pos + 1, j + 1, curr.pos+1);
				done = true
			}
			if p[j] < curr.value {
				curr = Pair{p[j],j}
			}
		}
		if ! done {
			fmt.Printf("NO\n")
		}
	}
}

package main

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

type Pair struct {
	value int
	pos int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	t,_ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		n,_ := strconv.Atoi(scanner.Text())
		p := make([]int, n)
		for j := 0; j < n; j++ {
			scanner.Scan()
			p[j],_ = strconv.Atoi(scanner.Text())
		}

		from_left := make([]Pair, n)
		for j := 0; j < n; j++ {
			from_left[j] = Pair {p[j], j}
			if j > 0 && from_left[j].value > from_left[j-1].value {
				from_left[j] = from_left[j-1]
			}
		}

		done := false
		curr := Pair{p[n-1],n-1}
		for j := n - 2; !done && j >= 1; j-- {
			if p[j] > curr.value && p[j] > from_left[j-1].value{
				fmt.Printf("YES\n%d %d %d\n", from_left[j-1].pos + 1, j + 1, curr.pos+1);
				done = true
			}
			if p[j] < curr.value {
				curr = Pair{p[j],j}
			}
		}
		if ! done {
			fmt.Printf("NO\n")
		}
	}
}

package main

import (
	"fmt"
)

type Pair struct {
	value int
	pos int
}

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

		from_left := make([]Pair, n)
		for j := 0; j < n; j++ {
			from_left[j] = Pair {p[j], j}
			if j > 0 && from_left[j].value > from_left[j-1].value {
				from_left[j] = from_left[j-1]
			}
		}

		done := false
		curr := Pair{p[n-1],n-1}
		for j := n - 2; !done && j >= 1; j-- {
			if p[j] > curr.value && p[j] > from_left[j-1].value{
				fmt.Printf("YES\n%d %d %d\n", from_left[j-1].pos + 1, j + 1, curr.pos+1);
				done = true
			}
			if p[j] > curr.value {
				curr = Pair{p[j],j}
			}
		}
		if ! done {
			fmt.Printf("NO\n")
		}
	}
}

package main

import (
	"fmt"
)

type Pair struct {
	value int
	pos int
}

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

		from_left := make([]Pair, n)
		for j := 0; j < n; j++ {
			from_left[j] = Pair {p[j], j}
			if j > 0 && from_left[j].value > from_left[j].value {
				from_left[j] = from_left[j-1]
			}
		}

		done := false
		curr := Pair{p[n-1],n-1}
		for j := n - 2; !done && j >= 1; j-- {
			if p[j] > curr.value && p[j] > from_left[j-1].value{
				fmt.Printf("YES\n%d %d %d\n", from_left[j-1].pos + 1, j + 1, curr.pos+1);
				done = true
			}
			if p[j] > curr.value {
				curr = Pair{p[j],j}
			}
		}
		if ! done {
			fmt.Printf("NO\n")
		}
	}
}

package main

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

type Pair struct {
	value int
	pos int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	t,_ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		n,_ := strconv.Atoi(scanner.Text())
		p := make([]int, n)
		for j := 0; j < n; j++ {
			p[j],_ = strconv.Atoi(scanner.Text())
		}

		from_left := make([]Pair, n)
		for j := 0; j < n; j++ {
			from_left[j] = Pair {p[j], j}
			if j > 0 && from_left[j].value > from_left[j-1].value {
				from_left[j] = from_left[j-1]
			}
		}

		done := false
		curr := Pair{p[n-1],n-1}
		for j := n - 2; !done && j >= 1; j-- {
			if p[j] > curr.value && p[j] > from_left[j-1].value{
				fmt.Printf("YES\n%d %d %d\n", from_left[j-1].pos + 1, j + 1, curr.pos+1);
				done = true
			}
			if p[j] < curr.value {
				curr = Pair{p[j],j}
			}
		}
		if ! done {
			fmt.Printf("NO\n")
		}
	}
}