Kristina has two arrays $$$a$$$ and $$$b$$$, each containing $$$n$$$ non-negative integers. She can perform the following operation on array $$$a$$$ any number of times:   apply a decrement to each non-zero element of the array, that is, replace the value of each element $$$a_i$$$ such that $$$a_i > 0$$$ with the value $$$a_i - 1$$$ ($$$1 \le i \le n$$$). If $$$a_i$$$ was $$$0$$$, its value does not change. Determine whether Kristina can get an array $$$b$$$ from an array $$$a$$$ in some number of operations (probably zero). In other words, can she make $$$a_i = b_i$$$ after some number of operations for each $$$1 \le i \le n$$$?For example, let $$$n = 4$$$, $$$a = [3, 5, 4, 1]$$$ and $$$b = [1, 3, 2, 0]$$$. In this case, she can apply the operation twice:   after the first application of the operation she gets $$$a = [2, 4, 3, 0]$$$;  after the second use of the operation she gets $$$a = [1, 3, 2, 0]$$$. Thus, in two operations, she can get an array $$$b$$$ from an array $$$a$$$.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) —the number of test cases in the test. The descriptions of the test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^4$$$). The second line of each test case contains exactly $$$n$$$ non-negative integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). The third line of each test case contains exactly $$$n$$$ non-negative integers $$$b_1, b_2, \dots, b_n$$$ ($$$0 \le b_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ values over all test cases in the test does not exceed $$$2 \cdot 10^5$$$.

For each test case, output on a separate line:   YES, if by doing some number of operations it is possible to get an array $$$b$$$ from an array $$$a$$$;  NO otherwise.  You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).

NoteThe first test case is analyzed in the statement.In the second test case, it is enough to apply the operation to array $$$a$$$ once.In the third test case, it is impossible to get array $$$b$$$ from array $$$a$$$.

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(
    . "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"
	"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"
	"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"
	"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 (
	"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"
	"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()
	}
}


You are given a permutation $$$p_1, p_2, \dots, p_n$$$. Recall that sequence of $$$n$$$ integers is called a permutation if it contains all integers from $$$1$$$ to $$$n$$$ exactly once.Find three indices $$$i$$$, $$$j$$$ and $$$k$$$ such that:   $$$1 \le i < j < k \le n$$$;  $$$p_i < p_j$$$ and $$$p_j > p_k$$$.  Or say that there are no such indices.

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 200$$$) — the number of test cases. Next $$$2T$$$ lines contain test cases — two lines per test case. The first line of each test case contains the single integer $$$n$$$ ($$$3 \le n \le 1000$$$) — the length of the permutation $$$p$$$. The second line contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$; $$$p_i \neq p_j$$$ if $$$i \neq j$$$) — the permutation $$$p$$$.

For each test case:    if there are such indices $$$i$$$, $$$j$$$ and $$$k$$$, print YES (case insensitive) and the indices themselves;  if there are no such indices, print NO (case insensitive).  If there are multiple valid triples of indices, print any of them.

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


