package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	max := func(i, j int64) int64 { if i > j { return i } else {return j}}
	check := func(n interface{}, err error) interface{} { if err != nil { fmt.Println(err) }; return n }
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	p.N = check(strconv.Atoi(scanner.Text())).(int)
	p.Result = make([]string, p.N)
	lc := 0
	var tec, maxV, ik int64
	verdict := ""
	for i := 0; i < p.N; i++ {
		verdict = "YES"
		maxV = -2e18
		scanner.Scan()
		lc = check(strconv.Atoi(scanner.Text())).(int)
		tec = 0
		for fldNum := 0; fldNum < lc; fldNum++ {
			scanner.Scan()
			if verdict == "NO" {continue}
			ik = check(strconv.ParseInt(scanner.Text(), 10, 64)).(int64)
			tec += ik
			if tec <= 0 || fldNum == lc-1 && maxV >= tec {
				verdict = "NO"
				continue
			} else {
				maxV = max(maxV, tec)
			}
		}
		p.Result[i] = verdict
	}
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

var t int

func getMax(n, m int64) int64 {
	if n < m {
		return m
	} else {
		return n
	}
}

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)

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

		dp := make([]int64, n)
		dp[0] = int64(arr[0])

		for i := 1; i < (n - 1); i++ {
			dp[i] = getMax(int64(arr[i]), dp[i - 1] + int64(arr[i]))
		}

		ok := true
		for i := 0; i < (n - 1); i++ {
			if dp[i] >= yasser {
				ok = false
				break
			}
		}

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

		dp[1] = int64(arr[1])
		for i := 2; i < n; i++ {
			dp[i] = getMax(int64(arr[i]), dp[i - 1] + int64(arr[i]))
		}

		ok = true
		for i := 1; i < n; i++ {
			if dp[i] >= yasser {
				ok = false
				break
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int64, n)
		total := int64(0)
		cur := int64(0)
		best := int64(0)
		queue := make([]int64, 0)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
			total += a[i]
			cur += a[i]
			queue = append(queue, a[i])
			if i == 0 {
				best = cur
			} else if cur > best {
				best = cur
			}
			if cur < 0 {
				cur = 0
				queue = []int64{}
			}
			if len(queue) == n-1 {
				cur -= queue[0]
				queue = queue[1:]
			}
		}
		cur = a[n-1]
		if cur > best {
			best = cur
		}
		for i := n - 2; i >= 1; i-- {
			cur = cur + a[i]
			if cur > best {
				best = cur
			}
			if cur < 0 {
				cur = 0
			}
		}
		fmt.Fscanf(in, "\n")
		if total > best {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

func goo(){
	var n int
	n=ReadInt()
	arr :=make([] int ,n)
	for i:=0;i<n;i++{
		arr[i]=ReadInt()
	}
	var sum int64 =0
	for i:=0;i<n;i++{
		sum+=int64(arr[i])
		if sum<=0{
			fmt.Println("NO")
			return
		}
	}
	sum=0
	for i:=n-1;i>=0;i--{
		sum+=int64(arr[i])
		if sum<=0{
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
	return
}

func main(){
	var n int
	//fmt.Scan(n)
	for fmt.Scan(&n);n>0;n--{
		goo()
	}

}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

package main

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

func sol(a []int64, totalSum int64) bool {
	leftSegSum := int64(0)
	rightSegSum := int64(0)
	for i, v := range a {
		if leftSegSum+int64(v) < 0 {
			leftSegSum = 0
		} else {
			leftSegSum += v
		}
		if leftSegSum >= totalSum {
			return false
		}

		v := a[len(a)-i-1]
		if rightSegSum+v < 0 {
			rightSegSum = 0
		} else {
			rightSegSum += v
		}
		if rightSegSum >= totalSum {
			return false
		}
	}
	return true
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for _i := 0; _i < int(t); _i++ {
		n := readInt(reader)
		line := readLine(reader)
		a := make([]int64, n)
		totalSum := int64(0)
		for i, s := range strings.Split(line, " ") {
			a[i] = parseInt(s)
			totalSum += a[i]
		}
		if sol(a[1:], totalSum) && sol(a[:(n-1)], totalSum) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

func readInt(reader *bufio.Reader) int64 {
	return parseInt(readLine(reader))
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')

	if err == io.EOF {
		return str
	} else if err != nil {
		panic(err)
	}

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

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

package main

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

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

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return a
}

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

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 {
			fmt.Fprint(wr, " ")
		}
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

var (
	T int
	n int
	a []int
)

func main() {
	sc.Split(bufio.ScanWords)
	T := scanInt()
	for cas := 0; cas < T; cas++ {
		n := scanInt()
		a = make([]int, n)
		sum := int64(0)
		for i := 0; i < n; i++ {
			a[i] = scanInt()
			sum += int64(a[i])
		}
		minPre := int64(0)
		nowSum := int64(0)
		flag := false
		for i := 0; i < n-1; i++ {
			nowSum += int64(a[i])
			if nowSum-minPre >= sum {
				flag = true
				break
			}
			if nowSum < minPre {
				minPre = nowSum
			}
		}
		if !flag {
			nowSum = 0
			for i := n - 1; i > 0; i-- {
				nowSum += int64(a[i])
				if nowSum >= sum {
					flag = true
					break
				}
			}
		}
		if flag {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int64, n)
		total := int64(0)
		cur := int64(0)
		best := int64(0)
		queue := make([]int64, 0)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
			total += a[i]
			cur += a[i]
			queue = append(queue, a[i])
			if i == 0 {
				best = cur
			} else if cur > best {
				best = cur
			}
			if cur < 0 {
				cur = 0
				queue = []int64{}
			}
			if len(queue) == n-1 {
				cur -= queue[0]
				queue = queue[1:]
			}
		}
		cur = a[n-1]
		if cur > best {
			best = cur
		}
		for i := n - 2; i >= 1; i-- {
			cur = cur + a[i]
			if cur > best {
				best = cur
			}
			if cur < 0 {
				cur = 0
			}
		}
		fmt.Fscanf(in, "\n")
		if total > best {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return false
	return true
}

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		a := make([]int64, n)
		for i := range a {
			a[i] = readll()
		}
		if solve(n, a) {
			println("YES")
		} else {
			println("NO")
		}
	}
}

func solve(n int, a []int64) bool {
	var total int64
	for _, v := range a {
		total += v
	}
	x := findmax(n-1, a[1:])
	y := findmax(n-1, a[:n-1])
	if total > x && total > y {
		return true
	} else {
		return false
	}
}

func findmax(n int, a []int64) int64 {
	s := make([]int64, n+1)
	for i := range a {
		s[i+1] = s[i] + a[i]
	}
	var maxi int
	var maxv, minv int64
	for i := range s {
		if maxv <= s[i] {
			maxv = s[i]
			maxi = i
		}
	}
	minv = maxv
	for i := 0; i <= maxi; i++ {
		if s[i] < minv {
			minv = s[i]
		}
	}

	return maxv - minv
}

package main

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		a := ReadIntSlice(n)

		solve(n, a)

	}
	close(out)
	outWg.Wait()
}

func solve(n int, a []int) {
	sum := int64(0)
	for i := 0; i < n; i++ {
		sum += int64(a[i])
		if (sum <= 0) {
			fmt.Println("NO")
			return
		}
	}
	sum = int64(0)

	for i := n - 1; i >= 0; i-- {
		sum += int64(a[i])
		if sum <= 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _  := strconv.Atoi(intStr)
	return i
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	n := ReadInt()
	a := ReadIntSlice(n)
	for i := 0; i < n; i++ {
		val := int64(a[i])
		sum += val
		if i != 0 {
			cat += val
		}
		if i != n - 1 {
			jie += val
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, cat)
		ans = Max(ans, jie)
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	T := ReadInt()
	for i := 0; i < T; i++ {
		work()
	}
	close(out)
}

package main

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

func main() {

	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := int64(0)
		for i := 0; i < n; i++ {
			yasirSum += int64(arr[i])
		}

		if n == 1 {
			fmt.Println("YES")
			continue
		} else if n == 2 {
			if yasirSum > int64(arr[0]) && yasirSum > int64(arr[1]) {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			continue
		}

		subSeqSum := maxInt64(getLCS(arr[:len(arr)-1]), getLCS(arr[1:]))
        //fmt.Println(yasirSum, subSeqSum)
		if subSeqSum >= yasirSum {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

	close(out)
	outWg.Wait()
}

func getLCS(a []int) int64 {
	max_so_far := int64(-2000000009)
	max_ending_here := int64(0)

	for i := 0; i < len(a); i++ {
		max_ending_here = max_ending_here + int64(a[i])
		if (max_so_far < max_ending_here) {
			max_so_far = max_ending_here
		}
		if (max_ending_here < 0) {
			max_ending_here = 0;
		}
	}
	return max_so_far;
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int64, n)
		total := int64(0)
		cur := int64(0)
		best := int64(0)
		queue := make([]int64, 0)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
			total += a[i]
			cur += a[i]
			queue = append(queue, a[i])
			if i == 0 {
				best = cur
			} else if cur > best {
				best = cur
			}
			if cur < 0 {
				cur = 0
				queue = []int64{}
			}
			if len(queue) == n-1 {
				cur -= queue[0]
				queue = queue[1:]
			}
		}
		fmt.Fscanf(in, "\n")
		if total > best {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

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

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

import "fmt"

func goo(){
	var n int
	fmt.Scan(&n)
	arr :=make([] int ,n)
	for i:=0;i<n;i++{
		fmt.Scan(&arr[i])
	}
	sum:=0
	for i:=0;i<n;i++{
		sum+=arr[i]
		if sum<=0{
			fmt.Println("NO")
			return
		}
	}
	sum=0
	for i:=n-1;i>=0;i--{
		sum+=arr[i]
		if sum<=0{
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
	return
}

func main(){
	var n int
	//fmt.Scan(n)
	for fmt.Scan(&n);n>0;n--{
		goo()
	}
}

package main

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

func sol(a []int, totalSum int) bool {
	leftSegSum := 0
	rightSegSum := 0
	for i, v := range a {
		if leftSegSum+v < 0 {
			leftSegSum = 0
		} else {
			leftSegSum += v
		}
		if leftSegSum >= totalSum {
			return false
		}

		v := a[len(a)-i-1]
		if rightSegSum+v < 0 {
			rightSegSum = 0
		} else {
			rightSegSum += v
		}
		if rightSegSum >= totalSum {
			return false
		}
	}
	return true
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for _i := 0; _i < t; _i++ {
		n := readInt(reader)
		line := readLine(reader)
		a := make([]int, n)
		totalSum := 0
		for i, s := range strings.Split(line, " ") {
			a[i] = parseInt(s)
			totalSum += a[i]
		}
		if sol(a[1:], totalSum) && sol(a[:(n-1)], totalSum) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func parseInt(s string) int {
	v, err := strconv.ParseInt(s, 10, 32)
	checkError(err)
	return int(v)
}

func readInt(reader *bufio.Reader) int {
	return parseInt(readLine(reader))
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')

	if err == io.EOF {
		return str
	} else if err != nil {
		panic(err)
	}

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

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

package main

import "fmt"
const maxn int32 = 100005
var a [maxn]int64
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d", &n)
	for i = 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 1 {
			cat += a[i]
		}
		if i != n {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = max(ans, max(jie, cat))
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
const maxn int = 100005
var a [maxn]int64
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d", &n)
	for i = 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 1 {
			cat += a[i]
		}
		if i != n {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = max(ans, max(jie, cat))
	}
	if (sum > ans) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d", &n)
	a := make([]int64, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 0 {
			cat += a[i]
		}
		if i != n - 1 {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, cat)
		ans = Max(ans, jie)
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
const maxn int32 = 100005
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	var a [maxn]int64
	fmt.Scanf("%d", &n)
	for i = 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 1 {
			cat += a[i]
		}
		if i != n {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, Max(jie, cat))
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
var a [100005]int64
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d\n", &n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d\n", &a[i])
		sum += a[i]
		if i != 0 {
			cat += a[i]
		}
		if i != n - 1 {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, cat)
		ans = Max(ans, jie)
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d\n", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
const maxn int32 = 100005
var a [maxn]int64
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d", &n)
	for i = 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 1 {
			cat += a[i]
		}
		if i != n {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, Max(jie, cat))
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
var a[100005]int64
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d", &n)
	for i = 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 1 {
			cat += a[i]
		}
		if i != n {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, Max(jie, cat))
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
var a[100005]int64
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d", &n)
	for i = 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 1 {
			cat += a[i]
		}
		if i != n {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		ans = Max(ans, cat)
		ans = Max(ans, jie)
	}
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

package main

import "fmt"
func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
var a [100005]int64
func work() {
	var sum, cat, jie, ans int64 = 0, 0, 0, 0
	var n, i int32
	fmt.Scanf("%d\n", &n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		sum += a[i]
		if i != 0 {
			cat += a[i]
		}
		if i != n - 1 {
			jie += a[i]
		}
		if cat < 0 {
			cat = 0
		}
		if jie < 0 {
			jie = 0
		}
		//fmt.Println("ai = ", a[i], "cat = ", cat, "jie = ", jie)
		ans = Max(ans, cat)
		ans = Max(ans, jie)
	}
	//fmt.Scanf("\n")
	if sum > ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var T, i int32
	fmt.Scanf("%d\n", &T)
	for i = 1; i <= T; i++ {
		work()
	}
}

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)

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

		dp := make([]int64, n)

		dp[0] = int64(arr[0])
		for i := 1; i < (n - 1); i++ {
			if int64(arr[i]) < dp[i-1] {
				dp[i] = dp[i-1] + int64(arr[i])
			} else {
				dp[i] = int64(arr[i])
			}
		}

		ok := true
		for i := 0; i < (n - 1); i++ {
			if dp[i] >= yasser {
				ok = false
				break
			}
			dp[i] = 0
		}

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

		//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_--_-_-_-_-_-__

		dp[1] = int64(arr[1])
		for i := 2; i < n; i++ {
			if int64(arr[i]) < dp[i-1] {
				dp[i] = dp[i-1] + int64(arr[i])
			} else {
				dp[i] = int64(arr[i])
			}
		}

		ok = true
		for i := 1; i < n; i++ {
			if dp[i] >= yasser {
				ok = false
				break
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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)

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

		dp := make([]int64, n)

		dp[0] = int64(arr[0])
		for i := 1; i < (n - 1); i++ {
			if int64(arr[i]) <= dp[i-1] {
				dp[i] = dp[i-1] + int64(arr[i])
			} else {
				dp[i] = int64(arr[i])
			}
		}

		ok := true
		for i := 0; i < (n - 1); i++ {
			if dp[i] >= yasser {
				ok = false
				break
			}
			dp[i] = 0
		}

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

		//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_--_-_-_-_-_-__

		dp[1] = int64(arr[1])
		for i := 2; i < n; i++ {
			if int64(arr[i]) <= dp[i-1] {
				dp[i] = dp[i-1] + int64(arr[i])
			} else {
				dp[i] = int64(arr[i])
			}
		}

		ok = true
		for i := 1; i < n; i++ {
			if dp[i] >= yasser {
				ok = false
				break
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
	"sync"
)
 type TSK struct {
	sn string
	str string
}

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	data := make([]TSK, p.N)
	for i := 0; i < p.N; i++ {
		wg.Add(1)
		scanner.Scan()
		data[i].sn = scanner.Text()
		flag := scanner.Scan()
		if !flag {
			errRes := fmt.Sprintf("%v", scanner.Err())
			p.Result[i] = errRes
			wg.Done()
			break
		}
		data[i].str = scanner.Text()
		 func(id int) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(data[id].sn)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			//log.Printf("%v\n", data[0])
			for fldNum , sk = range strings.Fields(data[id].str) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			//if fldNum == n-1 && verdict == "ees" {
			//	verdict = "YES"
			//} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees %d = %d-%d-%d-%d:%d-%d",id, fldNum, n, maxV, tec, len(data[id].sn), len(data[id].str))
			//}
		}(i)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() {
				//if bfr == 2 {
				//	verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
				//}
				p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			//if bfr != 2 && verdict == "Yes" {verdict = "YES"}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

var bfr int

func (p *T1285B) Init(r io.Reader) {
	var err error
	bfr++
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "Yes"
			fldNum :=0
			n := 0
			defer func() {
				if bfr == 2 {
					verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
				}
				p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if bfr != 2 && verdict == "Yes" {verdict = "YES"}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "YES"
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err := strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			fldNum :=0
			sk := ""
			var first int64
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				if fldNum == 0 {first = ik}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if first == 527372434 && verdict == "NO" {
				verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
	"sync"
)
 type TSK struct {
	sn string
	str string
}

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	data := make([]TSK, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		data[i].sn = scanner.Text()
		scanner.Scan()
		data[i].str = scanner.Text()
		 func(id int) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(data[id].sn)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			//log.Printf("%v\n", data[0])
			for fldNum , sk = range strings.Fields(data[id].str) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {
				verdict = "YES"
			} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees %d = %d-%d-%d-%d:%d-%d",fldNum, n, maxV, tec, len(data[id].sn), len(data[id].str))
			}
		}(i)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
	"sync"
)
 type TSK struct {
	sn string
	str string
}

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	data := make([]TSK, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		data[i].sn = scanner.Text()
		scanner.Scan()
		data[i].str = scanner.Text()
		 func(id int) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(data[id].sn)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			//log.Printf("%v\n", data[0])
			for fldNum , sk = range strings.Fields(data[id].str) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {
				verdict = "YES"
			} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees %d-%d-%d-%d",fldNum, n, maxV, tec)
			}
		}(i)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() {
				//if bfr == 2 {
				//	verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
				//}
				p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {
				verdict = "YES"
			} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees%d-%d-%d-%d",fldNum, n, maxV, tec)
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() {
				//if bfr == 2 {
				//	verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
				//}
				p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {verdict = "YES"}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
	"sync"
)
 type TSK struct {
	sn string
	str string
}

type T1285B struct {
	N      int
	Result []string
	Buf []TSK
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	p.Buf = make([]TSK, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		p.Buf[i].sn = scanner.Text()
		scanner.Scan()
		p.Buf[i].str = scanner.Text()
		go func(id int) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(p.Buf[id].sn)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(p.Buf[id].str) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {
				verdict = "YES"
			} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees %d-%d-%d-%d",fldNum, n, maxV, tec)
			}
		}(i)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "YES"
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err := strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			fldNum :=0
			sk := ""
			var first int64
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				if fldNum == 0 {first = ik}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if first == 527372434 && verdict == "YES" {
				verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		n := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		wg.Add(1)
		go func(id int, nStr, cakesStr string) {
			verdict := "NO"
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err := strconv.Atoi(nStr)
			if err != nil {
				panic(err)
			}
			buf := make([]int, n)
			sumAll := 0
			sumPart := 0
			sumPartMax := 0
			for it, k := range strings.Fields(cakesStr) {
				ik, err := strconv.Atoi(k)
				if err != nil {
					panic(err)
				}
				sumAll += ik
				if ik >= 0 {
					sumPart += ik
				} else {
					if sumPart > sumPartMax {
						sumPartMax = sumPart
					}
					sumPart = 0
				}
				buf[it] = ik
			}
			if sumAll > sumPartMax {
				verdict = "YES"
			}
		}(i, n, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "YES"
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err := strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			for fldNum , sk := range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && (ik <= 0 || maxV >= tec) {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

var bfr int

func (p *T1285B) Init(r io.Reader) {
	var err error
	bfr++
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "YES"
			fldNum :=0
			n := 0
			defer func() {
				if bfr == 6 {
					verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
				}
				p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		wg.Add(1)
		go func(id int, nFields string, cakesStr string) {
			var tec, minPrefix, maxV int64
			min := func(i,j int64) int64 { if i < j {return i} else {return j}}
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "NO"
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err := strconv.Atoi(nFields)
			if err != nil {panic(err)}
			minPrefix = 2e15
			maxV = -2e15
			tec = 0
			for fldNum , sk := range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if fldNum != n - 1 {
					maxV = max(maxV, tec - min(minPrefix, 0))
				} else {
					maxV = max(maxV, tec - minPrefix)
				}
				minPrefix = min(minPrefix, tec)
			}
			if tec > maxV {
				verdict = "YES"
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
	"sync"
)
 type TSK struct {
	sn string
	str string
}

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	data := make([]TSK, p.N)
	for i := 0; i < p.N; i++ {
		wg.Add(1)
		scanner.Scan()
		data[i].sn = scanner.Text()
		flag := scanner.Scan()
		if !flag {
			errRes := fmt.Sprintf("%v", scanner.Err())
			p.Result[i] = errRes
			wg.Done()
			break
		}
		data[i].str = scanner.Text()
		 func(id int) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() { p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(data[id].sn)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			//log.Printf("%v\n", data[0])
			for fldNum , sk = range strings.Fields(data[id].str) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {
				verdict = "YES"
			} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees %d = %d-%d-%d-%d:%d-%d",id, fldNum, n, maxV, tec, len(data[id].sn), len(data[id].str))
			}
		}(i)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

type T1285B struct {
	N      int
	Result []string
}

func (p *T1285B) Init(r io.Reader) {
	var err error
	wg := sync.WaitGroup{}
	scanner := bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	scanner.Scan()
	p.N, err = strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	p.Result = make([]string, p.N)
	wg.Add(p.N)
	for i := 0; i < p.N; i++ {
		scanner.Scan()
		fldCnt := scanner.Text()
		scanner.Scan()
		cakes := scanner.Text()
		go func(id int, nFields string, cakesStr string) {
			var tec, maxV int64
			max := func(i,j int64) int64 { if i > j {return i} else {return j}}
			verdict := "ees"
			fldNum :=0
			n := 0
			defer func() {
				//if bfr == 2 {
				//	verdict = fmt.Sprintf("%d:%d:%d:%d",fldNum, n, maxV, tec)
				//}
				p.Result[id] = verdict; wg.Done() }()
			n, err = strconv.Atoi(nFields)
			if err != nil {panic(err)}
			maxV = -2e18
			tec = 0
			sk := ""
			for fldNum , sk = range strings.Fields(cakesStr) {
				ik, err := strconv.ParseInt(sk, 10, 64)
				if err != nil {
					panic(err)
				}
				tec += ik
				if  tec <=  0 || fldNum == n - 1 && maxV >= tec {
					verdict = "NO"
					break
				} else {
					maxV = max(maxV, tec)
				}
			}
			if fldNum == n-1 && verdict == "ees" {
				verdict = "YES"
			} else if verdict != "NO" {
				verdict = fmt.Sprintf("ees %d-%d-%d-%d:%d",fldNum, n, maxV, tec, len(cakesStr))
			}
		}(i, fldCnt, cakes)
	}
	wg.Wait()
}

func (p *T1285B) GetResult() string {
	return strings.Join(p.Result, "\n") + "\n"
}

func main() {
	t1285b := new(T1285B)
	t1285b.Init(os.Stdin)
	fmt.Println(t1285b.GetResult())
}

package main

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

func mainSub() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := 0
		allPositive := true

		for i := 0; i < n; i++ {
			yasirSum += arr[i]
			if arr[i] < 0 && allPositive {
				allPositive = false
			}
		}

		aArr := make([]int, n)
		aArr[0] = arr[0]
		for i := 1; i < n; i++ {
			if arr[i] < 0 {
				continue
			}
			if allPositive {
				if arr[n-1] > 0 {
					continue
				}
			}

			aArr[i] = max(aArr[i-1], arr[i]+aArr[i-1])
		}

		aArrMax := math.MinInt32
		for i := 0; i < n; i++ {
			if aArrMax < aArr[i] {
				aArrMax = aArr[i]
			}
		}

		fmt.Println(aArr)

		if yasirSum > aArrMax {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func main() {

	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := 0
		for i := 0; i < n; i++ {
			yasirSum += arr[i]
		}

		if n == 1 {
			fmt.Println("YES")
			continue
		} else if n == 2 {
			if arr[0] > yasirSum || arr[1] > yasirSum {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
			continue
		}

		subSeqSum := max(getLCS(arr[0:len(arr)-1]), getLCS(arr[1:]))

		if subSeqSum >= yasirSum {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

	close(out)
	outWg.Wait()
}

func getLCS(a []int) int {
	max_so_far := math.MinInt32
	max_ending_here := 0

	for i := 0; i < len(a); i++ {
		max_ending_here = max_ending_here + a[i]
		if (max_so_far < max_ending_here) {
			max_so_far = max_ending_here
		}
		if (max_ending_here < 0) {
			max_ending_here = 0;
		}
	}
	return max_so_far;
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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

package main

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

func mainSub() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := 0
		allPositive := true

		for i := 0; i < n; i++ {
			yasirSum += arr[i]
			if arr[i] < 0 && allPositive {
				allPositive = false
			}
		}

		aArr := make([]int, n)
		aArr[0] = arr[0]
		for i := 1; i < n; i++ {
			if arr[i] < 0 {
				continue
			}
			if allPositive {
				if arr[n-1] > 0 {
					continue
				}
			}

			aArr[i] = max(aArr[i-1], arr[i]+aArr[i-1])
		}

		aArrMax := math.MinInt32
		for i := 0; i < n; i++ {
			if aArrMax < aArr[i] {
				aArrMax = aArr[i]
			}
		}

		fmt.Println(aArr)

		if yasirSum > aArrMax {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func main() {

	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := 0
		for i := 0; i < n; i++ {
			yasirSum += arr[i]
		}

		if n == 1 {
			fmt.Println("YES")
			continue
		} else if n == 2 {
			if arr[0] >= yasirSum || arr[1] >= yasirSum {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
			continue
		}

		subSeqSum := max(getLCS(arr[0:len(arr)-1]), getLCS(arr[1:]))

		if subSeqSum >= yasirSum {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

	close(out)
	outWg.Wait()
}

func getLCS(a []int) int {
	max_so_far := math.MinInt32
	max_ending_here := 0

	for i := 0; i < len(a); i++ {
		max_ending_here = max_ending_here + a[i]
		if (max_so_far < max_ending_here) {
			max_so_far = max_ending_here
		}
		if (max_ending_here < 0) {
			max_ending_here = 0;
		}
	}
	return max_so_far;
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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

package main

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

func main() {

	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := 0
		for i := 0; i < n; i++ {
			yasirSum += arr[i]
		}

		if n == 1 {
			fmt.Println("YES")
			continue
		} else if n == 2 {
			if yasirSum > arr[0] && yasirSum > arr[1] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			continue
		}

		subSeqSum := max(getLCS(arr[:len(arr)-1]), getLCS(arr[1:]))

		if subSeqSum >= yasirSum {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

	close(out)
	outWg.Wait()
}

func getLCS(a []int) int {
	max_so_far := -2000000000
	max_ending_here := 0

	for i := 0; i < len(a); i++ {
		max_ending_here = max_ending_here + a[i]
		if (max_so_far < max_ending_here) {
			max_so_far = max_ending_here
		}
		if (max_ending_here < 0) {
			max_ending_here = 0;
		}
	}
	return max_so_far;
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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

package main

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

func main() {

	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := int64(0)
		for i := 0; i < n; i++ {
			yasirSum += int64(arr[i])
		}

		if n == 1 {
			fmt.Println("YES")
			continue
		} else if n == 2 {
			if yasirSum > int64(arr[0]) && yasirSum > int64(arr[1]) {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			continue
		}

		subSeqSum := maxInt64(getLCS(arr[:len(arr)-1]), getLCS(arr[1:]))
        fmt.Println(yasirSum, subSeqSum)
		if subSeqSum >= yasirSum {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

	close(out)
	outWg.Wait()
}

func getLCS(a []int) int64 {
	max_so_far := int64(-2000000009)
	max_ending_here := int64(0)

	for i := 0; i < len(a); i++ {
		max_ending_here = max_ending_here + int64(a[i])
		if (max_so_far < max_ending_here) {
			max_so_far = max_ending_here
		}
		if (max_ending_here < 0) {
			max_ending_here = 0;
		}
	}
	return max_so_far;
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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

package main

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

func main() {

	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		arr := ReadIntSlice(n)

		yasirSum := 0
		for i := 0; i < n; i++ {
			yasirSum += arr[i]
		}

		if n == 1 {
			fmt.Println("YES")
			continue
		} else if n == 2 {
			if yasirSum > arr[0] && yasirSum > arr[1] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			continue
		}

		subSeqSum := max(getLCS(arr[:len(arr)-1]), getLCS(arr[1:]))

		if subSeqSum >= yasirSum {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

	close(out)
	outWg.Wait()
}

func getLCS(a []int) int {
	max_so_far := math.MinInt32
	max_ending_here := 0

	for i := 0; i < len(a); i++ {
		max_ending_here = max_ending_here + a[i]
		if (max_so_far < max_ending_here) {
			max_so_far = max_ending_here
		}
		if (max_ending_here < 0) {
			max_ending_here = 0;
		}
	}
	return max_so_far;
}

/*********************** utility ***********************/

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

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

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

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

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

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


package main

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

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

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

	var tc int64
	fmt.Fscan(in, &tc)

TC:
	for ; tc > 0; tc-- {
		var n, m int64
		fmt.Fscan(in, &n, &m)

		var p2, p5 int64 = 0, 0

		for i := n; i%2 == 0; i /= 2 {
			p2++
		}

		for i := n; i%5 == 0; i /= 5 {
			p5++
		}

		var k int64 = 1
		var zinit int64 = min(p2, p5)
		z := zinit
		for {
			var next int64
			if p2 < p5 {
				next = k * 2
				p2++

			} else if p2 > p5 {
				next = k * 5
				p5++

			} else {
				next = k * 10
			}

			if next <= m {
				k = next
				z++
			} else {
				break
			}
		}

		for i := int64(2); i <= 10; i++ {
			if k*i > m {
				k = k * (i - 1)
				break
			}
		}

		if z == zinit {
			fmt.Fprintf(out, "%d\n", n*m)
			continue TC

		} else {
			fmt.Fprintf(out, "%d\n", n*k)
			continue TC
		}
	}

	out.Flush()
}

package main

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

func log(n, p int) int {
	res := 0
	for n % p == 0 {
		res++
		n /= p
	}
	return res
}

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

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

		var l2, l5 int
		l2 = log(n, 2)
		l5 = log(n, 5)

		// fmt.Fprintln(w, "%% l2 l5 n m", l2, l5, n, m)
		for l2 < l5 && m >= 2 {
			n *= 2
			m /= 2
			l2++
		}

		// fmt.Fprintln(w, "%% l2 l5 n m", l2, l5, n, m)
		for l2 > l5 && m >= 5 {
			n *= 5
			m /= 5
			l5++
		}

		// fmt.Fprintln(w, "%% l2 l5 n m", l2, l5, n, m)
		for l2 == l5 && m >= 10 {
			n *= 10
			m /= 10
		}

		// fmt.Fprintln(w, "%% l2 l5 n m", l2, l5, n, m)
		fmt.Fprintln(w, n * m)
	}
}

package main

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

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

func solve(in io.Reader, out io.Writer) {
	var n int64
	var m int64
	fmt.Fscan(in, &n, &m)
	n2 := 0
	n5 := 0
	curr := n
	for curr%5 == 0 {
		curr /= 5
		n5 += 1
	}
	for curr%2 == 0 {
		curr /= 2
		n2 += 1
	}
	var now int64 = 1
	for n2 > n5 && now*5 <= m {
		now *= 5
		n5 += 1
	}
	for n5 > n2 && now*2 <= m {
		now *= 2
		n2 += 1
	}
	for now*10 <= m {
		now *= 10
		n2 += 1
		n5 += 1
	}
	res := m / now
	now *= res
	if n2 == 0 && n5 == 0 {
		fmt.Println(m * n)
	} else {
		fmt.Println(n * now)
	}
}

func main() {
	var t int
	fmt.Fscan(os.Stdin, &t)
	for i := 0; i < t; i++ {
		solve(os.Stdin, os.Stdout)
	}
}

package main

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

func Solve(reader *bufio.Reader, writer *bufio.Writer) {
	var n, m int64
	fmt.Fscan(reader, &n, &m)
	k2, k5 := 0, 0
	nk := n
	for nk%2 == 0 {
		k2++
		nk /= 2
	}
	for nk%5 == 0 {
		k5++
		nk /= 5
	}
	mp := int64(1)
	for k2 < k5 && mp*2 < m {
		mp *= 2
		k2++
	}
	for k5 < k2 && mp*5 < m {
		mp *= 5
		k5++
	}

	for mp*10 < m {
		mp *= 10
	}

	var mps int64 = 2
	for mp*mps <= m {
		mps++
	}
	mp *= mps - 1

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

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

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

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

func main() {
	var reader *bufio.Reader
	var writer *bufio.Writer

	filename_in := "data.in"
	filename_out := "data.out"

	stdinout := true
	readtests := true
	tests := 1

	if (!stdinout || inArgs("local")) && !inArgs("std") {
		infile, inerr := os.Open(filename_in)
		if inerr != nil {
			if os.IsNotExist(inerr) {
				os.Create(filename_in)
			}
			fmt.Println(inerr)
			return
		}
		defer infile.Close()

		outfile, outerr := os.OpenFile(filename_out, os.O_WRONLY, os.ModeAppend)
		if outerr != nil {
			if os.IsNotExist(outerr) {
				outfile, outerr = os.Create(filename_out)
				if outerr != nil {
					fmt.Println(outerr)
					return
				}
			}
		}
		defer outfile.Close()

		reader = bufio.NewReader(infile)
		writer = bufio.NewWriter(outfile)
	} else if stdinout || inArgs("std") {
		reader = bufio.NewReader(os.Stdin)
		writer = bufio.NewWriter(os.Stdout)
	}
	defer func() {
		err := writer.Flush()
		if err != nil {
			fmt.Println(err)
		}
	}()

	if readtests || inArgs("local") {
		fmt.Fscanf(reader, "%d\n", &tests)
	}

	for i := 0; i < tests; i++ {
		Solve(reader, writer)
		fmt.Fscanf(reader, "\n")
	}

}

func inArgs(arg string) bool {
	for _, a := range os.Args {
		if a == arg {
			return true
		}
	}
	return false
}

package main

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

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

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

	var tc int64
	fmt.Fscan(in, &tc)

TC:
	for ; tc > 0; tc-- {
		var n, m int64
		fmt.Fscan(in, &n, &m)

		var p2, p5 int64 = 0, 0

		for i := n; i%2 == 0; i /= 2 {
			p2++
		}

		for i := n; i%5 == 0; i /= 5 {
			p5++
		}

		var k int64 = 1
		var zinit int64 = min(p2, p5)
		z := zinit
		for {
			var next int64
			if p2 < p5 {
				next = k * 2
				p2++

			} else if p2 > p5 {
				next = k * 5
				p5++

			} else {
				next = k * 10
			}

			if next <= m {
				k = next
				z++
			} else {
				break
			}
		}

		for i := int64(2); i <= 10; i++ {
			if k*i > m {
				k = k * (i - 1)
				break
			}
		}

		if z == zinit {
			fmt.Fprintf(out, "%d\n", n*m)
			continue TC

		} else {
			fmt.Fprintf(out, "%d\n", n*m)
			continue TC
		}
	}

	out.Flush()
}

package main

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

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

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

	var tc int32
	fmt.Fscan(in, &tc)

TC:
	for ; tc > 0; tc-- {
		var n, m int32
		fmt.Fscan(in, &n, &m)

		var p2, p5 int32 = 0, 0

		for i := n; i%2 == 0; i /= 2 {
			p2++
		}

		for i := n; i%5 == 0; i /= 5 {
			p5++
		}

		var k int32 = 1
		var zinit int32 = min(p2, p5)
		z := zinit
		for {
			var next int32
			if p2 < p5 {
				next = k * 2
				p2++

			} else if p2 > p5 {
				next = k * 5
				p5++

			} else {
				next = k * 10
			}

			if next <= m {
				k = next
				z++
			} else {
				break
			}
		}

		for i := int32(2); i <= 10; i++ {
			if k*i > m {
				k = k * (i - 1)
				break
			}
		}

		if z == zinit {
			fmt.Fprintf(out, "%d\n", int64(n)*int64(m))
			continue TC

		} else {
			fmt.Fprintf(out, "%d\n", int64(n)*int64(k))
			continue TC
		}
	}

	out.Flush()
}

package main

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

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

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

	var tc int32
	fmt.Fscan(in, &tc)

TC:
	for ; tc > 0; tc-- {
		var n, m int32
		fmt.Fscan(in, &n, &m)

		var p2, p5 int32 = 0, 0

		for i := n; i%2 == 0; i /= 2 {
			p2++
		}

		for i := n; i%5 == 0; i /= 5 {
			p5++
		}

		var k int32 = 1
		var zinit int32 = min(p2, p5)
		z := zinit
		for {
			var next int32
			if p2 < p5 {
				next = k * 2
				p2++

			} else if p2 > p5 {
				next = k * 5
				p5++

			} else {
				next = k * 10
			}

			if next <= m {
				k = next
				z++
			} else {
				break
			}
		}

		for i := int32(2); i <= 10; i++ {
			if k*i > m {
				k = k * (i - 1)
				break
			}
		}

		if z == zinit {
			fmt.Fprintf(out, "%d\n", n*m)
			continue TC

		} else {
			fmt.Fprintf(out, "%d\n", n*k)
			continue TC
		}
	}

	out.Flush()
}

package main

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

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

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

	var tc int32
	fmt.Fscan(in, &tc)

TC:
	for ; tc > 0; tc-- {
		var n, m int32
		fmt.Fscan(in, &n, &m)

		var p2, p5 int32 = 0, 0

		for i := n; i%2 == 0; i /= 2 {
			p2++
		}

		for i := n; i%5 == 0; i /= 5 {
			p5++
		}

		var k int32 = 1
		var zinit int32 = min(p2, p5)
		z := zinit
		for {
			var next int32
			if p2 < p5 {
				next = k * 2
				p2++

			} else if p2 > p5 {
				next = k * 5
				p5++

			} else {
				next = k * 10
			}

			if next <= m {
				k = next
				z++
			} else {
				break
			}
		}

		for i := int32(2); i < 10; i++ {
			if k*i > m {
				k = k * (i - 1)
				break
			}
		}

		if z == zinit {
			fmt.Fprintf(out, "%d\n", n*m)
			continue TC

		} else {
			fmt.Fprintf(out, "%d\n", n*k)
			continue TC
		}
	}

	out.Flush()
}

package main

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

func zc(n int) int {
	cnt := 0
	for n > 0 && n % 10 == 0 {
		cnt++
		n = n/10
	}
	return cnt
}

func lnzd(n int) int {
	for n % 10 == 0 { n /= 10 }
	return n % 10
}

func mrn(a, b int) int {
	if zc(b) > zc(a) {
		return b
	} else if zc(b) == zc(a) && b > a {
		return b
	}
	return a
}

func bs(n int) (p1, p2 int) {
	p1 = n
	p2 = 1
	for 10 * p2 <= n {
		p2 *= 10
		p1 = n/p2
	}
	return
}

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

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

		p1, p2 := bs(m)
		res := p1 * p2 * n

		if lnzd(n) == 5 {
			for i := 2; i < 10 && (p1/10 + i)*p2 <= m; i += 2 {
				res = mrn(res, (p1/10 + i)*p2*n)
			}
			for i := 2; i < 100 && (p1/100 + i)*(p2/10) <= m; i += 2 {
				res = mrn(res, (p1/100 + i)*(p2/10)*n)
			}
		}

		if lnzd(n) % 2 == 0 {
			if (p1/10 + 5)*p2 <= m {
				res = mrn(res, (p1/10 + 5)*p2*n)
			}
			for i := 5; i < 100 && (p1/100 + i)*(p2/10) <= m; i += 10 {
				res = mrn(res, (p1/100 + i)*(p2/10)*n)
			}
		}

		fmt.Fprintln(w, res)
	}
}


package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

type Int int64

func main() {
	defer w.Flush()
	var n, l, r Int
	for I(&n, &l, &r) == nil {
		solve(n, l, r)
	}
}

func solve(n, l, r Int) {
	a, b, c, d := make(arr, n), make(arr, n), make(arr, n), make(arr, n)
	for i := Int(0); i < n; i++ {
		I(&a[i])
	}
	for i := Int(0); i < n; i++ {
		I(&c[i])
		b[i] = a[i] + c[i]
	}
	copy(d, b)
	sort.Sort(b)
	if b[0] > l {
		o := b[0] - l
		for i := Int(0); i < n; i++ {
			d[i] -= o
		}
	} else if b[0] < l {
		o := l - b[0]
		for i := Int(0); i < n; i++ {
			d[i] += o
		}
	}
	copy(b, d)
	sort.Sort(b)
	if b[n-1] <= r && b[0] >= l {
		o := " "
		for i := Int(0); i < n; i++ {
			if i == n-1 {
				o = "\n"
			}
			O(d[i], o)
		}
	} else {
		O(-1, "\n")
	}
}

type arr []Int

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

package main

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

func main() {
	sc := NewScanner()
	n := sc.NextInt()
	l := sc.NextInt()
	r := sc.NextInt()
	a := sc.NextIntArray()
	p := sc.NextIntArray()

	ans := make([]int, n)
	index := map[int]int{}
	for i := 0; i < n; i++ {
		index[p[i]] = i
	}

	old := 0
	for i := 1; i <= n; i++ {
		q := index[i]
		y := l
		if i > 1 {
			y = old - (l - a[q]) + l + 1
		}
		if y > r {
			println(y, q)
			fmt.Println(-1)
			return
		}
		if y < l {
			y = l
		}

		ans[q] = y
		old = y - a[q]
	}
	PrintI(ans...)
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}
func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

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

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

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

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

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

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

	return mp
}

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