It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guys. For example, he can hit the ball directly to the specified point. And yet, the notion of a giveaway is foreign to him. The combination of these features makes the Robo-Wallace the perfect footballer — as soon as the ball gets to him, he can just aim and hit the goal. He followed this tactics in the first half of the match, but he hit the goal rarely. The opposing team has a very good goalkeeper who catches most of the balls that fly directly into the goal. But Robo-Wallace is a quick thinker, he realized that he can cheat the goalkeeper. After all, they are playing in a football box with solid walls. Robo-Wallace can kick the ball to the other side, then the goalkeeper will not try to catch the ball. Then, if the ball bounces off the wall and flies into the goal, the goal will at last be scored.Your task is to help Robo-Wallace to detect a spot on the wall of the football box, to which the robot should kick the ball, so that the ball bounces once and only once off this wall and goes straight to the goal. In the first half of the match Robo-Wallace got a ball in the head and was severely hit. As a result, some of the schemes have been damaged. Because of the damage, Robo-Wallace can only aim to his right wall (Robo-Wallace is standing with his face to the opposing team's goal).The football box is rectangular. Let's introduce a two-dimensional coordinate system so that point (0, 0) lies in the lower left corner of the field, if you look at the box above. Robo-Wallace is playing for the team, whose goal is to the right. It is an improvised football field, so the gate of Robo-Wallace's rivals may be not in the middle of the left wall.  In the given coordinate system you are given:   y1, y2 — the y-coordinates of the side pillars of the goalposts of robo-Wallace's opponents;  yw — the y-coordinate of the wall to which Robo-Wallace is aiming;  xb, yb — the coordinates of the ball's position when it is hit;  r — the radius of the ball. A goal is scored when the center of the ball crosses the OY axis in the given coordinate system between (0, y1) and (0, y2). The ball moves along a straight line. The ball's hit on the wall is perfectly elastic (the ball does not shrink from the hit), the angle of incidence equals the angle of reflection. If the ball bounces off the wall not to the goal, that is, if it hits the other wall or the goal post, then the opposing team catches the ball and Robo-Wallace starts looking for miscalculation and gets dysfunctional. Such an outcome, if possible, should be avoided. We assume that the ball touches an object, if the distance from the center of the ball to the object is no greater than the ball radius r.

The first and the single line contains integers y1, y2, yw, xb, yb, r (1 ≤ y1, y2, yw, xb, yb ≤ 106; y1 < y2 < yw; yb + r < yw; 2·r < y2 - y1). It is guaranteed that the ball is positioned correctly in the field, doesn't cross any wall, doesn't touch the wall that Robo-Wallace is aiming at. The goal posts can't be located in the field corners.

If Robo-Wallace can't score a goal in the described manner, print "-1" (without the quotes). Otherwise, print a single number xw — the abscissa of his point of aiming.  If there are multiple points of aiming, print the abscissa of any of them. When checking the correctness of the answer, all comparisons are made with the permissible absolute error, equal to 10 - 8.  It is recommended to print as many characters after the decimal point as possible.

NoteNote that in the first and third samples other correct values of abscissa xw are also possible.

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func sdist(ym,y2,xb,yb float64) float64 {
	a := (yb-ym)/xb
	b := float64(-1)
	c := ym

	// printf("%f %f %f\n", a,b,c)

	return math.Abs(a*0 + b*y2 + c)/math.Sqrt(a*a + b*b)
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw-=r

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	ym := y1-r

	im := intersection(y1-r,yw,xb,yb)
	// i2 := intersection(y2,yw,xb,yb)

	// printf("im=%f i2=%f dist=%f y2=%f\n", im,i2,sdist(ym, y2, xb,yb),y2)

	if(sdist(ym, y2, xb,yb) >= r) {
		printf("%0.10f\n", im)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func sdist(ym,y2,xb,yb float64) float64 {
	a := (yb-ym)/xb
	b := float64(-1)
	c := ym

	// printf("%f %f %f\n", a,b,c)

	return math.Abs(a*0 + b*y2 + c)/math.Sqrt(a*a + b*b)
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw--

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	ym := y1-r

	im := intersection(y1-r,yw,xb,yb)
	// i2 := intersection(y2,yw,xb,yb)

	// printf("im=%f i2=%f dist=%f y2=%f\n", im,i2,sdist(ym, y2, xb,yb),y2)

	if(sdist(ym, y2, xb,yb) >= r) {
		printf("%0.10f\n", im)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func sdist(ym,y2,xb,yb float64) float64 {
	a := (yb-ym)/xb
	b := float64(-1)
	c := ym

	// printf("%f %f %f\n", a,b,c)

	return math.Abs(a*0 + b*y2 + c)/math.Sqrt(a*a + b*b)
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw-=r

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	ym := y1-r

	im := intersection(y1-r,yw,xb,yb)
	i2 := intersection(y2,yw,xb,yb)

	printf("im=%f i2=%f dist=%f y2=%f\n", im,i2,sdist(ym, y2, xb,yb),y2)

	if(sdist(ym, y2, xb,yb) >= r) {
		printf("%0.10f\n", im)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	i1 := intersection(y1,yw,xb,yb)
	i2 := intersection(y2,yw,xb,yb)

	// printf("i1=%f y2=%f\n", i1,i2)

	if(i1-i2 >= r) {
		printf("%f\n", i1)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func sdist(ym,y2,xb,yb float64) float64 {
	a := (yb-ym)/xb
	b := float64(-1)
	c := ym

	printf("%f %f %f\n", a,b,c)

	return math.Abs(a*0 + b*y2 + c)/math.Sqrt(a*a + b*b)
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw--

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	ym := y1-r

	im := intersection(y1-r,yw,xb,yb)
	i2 := intersection(y2,yw,xb,yb)

	printf("im=%f i2=%f dist=%f y2=%f\n", im,i2,sdist(ym, y2, xb,yb),y2)

	if(sdist(ym, y2, xb,yb) >= r) {
		printf("%f\n", im)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func sdist(ym,y2,xb,yb float64) float64 {
	a := (yb-ym)/xb
	b := float64(-1)
	c := ym

	// printf("%f %f %f\n", a,b,c)

	return math.Abs(a*0 + b*y2 + c)/math.Sqrt(a*a + b*b)
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw--

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	ym := (y1+y2)/2.0

	im := intersection(y1-r,yw,xb,yb)
	// i2 := intersection(y2,yw,xb,yb)

	// printf("im=%f i2=%f dist=%f y2=%f\n", im,i2,sdist(ym, y2, xb,yb),y2)

	if(sdist(ym, y2, xb,yb) >= r/2.0) {
		printf("%f\n", im)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw--

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	// i1 := intersection(y1,yw,xb,yb)
	im := intersection(y1-r,yw,xb,yb)
	i2 := intersection(y2,yw,xb,yb)

	// printf("i1=%f im=%f i2=%f\n", i1,im,i2)

	if(im-i2 >= r) {
		printf("%f\n", im)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	i1 := intersection(y1,yw,xb,yb)
	i2 := intersection(y2,yw,xb,yb)

	if(i1-i2 >= r) {
		printf("%f\n", i2 + (i1-i2)/2.0)
	} else {
		printf("-1\n")
	}
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func intersection(y,yw,xb,yb float64) float64 {
	ans := (yw-y) * xb / (yb-y)

	return ans
}

func sdist(ym,y2,xb,yb float64) float64 {
	a := (yb-ym)/xb
	b := float64(-1)
	c := ym

	// printf("%f %f %f\n", a,b,c)

	return math.Abs(a*0 + b*y2 + c)/math.Sqrt(a*a + b*b)
}

func main() {
	defer writer.Flush()

	var y1,y2,yw,xb,yb,r float64

	scanf("%f %f %f %f %f %f\n", &y1,&y2,&yw,&xb,&yb,&r)

	yw--

	y1 = yw-y1+yw
	y2 = yw-y2+yw

	ym := y1-r

	im := intersection(y1-r,yw,xb,yb)
	// i2 := intersection(y2,yw,xb,yb)

	// printf("im=%f i2=%f dist=%f y2=%f\n", im,i2,sdist(ym, y2, xb,yb),y2)

	if(sdist(ym, y2, xb,yb) >= r) {
		printf("%f\n", im)
	} else {
		printf("-1\n")
	}
}