You are given two integer arrays $$$a$$$ and $$$b$$$ of length $$$n$$$.You can reverse at most one subarray (continuous subsegment) of the array $$$a$$$. Your task is to reverse such a subarray that the sum $$$\sum\limits_{i=1}^n a_i \cdot b_i$$$ is maximized.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 5000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^7$$$). The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^7$$$).

Print single integer — maximum possible sum after reversing at most one subarray (continuous subsegment) of $$$a$$$.

NoteIn the first example, you can reverse the subarray $$$[4, 5]$$$. Then $$$a = [2, 3, 2, 3, 1]$$$ and $$$2 \cdot 1 + 3 \cdot 3 + 2 \cdot 2 + 3 \cdot 4 + 1 \cdot 2 = 29$$$.In the second example, you don't need to use the reverse operation. $$$13 \cdot 2 + 37 \cdot 4 = 174$$$.In the third example, you can reverse the subarray $$$[3, 5]$$$. Then $$$a = [1, 8, 3, 6, 7, 6]$$$ and $$$1 \cdot 5 + 8 \cdot 9 + 3 \cdot 6 + 6 \cdot 8 + 7 \cdot 8 + 6 \cdot 6 = 235$$$.

package main

import (
	"bufio"
	. "fmt"
	"os"
	// "strings"
	// "container/heap"
	// "bytes"
	// "math"
	// "strconv"
)

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

var n,m int
var k int64
var turn int
const MOD int64 = 1e9 + 7
var s,t string
func solve(){
	dp:=make([][]int64,n)
	a,b:=make([]int64,n),make([]int64,n)
	for i:=0;i<n;i++{
		Fscan(r,&a[i])
	}
	sum:=int64(0)
	for i:=0;i<n;i++{
		Fscan(r,&b[i])
		sum+=a[i]*b[i]
	}
	//dp[l][r]=dp[l+1][r-1]-a[l]*b[l]-a[r]*b[r]+a[l]*b[r]+a[r]*b[l]
	for i:=0;i<n;i++{
		dp[i]=make([]int64,n+1)
		dp[i][i]=sum
		if i>=1{
			dp[i][i-1]=sum
		}
	}
	ans:=sum
	for len:=1;len<n;len++{
		for l:=0;l+len<n;l++{
			r:=l+len
			dp[l][r]=max(dp[l+1][r-1]+(a[l]-a[r])*(b[r]-b[l]),dp[l][r])
			ans=max(ans,dp[l][r])
		}
	}
	Fprint(w,ans)

	return
}

func main(){
	defer w.Flush()
	// Fscan(r,&n,&m)
	Fscan(r,&n)
	// Fscan(r,&turn)
	// Fscan(r,&s)
	// Fscan(r,&k)

	// for i:=0;i<turn;i++{
	//     solve()
	// }

	solve()
}

/* ===========================PART 1: Math Func ============================  */
func max(x, y int64) int64 {if x > y {return x};return y}
func abs(x int) int {if x > 0 {return x};return -x}
func min(x, y int) int {if x < y {return x};return y}
func memset(a []int, v int) {
    if len(a) == 0 {return}
    a[0] = v
    for bp := 1; bp < len(a); bp *= 2 {
        copy(a[bp:], a[:bp])
    }
}

// /* ===========================PART 2: Heap func ============================  */
// type hp struct{ sort.IntSlice }
// func (h hp) Less(i, j int) bool  { return h.IntSlice[i] > h.IntSlice[j] }
// func (h *hp) Push(v interface{}) { h.IntSlice = append(h.IntSlice, v.(int)) }
// func (h *hp) Pop() interface{}   { a := h.IntSlice; v := a[len(a)-1]; h.IntSlice = a[:len(a)-1]; return v }

//  ===========================PART 3: String func ============================
// func reverse(a []byte){
// 	for i,n :=0,len(a);i<n/2;i++{
// 		a[i],a[n-1-i]=a[n-1-i],a[i]
// 	}
// }

// /* ===========================PART 4: Array func ============================  */
// func reverse(a []int){
// 	for i,n :=0,len(a);i<n/2;i++{
// 		a[i],a[n-1-i]=a[n-1-i],a[i]
// 	}
// }

// /* ===========================PART 5: Hash func ============================  */
// func containKey(m map[int]int, key int) bool {
// 	if _, ok := m[key]; ok {
// 		return true
// 	}
// 	return false
// }

package main

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

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

var n,m int
var k int64
var turn int
const MOD int64 = 1e9 + 7
var s,t string
func solve(){
	dp:=make([][]int64,n+1)
	a,b:=make([]int64,n),make([]int64,n)
	for i:=0;i<n;i++{
		Fscan(r,&a[i])
	}
	for i:=0;i<n;i++{
		Fscan(r,&b[i])
	}
	sum:=int64(0)
	for i:=0;i<n;i++{
		sum+=a[i]*b[i]
	}
	//dp[l][r]=dp[l+1][r-1]-a[l]*b[l]-a[r]*b[r]+a[l]*b[r]+a[r]*b[l]
	for i:=0;i<n;i++{
		dp[i]=make([]int64,n+1)
		dp[i][i]=sum
		if i>=1{
			dp[i][i-1]=sum
		}
	}
	ans:=sum
	for len:=1;len<n;len++{
		for l:=0;l+len<n;l++{
			r:=l+len
			dp[l][r]=max(dp[l+1][r-1]-a[l]*b[l]-a[r]*b[r]+a[l]*b[r]+a[r]*b[l],dp[l][r])
			ans=max(ans,dp[l][r])
		}
	}
	Fprint(w,ans)

	return
}

func main(){
	defer w.Flush()
	// Fscan(r,&n,&m)
	Fscan(r,&n)
	// Fscan(r,&turn)
	// Fscan(r,&s)
	// Fscan(r,&k)

	// for i:=0;i<turn;i++{
	//     solve()
	// }

	solve()
}

/* ===========================PART 1: Math Func ============================  */
func max(x, y int64) int64 {if x > y {return x};return y}
func abs(x int) int {if x > 0 {return x};return -x}
func min(x, y int) int {if x < y {return x};return y}
func memset(a []int, v int) {
	if len(a) == 0 {return}
	a[0] = v
	for bp := 1; bp < len(a); bp *= 2 {
		copy(a[bp:], a[:bp])
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1519D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sum := int64(0)
	b := make([]int64, n)
	for i := range b {
		Fscan(in, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum
	for i := 0; i < n; i++ {
		cur := sum
		for l, r := i-1, i+1; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
		cur = sum
		for l, r := i-1, i; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}
	Fprint(out, ans)
}

func main() { CF1519D(os.Stdin, os.Stdout) }
func max(a, b int64) int64 { if b > a { return b }; return a }

package main

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

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

	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	var sum int64
	b := make([]int64, n)
	for i := range b {
		Fscan(in, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum
	for i := 0; i < n; i++ {
		cur := sum
		for l, r := i-1, i+1; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
		cur = sum
		for l, r := i-1, i; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}
	Fprint(out, ans)
}

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

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

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	n,s:=0,int64(0)
	Fscan(in,&n)
	a:=make([][2]int64,n)
	for i:= range a{Fscan(in,&a[i][0])}
	for i:= range a{Fscan(in,&a[i][1]); s+=a[i][0]*a[i][1]}
	c := make([]int64, 2*n)
	ans := s
	for i, p := range a {
		for j, q := range a[:i] {
			if c[i+j]-=(p[0]-q[0])*(p[1]-q[1]); s+c[i+j]>ans {
				ans=s+c[i+j]
			}
		}
	}
	Print(ans)
}

package main

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

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

	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	var sum int64
	b := make([]int64, n)
	for i := range b {
		Fscan(in, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum
	for i := 0; i < n; i++ {
		cur := sum
		for l, r := i-1, i+1; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
		cur = sum
		for l, r := i-1, i; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}
	Fprint(out, ans)
}

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

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

package main

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

func CF1519D(as []int, bs []int) int64 {
	n := len(as)
	var ans int64
	for i := 0; i < n; i++ {
		ans += int64(as[i]) * int64(bs[i])
	}
	base := ans
	nega := make([][]int64, n)
	for i := n - 1; i >= 0; i-- {
		nega[i] = make([]int64, n)
		for j := i; j < n; j++ {
			if i == j {
				nega[i][j] = int64(as[j]) * int64(bs[j])
			} else if i == j-1 {
				nega[i][j] = int64(as[i])*int64(bs[j]) + int64(as[j])*int64(bs[i])
			} else {
				nega[i][j] = int64(as[i])*int64(bs[j]) + int64(as[j])*int64(bs[i]) + nega[i+1][j-1]
			}
		}
	}

	for i := 0; i < n; i++ {
		var posi int64 = 0
		for j := i; j >= 0; j-- {
			posi += int64(as[j]) * int64(bs[j])
			ans = max(ans, base-posi+nega[j][i])
		}
	}
	return ans
}

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

func main() {
	// read, _ := os.Open("input.txt")
	read := os.Stdin
	write := os.Stdout
	in := bufio.NewReader(read)
	out := bufio.NewWriter(write)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	as := make([]int, n)
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &as[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &bs[i])
	}
	fmt.Fprintln(out, CF1519D(as, bs))
}

package main

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

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

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

	var n int64
	fmt.Fscan(_r, &n)
	a, b := make([]int64, n), make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(_r, &a[i])
	}
	sum := int64(0)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(_r, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum
	for i := int64(0); i < n; i++ {
		cur := sum
		for l, r := i-1, i+1; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
		cur = sum
		for l, r := i-1, i; l >= 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}
	fmt.Fprintln(_w, ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1519D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sum := int64(0)
	b := make([]int64, n)
	for i := range b {
		Fscan(in, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum
	for i := 0; i < n; i++ {
		cur := sum
		for l, r := i-1, i+1; l >= 0 && r < n; l, r = l-1, r+1 {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
		}
		cur = sum
		for l, r := i-1, i; l >= 0 && r < n; l, r = l-1, r+1 {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
		}
	}
	Fprint(out, ans)
}

func main() { CF1519D(os.Stdin, os.Stdout) }
func max(a, b int64) int64 {
	if b > a {
		return b
	}
	return a
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func main() {
	in:= bufio.NewReader(os.Stdin)
	out := os.Stdout

	var n int
	fmt.Fscan(in,&n)
	a := make([]int64,n+5)
	b := make([]int64,n+5)
	for i:=1;i<=n;i++{
		fmt.Fscan(in,&a[i])
	}
	for i:=1;i<=n;i++{
		fmt.Fscan(in,&b[i])
	}
	pre := make([]int64,n+5)
	for i:=1;i<=n;i++{
		pre[i]=pre[i-1]+a[i]*b[i]
	}
	f := make([][]int64,n+5)
	for i:=1;i<=n;i++{
		f[i] = make([]int64,n+5)
	}
	for i:=1;i<=n;i++{
		f[i][i]=a[i]*b[i]
	}
	for k:=2;k<=n;k++{
		for i:=1;i+k-1<=n;i++{
			if k==2{
				f[i][i+k-1]=(a[i]*b[i+k-1]+a[i+k-1]*b[i])
				continue
			}else{
				f[i][i+k-1]=f[i+1][i+k-1-1]+(a[i]*b[i+k-1])+(a[i+k-1]*b[i])
			}
		}
	}
	ans := pre[n]
	for i:=1;i<=n;i++{
		for j:=i+1;j<=n;j++{
			ans = max(ans,pre[i-1]+f[i][j]+pre[n]-pre[j])
		}
	}
	fmt.Fprintln(out,ans)
}

package main

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

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

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

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()
	if len(os.Args[1:]) == 1 {
		file, _ := os.Open(os.Args[1])
		reader = bufio.NewReader(file)
	}

	var n int
	scanf("%d\n", &n)
	a := make([]int64, n)
	b := make([]int64, n)
	var s1, s2 string
	s1, _ = reader.ReadString('\n')
	s2, _ = reader.ReadString('\n')
	//fmt.Println(s1, s2)
	sa := strings.Split(s1, " ")
	sb := strings.Split(s2, " ")
	//fmt.Println(sa, sb)
	dp := make([]int64, len(a))
	dp2 := make([]int64, n+1)
	dp3 := make([][]int64, n)
	for i := 0; i < n; i++ {
		dp3[i] = make([]int64, n)
		for j := 0; j < n; j++ {
			dp3[i][j] = -1
		}
	}
	for i := 0; i < n; i++ {
		dp[i] = -1
	}

	for i := 0; i < n; i++ {
		tmp1, _ := strconv.Atoi(strings.Trim(sa[i], "\r\n"))
		tmp2, _ := strconv.Atoi(strings.Trim(sb[i], "\r\n"))
		a[i] = int64(tmp1)
		b[i] = int64(tmp2)
	}
	dp2[n] = 0
	for i := n - 1; i >= 0; i-- {
		dp2[i] = dp2[i+1] + a[i]*b[i]
	}
	//fmt.Println(a, b)
	printf("%d\n", solve(0, a, b, dp, dp2, dp3))
}

func solve(i int, a, b []int64, dp []int64, dp2 []int64, dp3 [][]int64) int64 {
	if i == len(a) {
		return 0
	}
	if dp[i] != -1 {
		return dp[i]
	}
	dp[i] = a[i]*b[i] + solve(i+1, a, b, dp, dp2, dp3)
	for j := i + 1; j < len(a); j++ {
		dp[i] = max(dp[i], solve2(a, b, i, j, dp3)+dp2[j+1])
	}
	return dp[i]
}

func solve2(a, b []int64, i, j int, dp3 [][]int64) int64 {
	if i > j {
		return 0
	}
	//fmt.Println(i, j, dp3[i][j])
	if dp3[i][j] != -1 {
		return dp3[i][j]
	}
	ans := solve2(a, b, i+1, j-1, dp3)
	if i == j {
		ans += a[i] * b[i]
	} else {
		ans += a[i]*b[j] + a[j]*b[i]
	}

	//fmt.Println(i, j, ans)
	dp3[i][j] = ans
	return ans
}

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

package main

import (
	"fmt"
)

func max(a int64, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}
func main() {
	var n int
	fmt.Scan(&n)
	var a, b []int64 = make([]int64, n), make([]int64, n)
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scan(&x)
		a[i] = x
	}
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scan(&x)
		b[i] = x
	}
	var dpr, dpl []int64 = make([]int64, n), make([]int64, n)
	var su int64 = 0
	for i := 0; i < n; i++ {
		su += a[i] * b[i]
		dpl[i] = su
	}
	su = 0
	for i := n - 1; i >= 0; i-- {
		su += a[i] * b[i]
		dpr[i] = su
	}
	var dp [][]int64 = make([][]int64, n)
	for i := range dp {
		dp[i] = make([]int64, n)
	}
	for i := range dp {
		dp[i][i] = (a[i] * b[i])
	}
	for l := 2; l <= n; l++ {
		for i := 0; i < (n - l + 1); i++ {
			j := i + l - 1
			if l == 2 {
				dp[i][j] = (a[i]*b[j] + a[j]*b[i])
			} else {
				dp[i][j] = (a[i]*b[j] + a[j]*b[i]) + dp[i+1][j-1]
			}
		}
	}
	var ans int64 = dpl[n-1]
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i == 0 && j == n-1 {
				ans = max(ans, dp[i][j])
			} else if i == 0 {
				ans = max(ans, dp[i][j]+dpr[j+1])
			} else if j == n-1 {
				ans = max(ans, dp[i][j]+dpl[i-1])
			} else {
				ans = max(ans, dp[i][j]+dpl[i-1]+dpr[j+1])
			}
		}
	}
	fmt.Println(ans)
}

package main

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

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

func cf(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)

	fmt.Fprintln(out, n)
}

func cf1519D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums1, nums2 := make([]int64, n), make([]int64, n)
	for i := range nums1 {
		fmt.Fscan(in, &nums1[i])
	}
	for i := range nums2 {
		fmt.Fscan(in, &nums2[i])
	}
	f := make([]int64, n+1)
	for i := range nums1 {
		f[i+1] = f[i] + nums1[i]*nums2[i]
	}
	ans := f[n]
	for i := range nums1 {
		for j, d, sum := i, 1, nums1[i]*nums2[i]; j-d >= 0 && j+d < n; d++ {
			sum += nums1[j-d]*nums2[j+d] + nums1[j+d]*nums2[j-d]
			ans = max64(ans, sum+f[n]-f[j+d+1]+f[j-d])
		}
		for j1, j2, d, sum := i, i+1, 0, int64(0); j1-d >= 0 && j2+d < n; d++ {
			sum += nums1[j2+d]*nums2[j1-d] + nums1[j1-d]*nums2[j2+d]
			ans = max64(ans, sum+f[n]-f[j2+d+1]+f[j1-d])
		}
	}

	fmt.Fprintln(out, ans)
}

func cf175C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([][2]int64, n)
	for i := range nums {
		fmt.Fscan(in, &nums[i][0], &nums[i][1])
	}
	var t int
	fmt.Fscan(in, &t)
	p := make([]int64, t+2)
	p[t+1] = 1e12
	pre := int64(0)
	for i := 1; i <= t; i++ {
		fmt.Fscan(in, &p[i])
		pre, p[i] = p[i], p[i]-pre
	}
	sort.Slice(nums, func(i, j int) bool {
		return nums[i][1] < nums[j][1]
	})
	sum := int64(0)
	for i, j := 0, 1; i < len(nums); {
		sum += min64(nums[i][0], p[j]) * nums[i][1] * int64(j)
		if nums[i][0] > p[j] {
			nums[i][0] -= p[j]
			j++
		} else {
			p[j] -= nums[i][0]
			i++
		}
	}

	fmt.Fprintln(out, sum)
}

func cf494A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var s string
	fmt.Fscan(in, &s)
	sum, minSum, cnt := 0, len(s), 0
	for i := range s {
		if s[i] == '(' {
			sum++
		} else if s[i] == ')' {
			sum--
		} else {
			sum--
			minSum = sum
			cnt++
		}
		if sum < 0 {
			fmt.Fprintln(out, -1)
			return
		}
		minSum = min(minSum, sum)
	}
	if minSum < sum {
		fmt.Fprintln(out, -1)
	} else {
		fmt.Fprintln(out, strings.Repeat("1\n", cnt-1), sum+1)
	}
}

func cf1281B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	for ; n > 0; n-- {
		var s, c string
		fmt.Fscan(in, &s, &c)
		cs := []byte(s)
		j, a, b := len(s)-1, 0, 0
		for i := len(s) - 1; i >= 0; i-- {
			if cs[i] > cs[j] {
				a, b = i, j
			} else if cs[i] < cs[j] {
				j = i
			}
		}
		cs[a], cs[b] = cs[b], cs[a]
		if s = string(cs); s < c {
			fmt.Fprintln(out, s)
		} else {
			fmt.Fprintln(out, "---")
		}
	}
}

func cf605A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([][3]int, n) // nums[0]原数字  nums[1]原下标	nums[2]排序后的下标
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &nums[i][0])
		nums[i][1] = i
	}
	sort.SliceStable(nums, func(i, j int) bool {
		return nums[i][0] < nums[j][0]
	})
	for i := range nums {
		nums[i][2] = i
	}
	sort.Slice(nums, func(i, j int) bool {
		return nums[i][1] < nums[j][1]
	})
	f := make([]int, n+1)
	for _, num := range nums {
		f[num[2]+1] = f[num[2]] + 1
	}

	fmt.Fprintln(out, n-max(f...))
}

func cf297B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)
	if n > m {
		fmt.Fprintln(out, "YES")
		return
	}
	a, b := make([]int, n), make([]int, m)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	for i := range b {
		fmt.Fscan(in, &b[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	for i := range a {
		if a[i] > b[i] {
			fmt.Fprintln(out, "YES")
			return
		}
	}

	fmt.Fprintln(out, "NO")
}

func helan(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([]int, n)
	for i := range nums {
		fmt.Fscan(in, &nums[i])
	}

	less, more := -1, n
	for i := 0; i < more; i++ {
		if nums[i] == 0 {
			less++
			nums[i], nums[less] = nums[less], nums[i]
		} else if nums[i] == 2 {
			more--
			nums[i], nums[more] = nums[more], nums[i]
			i--
		}
	}

	fmt.Fprintln(out, nums)
}

func cf1203D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var s, t string
	fmt.Fscan(in, &s, &t)
	ans := 0
	left, right := make([]int, len(t)), make([]int, len(t))
	i, j := 0, 0
	for ; i < len(s) && j < len(t); i++ {
		if s[i] == t[j] {
			left[j] = i
			j++
		}
	}
	ans = max(ans, len(s)-i)
	i, j = len(s)-1, len(t)-1
	for ; i >= 0 && j >= 0; i-- {
		if s[i] == t[j] {
			right[j] = i
			j--
		}
	}
	ans = max(ans, i+1)
	for k := 0; k < len(t)-1; k++ {
		ans = max(ans, right[k+1]-left[k]-1)
	}

	fmt.Fprintln(out, ans)

}

func cf1196D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t, n, k int
	var s string
	fmt.Fscan(in, &t)
	pat := "RGB"
	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k, &s)
		ans := k
		for i := 0; i < 3; i++ {
			diff := 0
			for j := range s[:k] {
				if s[j] != pat[(i+j)%3] {
					diff++
				}
			}
			ans = min(ans, diff)
			for j := k; j < n; j++ {
				if s[j] != pat[(i+j)%3] {
					diff++
				}
				if s[j-k] != pat[(i+j-k%3)%3] {
					diff--
				}
				ans = min(ans, diff)
			}
		}

		fmt.Fprintln(out, ans)
	}
}

func cf44H(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var s string
	fmt.Fscan(in, &s)
	f := make([][10]int64, len(s))
	for i := range f[0] {
		f[0][i] = 1
	}
	for i := 1; i < len(s); i++ {
		for j := range f[i] {
			f[i][(j+int(s[i])-'0')/2] += f[i-1][j]
			if (j+int(s[i])-'0')&1 == 1 {
				f[i][(j+int(s[i])-'0'+1)/2] += f[i-1][j]
			}
		}
	}
	flag := true
	for i := range s[:len(s)-1] {
		if s[i]-s[i+1] <= 1 || s[i+1]-s[i] <= 1 {
			continue
		} else {
			flag = false
			break
		}
	}
	ans := int64(0)
	for i := range f[0] {
		ans += f[len(s)-1][i]
	}
	if flag {
		ans--
	}
	fmt.Fprintln(out, ans)
}

func cf1051D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	fmt.Fscan(in, &n, &k)
	if k == 1 {
		fmt.Fprintln(out, 2)
		return
	}
	mod := int64(998244353)
	f := make([][2]int64, k+1)
	f[1][1], f[2][0] = 2, 2
	for i := 2; i <= n; i++ {
		for j := min(k, 2*i); j >= 2; j-- {
			f[j][1] = (f[j][0]*2 + f[j][1] + f[j-1][1]) % mod
			f[j][0] = (f[j][0] + f[j-2][0] + f[j-1][1]*2) % mod
		}
	}

	fmt.Fprintln(out, (f[k][0]+f[k][1])%mod)
}

func cf1051D3(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	fmt.Fscan(in, &n, &k)
	if k == 1 {
		fmt.Fprintln(out, 2)
		return
	}
	mod := int64(998244353)
	f := make([][][2]int64, n+1)
	for i := range f {
		f[i] = make([][2]int64, k+1)
	}
	f[1][1][1], f[1][2][0] = 2, 2
	for i := 2; i <= n; i++ {
		f[i][1][1] = 2
		for j := 2; j <= k && j <= 2*i; j++ {
			f[i][j][0] = (f[i-1][j][0] + f[i-1][j-2][0] + f[i-1][j-1][1]*2) % mod
			f[i][j][1] = (f[i-1][j][0]*2 + f[i-1][j][1] + f[i-1][j-1][1]) % mod
		}
	}

	fmt.Fprintln(out, (f[n][k][0]+f[n][k][1])%mod)
}

func cf468A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	fmt.Fscan(in, &n)
	if n < 4 {
		fmt.Fprintln(out, "NO")
		return
	}
	fmt.Fprintln(out, "YES")
	if (n-4)&1 == 0 {
		fmt.Fprintln(out, "1 * 2 = 2")
		fmt.Fprintln(out, "2 * 3 = 6")
		fmt.Fprintln(out, "6 * 4 = 24")
	} else {
		fmt.Fprintln(out, "2 * 4 = 8")
		fmt.Fprintln(out, "3 * 5 = 15")
		fmt.Fprintln(out, "8 + 15 = 23")
		fmt.Fprintln(out, "23 + 1 = 24")
	}
	for i := 5 + n&1; i < n; i += 2 {
		fmt.Fprintln(out, i+1, "-", i, "= 1")
		fmt.Fprintln(out, "1 * 24 = 24")
	}
}

func cf573B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, ans int
	fmt.Fscan(in, &n)
	arr := make([]int, n+2)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &arr[i])
		arr[i] = min(arr[i], arr[i-1]+1)
	}
	for i := n; i >= 1; i-- {
		arr[i] = min(arr[i], arr[i+1]+1)
		ans = max(ans, arr[i])
	}

	fmt.Fprintln(out, ans)
}

func min(nums ...int) int {
	ans := nums[0]
	for _, num := range nums {
		if ans > num {
			ans = num
		}
	}
	return ans
}

func min64(nums ...int64) int64 {
	ans := nums[0]
	for _, num := range nums {
		if ans > num {
			ans = num
		}
	}
	return ans
}

func max(nums ...int) int {
	ans := nums[0]
	for _, num := range nums {
		if ans < num {
			ans = num
		}
	}
	return ans
}

func max64(nums ...int64) int64 {
	ans := nums[0]
	for _, num := range nums {
		if ans < num {
			ans = num
		}
	}
	return ans
}

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

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"path"
	"runtime"
	"sort"
	"strings"
	"time"
)

/**
https://codeforces.com/contest/1519/problem/d
*/

func main() {
	StdIO(func(fio *fastIO) { cf1519d(fio) })
	// CaseIO(func(fio *fastIO) { cf1519d(fio) })
}

func cf1519d(fio *fastIO) {
	n := fio.r1i()
	a, b := fio.rni64(n), fio.rni64(n)
	var sum int64
	for i, v := range a {
		sum += v * b[i]
	}
	max, prev := sum, sum
	for i := 1; i < (n-1)<<1; i++ {
		l, r := i>>1, i>>1+i&1
		if l == r {
			l--
			r++
		}
		prev = sum
		for l >= 0 && r < n {
			prev += a[l]*b[r] + a[r]*b[l] - a[l]*b[l] - a[r]*b[r]
			max = Max(max, prev)
			l--
			r++
		}
	}
	fio.wln(max)
}

// ================== utils ==================

type _integer_ interface {
	~uint8 | ~uint16 | ~uint32 | ~uint64 | ~int8 | ~int16 | ~int32 | ~int64 | ~int | ~uint
}

type _float_ interface {
	~float32 | ~float64
}

type _number_ interface {
	_integer_ | _float_
}

type _ordered_ interface {
	_number_ | ~string
}

func _select_[T _ordered_](f func(x, t T) bool, ts ...T) T {
	n := len(ts)
	if n == 0 {
		panic("At Least One Argument")
	} else {
		x := ts[0]
		for i := 1; i < n; i++ {
			if f(x, ts[i]) {
				x = ts[i]
			}
		}
		return x
	}
}

func Max[T _ordered_](ts ...T) T {
	return _select_(func(x, t T) bool { return x < t }, ts...)
}
func Min[T _ordered_](ts ...T) T {
	return _select_(func(x, t T) bool { return x > t }, ts...)
}
func SumI[T _integer_](ts []T) (sum uint64) {
	for _, t := range ts {
		sum += uint64(t)
	}
	return
}
func SumF[T _float_](ts []T) (sum float64) {
	for _, t := range ts {
		sum += float64(t)
	}
	return
}
func SortASC[T _ordered_](ts []T) {
	sort.Slice(ts, func(i, j int) bool { return ts[i] < ts[j] })
}
func SortDESC[T _ordered_](ts []T) {
	sort.Slice(ts, func(i, j int) bool { return ts[i] > ts[j] })
}

func SliceInit[T _ordered_ | bool](n int, v T) []T {
	arr := make([]T, n)
	for i := range arr {
		arr[i] = v
	}
	return arr
}

// SliceInit2 M * N
func SliceInit2[T _ordered_ | bool](m, n int, v T) [][]T {
	arr := make([][]T, m)
	for i := range arr {
		arr[i] = SliceInit(n, v)
	}
	return arr
}

// SliceInit3 L * M * N
func SliceInit3[T _ordered_ | bool](l, m, n int, v T) [][][]T {
	arr := make([][][]T, l)
	for i := range arr {
		arr[i] = SliceInit2(m, n, v)
	}
	return arr
}

func b2i[T _integer_](b bool) T {
	if b {
		return 1
	} else {
		return 0
	}
}

// ================== fastIO ==================

// StdIO 标准输入输出，用于提交
func StdIO(f func(fio *fastIO)) {
	fio := newFastIO(os.Stdin, os.Stdout)
	f(fio)
	fio.flush()
}

// CaseIO 测试用例文件输入输出，用于测试，不支持多种答案的情况
// 读入`main`函数文件同目录的`inputs.txt`文件中的测试用例进行测试，文件格式参考`datafiles/inputs.txt`
func CaseIO(f func(fio *fastIO)) {
	_, file, _, _ := runtime.Caller(0)
	inputs, _ := os.Open(path.Dir(file) + "/inputs.txt")
	all, _ := io.ReadAll(inputs)
	buf := new(bytes.Buffer)
	for i, testcase := range strings.Split(string(all), "input\n")[1:] {
		items := strings.Split(testcase, "\noutput\n")
		input, expect := items[0], items[1]
		if expect[len(expect)-1] != '\n' {
			expect += "\n"
		}
		fmt.Printf("\n=== RUN   CASE %d\n", i+1)
		start := time.Now().UnixMilli()
		fio := newFastIO(strings.NewReader(input), buf)
		f(fio)
		fio.flush()
		cost := time.Now().UnixMilli() - start
		answer := buf.String()
		if expect == answer {
			fmt.Printf("--- PASS: CASE %d (%dms)\n", i+1, cost)
		} else {
			fmt.Printf("--- FAIL: CASE %d (%dms)\n[EXPECT]:\n%v[ANSWER]:\n%v", i+1, cost, expect, answer)
		}
		buf.Reset()
	}
}

type fastIO struct {
	reader io.Reader
	writer io.Writer
	out    *bufio.Writer
	buf    []byte // 4KB
	i, n   int
}

func newFastIO(reader io.Reader, writer io.Writer) *fastIO {
	return &fastIO{reader: reader, writer: writer, out: bufio.NewWriter(writer), buf: make([]byte, 1<<12)}
}

// 读取整数
func (f *fastIO) r1i() int             { return fioR1(f.ri) }
func (f *fastIO) r2i() (int, int)      { return fioR2(f.r1i) }
func (f *fastIO) r3i() (int, int, int) { return fioR3(f.r1i) }
func (f *fastIO) rni(n int) []int      { return fioRn(n, f.r1i) }
func (f *fastIO) rxi() (nums []int)    { return fioRx(f.ri) }

func (f *fastIO) rnimms(n int) (min, max int, sum uint64)   { return fioRnMMS(n, f.r1i) }
func (f *fastIO) rximms() (n int, min, max int, sum uint64) { return fioRxMMS(f.ri) }

func (f *fastIO) r1i64() int64                 { return fioR1(f.ri64) }
func (f *fastIO) r2i64() (int64, int64)        { return fioR2(f.r1i64) }
func (f *fastIO) r3i64() (int64, int64, int64) { return fioR3(f.r1i64) }
func (f *fastIO) rni64(n int) []int64          { return fioRn(n, f.r1i64) }
func (f *fastIO) rxi64() (nums []int64)        { return fioRx(f.ri64) }

func (f *fastIO) rni64mms(n int) (min, max int64, sum uint64)   { return fioRnMMS(n, f.r1i64) }
func (f *fastIO) rxi64mms() (n int, min, max int64, sum uint64) { return fioRxMMS(f.ri64) }

// 读取字符串
func (f *fastIO) r1s() []byte                   { return fioR1(f.rs) }
func (f *fastIO) r2s() ([]byte, []byte)         { return fioR2(f.r1s) }
func (f *fastIO) r3s() ([]byte, []byte, []byte) { return fioR3(f.r1s) }
func (f *fastIO) rns(n int) [][]byte            { return fioRn(n, f.r1s) }
func (f *fastIO) rxs() (strs [][]byte)          { return fioRx(f.rs) }

// 输出
func (f *fastIO) w(a ...any)                 { f.panic(fmt.Fprint(f.out, a...)) }
func (f *fastIO) wf(format string, a ...any) { f.panic(fmt.Fprintf(f.out, format, a...)) }
func (f *fastIO) wln(a ...any)               { f.panic(fmt.Fprintln(f.out, a...)) }
func (f *fastIO) flush()                     { f.panic(f.out.Flush()) }

// 尝试读取一个字符
func (f *fastIO) rc() (b byte, err error) {
	if f.i == f.n {
		f.i = 0
		if f.n, _ = f.reader.Read(f.buf); f.n == 0 {
			return 0, io.EOF
		}
	}
	b = f.buf[f.i]
	f.i++
	return
}

// 尝试读取一个整数（包括负数）
func (f *fastIO) ri() (x int, err error)     { return fioRi[int](f.rc) }
func (f *fastIO) ri64() (x int64, err error) { return fioRi[int64](f.rc) }

func fioRi[T _integer_](f func() (byte, error)) (x T, err error) {
	var b byte
	negative := false
	for b, err = f(); err == nil && !isDigit(b); b, err = f() {
		if b == '-' {
			negative = true
		}
	}
	if err != nil {
		return 0, err
	} else {
		x = T(b & 15)
		for b, _ = f(); isDigit(b); b, _ = f() {
			x = x*10 + T(b&15)
		}
		if negative {
			x = -x
		}
		return
	}
}

// 空白字符
var _ioWs = map[byte]bool{' ': true, '\n': true, '\r': true, '\t': true, '\v': true, '\f': true}

// 尝试读取一个被空白字符分隔的字符串
func (f *fastIO) rs() ([]byte, error) {
	b, err := f.rc()
	for ; err == nil && _ioWs[b]; b, err = f.rc() {
	}
	if err != nil {
		return nil, err
	} else {
		chars := []byte{b}
		for b, err = f.rc(); err == nil && !_ioWs[b]; b, err = f.rc() {
			chars = append(chars, b)
		}
		return chars, nil
	}
}

func isDigit(b byte) bool    { return '0' <= b && b <= '9' }
func isUpper(b byte) bool    { return 'A' <= b && b <= 'Z' }
func isLower(b byte) bool    { return 'a' <= b && b <= 'z' }
func isAlphabet(b byte) bool { return isLower(b) || isUpper(b) }

func fioPanic[T _number_ | []byte](x T, err any) T {
	if err != nil {
		panic(err)
	}
	return x
}

func fioR1[T _number_ | []byte](f func() (T, error)) T { return fioPanic(f()) }
func fioR2[T _number_ | []byte](f func() T) (T, T)     { return f(), f() }
func fioR3[T _number_ | []byte](f func() T) (T, T, T)  { return f(), f(), f() }
func fioRn[T _number_ | []byte](n int, f func() T) []T {
	arr := make([]T, n)
	for i := range arr {
		arr[i] = f()
	}
	return arr
}
func fioRx[T _number_ | []byte](f func() (T, error)) (arr []T) {
	for t, err := f(); err == nil; t, err = f() {
		arr = append(arr, t)
	}
	return
}
func fioRnMMS[T _integer_](n int, f func() T) (min, max T, sum uint64) {
	min = f()
	max, sum = min, uint64(min)
	for i := 1; i < n; i++ {
		t := f()
		sum += uint64(t)
		min, max = fioMinMax(min, max, t)
	}
	return
}
func fioRxMMS[T _integer_](f func() (T, error)) (n int, min, max T, sum uint64) {
	if t, err := f(); err == nil {
		n, min, max, sum = 0, t, t, uint64(t)
		for t, err = f(); err == nil; t, err = f() {
			n++
			sum += uint64(t)
			min, max = fioMinMax(min, max, t)
		}
	}
	return
}
func fioMinMax[T _number_](min, max, t T) (T, T) {
	if min > t {
		min = t
	} else if max < t {
		max = t
	}
	return min, max
}

func (fastIO) panic(a ...any) {
	n := len(a)
	if err := a[n-1]; err != nil {
		panic(err)
	}
}

package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i += 1 {
		_, _ = fmt.Scan(&a[i])
	}
	var sum int64 = 0
	for i := 0; i < n; i += 1 {
		_, _ = fmt.Scan(&b[i])
		sum += int64(a[i]) * int64(b[i])
	}
	ans := sum
	for i := 0; i < n*2; i += 1 {
		j, k := i/2, (i+1)/2
		cur := sum
		for j >= 0 && k < n {
			cur -= int64(a[j]) * int64(b[j])
			cur -= int64(a[k]) * int64(b[k])
			cur += int64(a[j]) * int64(b[k])
			cur += int64(a[k]) * int64(b[j])
			if ans < cur {
				ans = cur
			}
			j -= 1
			k += 1
		}
	}
	fmt.Println(ans)
}

package main

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

func max(x, y int64) int64 {
	if x < y {
		return y
	} else {
		return x
	}
}
func run(or io.Reader, ow io.Writer) {
	in := bufio.NewReader(or)
	out := bufio.NewWriter(ow)
	defer out.Flush()

	solve := func() {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int64, n)
		b := make([]int64, n)
		pre := make([]int64, n)

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &b[i])
		}
		for i := 0; i < n; i++ {
			if i > 0 {
				pre[i] = pre[i-1] + a[i]*b[i]
			} else {
				pre[i] = a[i] * b[i]
			}
		}
		ans := pre[n-1]
		res := make([]int64, n)
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if i+j < n {
					res[i+j] += a[i] * b[j]
				}
			}
		}
		calc := func(l, r int) int64 {
			if l > r {
				return 0
			} else if l == 0 {
				return pre[r]
			} else {
				return pre[r] - pre[l-1]
			}
		}
		for i := 0; i < n; i++ {
			// for j := i; j < n; j++ {
			// 	fmt.Fprint(out, res[j], " ")
			// }
			// fmt.Fprintln(out)
			for j := i; j < n; j++ {
				if i == 0 {
					ans = max(ans, calc(j+1, n-1)+res[j])
				} else {
					ans = max(ans, pre[i-1]+calc(j+1, n-1)+res[j])
				}
			}
			for j := i; j < n; j++ {
				res[j] -= a[i] * b[j]
				res[j] -= b[i] * a[j]
			}
			for j := 0; j < n-1; j++ {
				res[j] = res[j+1]
			}
			res[n-1] = 0
			for j := i + 1; j < n; j++ {
				res[n-1] += a[j] * b[n-(j-i)]
			}
		}
		fmt.Fprintln(out, ans)

	}

	T := 1
	//fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

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

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

var n,m int
var k int64
var turn int
const MOD int64 = 1e9 + 7
var s,t string
func solve(){
	dp:=make([][]int64,n+1)
	a,b:=make([]int64,n),make([]int64,n)
	for i:=0;i<n;i++{
		Fscan(r,&a[i])
	}
	for i:=0;i<n;i++{
		Fscan(r,&b[i])
	}
	sum:=int64(0)
	for i:=0;i<n;i++{
		sum+=a[i]*b[i]
	}
	//dp[l][r]=dp[l+1][r-1]-a[l]*b[l]-a[r]*b[r]+a[l]*b[r]+a[r]*b[l]
	for i:=0;i<n;i++{
		dp[i]=make([]int64,n+1)
		dp[i][i]=sum
		if i>1{
			dp[i][i-1]=sum
		}
	}
	ans:=sum
	for len:=1;len<n;len++{
		for l:=0;l+len<n;l++{
			r:=l+len
			dp[l][r]=max(dp[l+1][r-1]-a[l]*b[l]-a[r]*b[r]+a[l]*b[r]+a[r]*b[l],dp[l][r])
			ans=max(ans,dp[l][r])
		}
	}
	Fprint(w,ans)

	return
}

func main(){
	defer w.Flush()
	// Fscan(r,&n,&m)
	Fscan(r,&n)
	// Fscan(r,&turn)
	// Fscan(r,&s)
	// Fscan(r,&k)

	// for i:=0;i<turn;i++{
	//     solve()
	// }

	solve()
}

/* ===========================PART 1: Math Func ============================  */
func max(x, y int64) int64 {if x > y {return x};return y}
func abs(x int) int {if x > 0 {return x};return -x}
func min(x, y int) int {if x < y {return x};return y}
func memset(a []int, v int) {
	if len(a) == 0 {return}
	a[0] = v
	for bp := 1; bp < len(a); bp *= 2 {
		copy(a[bp:], a[:bp])
	}
}

package main

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

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

	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	var sum int64
	b := make([]int64, n)
	for i := range b {
		Fscan(in, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum
	for i := 0; i < n; i++ {
		cur := sum
		for l, r := i-1, i+1; l > 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
		cur = sum
		for l, r := i-1, i; l > 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
		cur = sum
		for l, r := i, i+1; l > 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}
	Fprintln(out, ans)
}

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

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

package main

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

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

	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	var sum int64
	b := make([]int64, n)
	for i := range b {
		Fscan(in, &b[i])
		sum += a[i] * b[i]
	}

	ans := sum

	//center
	for i := 1; i < n-1; i++ {
		cur := sum
		for l, r := i-1, i+1; l > 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}

	for i := 1; i < n; i++ {
		cur := sum
		for l, r := i-1, i; l > 0 && r < n; l-- {
			cur -= (a[l] - a[r]) * (b[l] - b[r])
			ans = max(ans, cur)
			r++
		}
	}
	Fprint(out, ans)
}

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

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

package main

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

func CF1519D(as []int, bs []int) int64 {
	n := len(as)
	var ans int64
	for i := 0; i < n; i++ {
		ans += int64(as[i] * bs[i])
	}
	base := ans
	nega := make([][]int64, n)
	for i := n - 1; i >= 0; i-- {
		nega[i] = make([]int64, n)
		for j := i; j < n; j++ {
			if i == j {
				nega[i][j] = int64(as[j]) * int64(bs[j])
			} else if i == j-1 {
				nega[i][j] = int64(as[i])*int64(bs[j]) + int64(as[j])*int64(bs[i])
			} else {
				nega[i][j] = int64(as[i])*int64(bs[j]) + int64(as[j])*int64(bs[i]) + nega[i+1][j-1]
			}
		}
	}

	for i := 0; i < n; i++ {
		var posi int64 = 0
		for j := i; j >= 0; j-- {
			posi += int64(as[j]) * int64(bs[j])
			ans = max(ans, base-posi+nega[j][i])
		}
	}
	return ans
}

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

func main() {
	// read, _ := os.Open("input.txt")
	read := os.Stdin
	write := os.Stdout
	in := bufio.NewReader(read)
	out := bufio.NewWriter(write)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	as := make([]int, n)
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &as[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &bs[i])
	}
	fmt.Fprintln(out, CF1519D(as, bs))
}

package main

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

func CF1519D(as []int, bs []int) int64 {
	n := len(as)
	var ans int64
	for i := 0; i < n; i++ {
		ans += int64(as[i] * bs[i])
	}
	base := ans
	nega := make([][]int64, n)
	for i := n - 1; i >= 0; i-- {
		nega[i] = make([]int64, n)
		for j := i; j < n; j++ {
			if i == j {
				nega[i][j] = int64(as[j] * bs[j])
			} else if i == j-1 {
				nega[i][j] = int64(as[i]*bs[j] + as[j]*bs[i])
			} else {
				nega[i][j] = int64(as[i]*bs[j]+as[j]*bs[i]) + nega[i+1][j-1]
			}
		}
	}

	for i := 0; i < n; i++ {
		var posi int64 = 0
		for j := i; j >= 0; j-- {
			posi += int64(as[j] * bs[j])
			ans = max(ans, base-posi+nega[j][i])
		}
	}
	return ans
}

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

func main() {
	// read, _ := os.Open("input.txt")
	read := os.Stdin
	write := os.Stdout
	in := bufio.NewReader(read)
	out := bufio.NewWriter(write)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	as := make([]int, n)
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &as[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &bs[i])
	}
	fmt.Fprintln(out, CF1519D(as, bs))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int)int{
	if x>y{
		return x
	}
	return y
}
func main() {
	in:= bufio.NewReader(os.Stdin)
	out := os.Stdout

	var n int
	fmt.Fscan(in,&n)
	a := make([]int,n+5)
	b := make([]int,n+5)
	for i:=1;i<=n;i++{
		fmt.Fscan(in,&a[i])
	}
	for i:=1;i<=n;i++{
		fmt.Fscan(in,&b[i])
	}
	pre := make([]int,n+5)
	for i:=1;i<=n;i++{
		pre[i]=pre[i-1]+a[i]*b[i]
	}
	f := [5005][5005]int{}
	for i:=1;i<=n;i++{
		f[i][i]=a[i]*b[i]
	}
	for k:=2;k<=n;k++{
		for i:=1;i+k-1<=n;i++{
			if k==2{
				f[i][i+k-1]=(a[i]*b[i+k-1]+a[i+k-1]*b[i])
				continue
			}else{
				f[i][i+k-1]=f[i+1][i+k-1-1]+(a[i]*b[i+k-1])+(a[i+k-1]*b[i])
			}
		}
	}
	ans := pre[n]
	for i:=1;i<=n;i++{
		for j:=i+1;j<=n;j++{
			ans = max(ans,pre[i-1]+f[i][j]+pre[n]-pre[j])
		}
	}
	fmt.Fprintln(out,ans)
}

package main

import (
	"fmt"
)

func max(a int64, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}
func main() {
	var n int
	fmt.Scanln(&n)
	var a, b []int64 = make([]int64, n), make([]int64, n)
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scanln(&x)
		a[i] = x
	}
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scanln(&x)
		b[i] = x
	}
	var dpr, dpl []int64 = make([]int64, n), make([]int64, n)
	var su int64 = 0
	for i := 0; i < n; i++ {
		su += a[i] * b[i]
		dpl[i] = su
	}
	su = 0
	for i := n - 1; i >= 0; i-- {
		su += a[i] * b[i]
		dpr[i] = su
	}
	var dp [][]int64 = make([][]int64, n)
	for i := range dp {
		dp[i] = make([]int64, n)
	}
	for i := range dp {
		dp[i][i] = (a[i] * b[i])
	}
	for l := 2; l <= n; l++ {
		for i := 0; i < (n - l + 1); i++ {
			j := i + l - 1
			if l == 2 {
				dp[i][j] = (a[i]*b[j] + a[j]*b[i])
			} else {
				dp[i][j] = (a[i]*b[j] + a[j]*b[i]) + dp[i+1][j-1]
			}
		}
	}
	var ans int64 = dpl[n-1]
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i == 0 && j == n-1 {
				ans = max(ans, dp[i][j])
			} else if i == 0 {
				ans = max(ans, dp[i][j]+dpr[j+1])
			} else if j == n-1 {
				ans = max(ans, dp[i][j]+dpl[i-1])
			} else {
				ans = max(ans, dp[i][j]+dpl[i-1]+dpr[j+1])
			}
		}
	}
	fmt.Println(ans)
}


Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up all the bulbs?If Vasya presses the button such that some bulbs connected to it are already turned on, they do not change their state, i.e. remain turned on.

The first line of the input contains integers n and m (1 ≤ n, m ≤ 100) — the number of buttons and the number of bulbs respectively.  Each of the next n lines contains xi (0 ≤ xi ≤ m) — the number of bulbs that are turned on by the i-th button, and then xi numbers yij (1 ≤ yij ≤ m) — the numbers of these bulbs.

If it's possible to turn on all m bulbs print "YES", otherwise print "NO".

NoteIn the first sample you can press each button once and turn on all the bulbs. In the 2 sample it is impossible to turn on the 3-rd lamp.

package main

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

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

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Text()

	resMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner.Scan()
		bulbIn := scanner.Text()//[:len(scanner.Text()) - 2]
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	if len(resMap) == m {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var dict = make(map[int]int)
	for i := 0; i < n; i++ {
		var numBulb int
		fmt.Scan(&numBulb)
		for j := 0; j < numBulb; j++ {
			var id int
			fmt.Scan(&id)
			dict[id] = 1
		}
	}
	var dictlen = len(dict)
	if dictlen < m {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import "fmt"

func main() {
    var n, m int
    fmt.Scanf("%d %d\n", &n, &m)

    on := make([]bool, m)
    num_on := 0
    for i := 0; i < n; i++ {
        var x int
        fmt.Scanf("%d", &x);
        for j := 0; j < x; j++ {
            var y int
            fmt.Scanf("%d", &y)
            if !on[y-1] {
                on[y-1] = true
                num_on++
            }
        }
        fmt.Scanf("\n")
    }

    if num_on == m {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())

    scanner.Scan()
    m, _ := strconv.Atoi(scanner.Text())

    mm := make(map[int]bool)
    for i:=0 ; i<n ; i++ {
        scanner.Scan()
        xn, _ := strconv.Atoi(scanner.Text())
        for j:=0 ; j<xn ; j++ {
            scanner.Scan()
            x, _ := strconv.Atoi(scanner.Text())
            mm[x] = true
        }
    }

    if len(mm) == m {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

import "fmt"

var on [105]int

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	u, v := 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&u)
		for j := 0; j < u; j++ {
			fmt.Scan(&v)
			on[v] += 1
		}
	}

	for i := 1; i <= m; i++ {
		if on[i] == 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")

}

package main

import (
	"fmt"
)

func main() {
	var n, m uint
	mee := make(map[uint]uint)
	//in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n, &m)
	for i := uint(0); i < n; i++ {
		var b, c uint
		fmt.Scan(&b)
		for j := uint(0); j < b; j++ {
			fmt.Scan(&c)
			mee[c] = c
		}
	}
	if len(mee) == int(m) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	//fmt.Println(mee)
}

package main

import (
    "fmt"
    )

func main() {
    var m, n int
    fmt.Scan(&n, &m)

    bulbs := make([]bool, m, m)
    for i := 0; i < n; i++ {
        var x, y int
        fmt.Scan(&x)
        for j := 0; j < x; j++ {
            fmt.Scan(&y)
            bulbs[y-1] = true
        }
    }

    possible := true
    for i := 0; i < m; i++ {
        if bulbs[i] == false {
            possible = false
            break
        }
    }

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

package main

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

func main() {
	n := nextInt()
	m := nextInt()
	can := make([]bool, m)
	for i := 0; i < n; i++ {
		x := nextInt()
		for j := 0; j < x; j++ {
			y := nextInt() - 1
			can[y] = true
		}
	}
	for i := 0; i < m; i++ {
		if !can[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func init() {
	// maybe defer writer.Flush() in main

	lineScanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	/*
		inputFile, err := os.Open("a.in")
		if err != nil {
			panic(err)
		}
		outputFile, err := os.Create("a.out")
		if err != nil {
			panic(err)
		}
		lineScanner = bufio.NewScanner(inputFile)
		writer = bufio.NewWriter(outputFile)
	*/

	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

var writer *bufio.Writer

func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

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

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

package main

import (
	"fmt"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	ma := make([]bool,m)
	for i :=0;i<n;i++ {
		var x int
		fmt.Scan(&x)
		for j :=0;j<x; j++ {
			var l int
			fmt.Scan(&l)
			ma[l-1] = true
		}
	}
	flag := true
	for _,b := range(ma) {
		if !b {
			flag = false
			break
		}
	}
	if flag {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

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

	resMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		bulbIn := scanner.Text()
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	if len(resMap) == m {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

package main

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

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

	resMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		bulbIn := scanner.Text()
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	// fmt.Println(resMap)
	if len(resMap) == m {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)

	resMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		bulbIn := scanner.Text()
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	if len(resMap) == m {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

package main

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

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

	resMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		bulbIn := scanner.Text()
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	// fmt.Println(resMap)
	if len(resMap) == m {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	// fmt.Println(n, m)

	resMap := make(map[int]int)
	for i := 0; i <= n; i++ {
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		bulbIn := strings.Trim(scanner.Text(), "\n")
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	if len(resMap) == m {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

package main

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

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

	resMap := make(map[int]int)
	for i := 0; i < n; i++ {
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		bulbIn := scanner.Text()//[:len(scanner.Text()) - 2]
		bulbs := strings.Split(bulbIn, " ")
		bulbSum, _ := strconv.Atoi(bulbs[0])
		for j := 1; j <= bulbSum; j++ {
			bulbIdx, _ := strconv.Atoi(bulbs[j])
			resMap[bulbIdx]++
		}
	}
	if len(resMap) == m {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

func main() {
    var n, m int
    fmt.Scanf("%d %d\n", &n, &m)

    on := make([]bool, m)
    num_on := 0
    for i := 0; i < n; i++ {
        var x int
        fmt.Scanf("%d", &x);
        for j := 0; j < x; j++ {
            var y int
            fmt.Scanf("%d", &y)
            if !on[y-1] {
                on[y-1] = true
                num_on++
            }
        }
        //fmt.Scanf("\n")
    }

    if num_on == m {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

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

func main() {
	var n, m uint
	mee := make(map[uint]uint)
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	for i := uint(0); i < n; i++ {
		var b, c uint
		fmt.Fscanf(in, "%d", &b)
		for j := uint(0); j < b; j++ {
			if j == b-1 {
				fmt.Fscanf(in, "%d\n", &c)
				mee[c] = c
			} else {
				fmt.Fscanf(in, "%d ", &c)
				mee[c] = c
			}

		}
	}
	if len(mee) == int(m) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m uint
	mee := make(map[uint]uint)
	//in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n, &m)
	for i := uint(0); i < n; i++ {
		var b, c uint
		fmt.Scan(&b)
		for j := uint(0); j < b; j++ {
			fmt.Scan(&c)
			mee[c] = c
		}
	}
	if len(mee) == int(m) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	fmt.Println(mee)
}


You are given an integer $$$n$$$. Check if $$$n$$$ has an odd divisor, greater than one (does there exist such a number $$$x$$$ ($$$x > 1$$$) that $$$n$$$ is divisible by $$$x$$$ and $$$x$$$ is odd).For example, if $$$n=6$$$, then there is $$$x=3$$$. If $$$n=4$$$, then such a number does not exist.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case contains one integer $$$n$$$ ($$$2 \le n \le 10^{14}$$$). Please note, that the input for some test cases won't fit into $$$32$$$-bit integer type, so you should use at least $$$64$$$-bit integer type in your programming language.

For each test case, output on a separate line:    "YES" if $$$n$$$ has an odd divisor, greater than one;  "NO" otherwise.  You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

package main

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

/*

 */

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

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

	for ; t > 0; t-- {
		var n int64
		scanf("%d\n", &n)

		if n&(n-1) != 0 {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

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 min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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))
}

package main

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

/*
6
*/

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

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

	for ; t > 0; t-- {
		var n int64
		scanf("%d\n", &n)

		for n%2 == 0 {
			n = n / 2
		}

		if n != 1 {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

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 min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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))
}

package main

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

/*
6
*/

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

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

	for ; t > 0; t-- {
		var n int64
		scanf("%d\n", &n)

		for n%2 == 0 && n != 2 {
			n = n / 2
		}

		if n%2 != 0 {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

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 min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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))
}

package main

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

type ti uint64

var scanner = bufio.NewScanner(os.Stdin)

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []ti {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []ti
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) ti {
	num, _ := strconv.ParseInt(strings.TrimSpace(s), 10, 64)
	return ti(num)
}

// ReadInput reads the input and returns the text
func ReadInput() string {
	scanner.Scan()
	return scanner.Text()
}

func findOddDivisor(n ti) string {
	if n <= 2 {
		return "NO"
	}

	if n%2 != 0 {
		return "YES"
	}

	for cur := n / 2; cur >= 2; cur /= 2 {
		if cur%2 != 0 {
			return "YES"
		}
	}

	return "NO"
}

func main() {
	input := ReadInput()
	test_cases := ParseInt(input)

	for i := ti(0); i < test_cases; i++ {
		input := ReadInput()
		num := ParseInt(input)
		fmt.Println(findOddDivisor(num))
	}
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int64
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &n)

		fmt.Fprintln(out, solve2(n))

	}

}

func solve2(n int64) string {

	num := int64(2)

	for num <= n {

		if num == n {
			return "NO"
		}

		num *= 2

	}

	return "YES"

}

func solve(n int64) string {

	if n%2 == 1 {
		return "YES"
	}

	d := int64(3)

	for d <= int64(math.Sqrt(float64(n))) {

		if n%d == 0 {
			return "YES"
		}

		d += 2

	}

	return "NO"

}

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	// 读入一行数据
	// s, _ := in.ReadString('\n')
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func(t int) {
		var n int64
		fmt.Fscan(in, &n)
		if n & (n-1) > 0 {
			fmt.Fprintln(out, "YES")
		}else{
			fmt.Fprintln(out, "NO")
		}
	}

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

package main

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

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

func out(x ...interface{}) {
	fmt.Fprint(wr, x...)
}

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

func nextInt64() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	defer wr.Flush()
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

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

func solve() {
	n := nextInt64()

	if n&(n-1) != 0 {
		out("YES\n")
	} else {
		out("NO\n")
	}
}

package main

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

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

func out(x ...interface{}) {
	fmt.Fprint(wr, x...)
}

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

func nextInt64() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	defer wr.Flush()
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

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

func solve() {
	n := nextInt64()

	for n%2 == 0 {
		n /= 2
	}

	if n != 1 {
		out("YES\n")
	} else {
		out("NO\n")
	}
}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n int64
		Fscan(in, &n)

		if n & (n-1) != 0 {
			Fprintln(out, "YES")

		} else {
			Fprintln(out, "NO")
		}
	}

}

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

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n int64
		Fscan(in, &n)

		for n & 0x1 == 0 {
			n >>= 1
		}
		if n == 1 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}

}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int64
		fmt.Scan(&n)

		if n&(n-1) != 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanln(&t)
	for {
		var n int64
		fmt.Scanln(&n)
		for n%2 == 0 {
			n /= 2
		}
		if n != 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
		if t == 0 {
			break
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var N int
	var x int64
	Fscan(in, &N)
	for tt:=0; tt < N; tt ++ {
		Fscan(in, &x)
		for x>0 && x&1 == 0 {
			x = x >> 1
		}
		ans := "YES\n"
		if x == 1 {
			ans = "NO\n"
		}
		out.WriteString(ans)
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int64
	fmt.Scan(&T)
	for ; T > 0; T-- {
		var n int64
		fmt.Scan(&n)
		for ; n%2 == 0; n >>= 1 {
		}
		if n == 1 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

import (
	. "fmt"
)

func main(){
	var t int;
	Scan(&t);
	for i:=0;i<t;i++ {
		var n int64;
		Scan(&n);

		for ;n>1 && n%2 == 0; {
			n/=2;
		}
		if n == 1 {
			Println("NO");
		} else{
			Println("YES");
		}
	}
}

package main

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

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

func Max(x, y int64) int64 {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	t := 10000
	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		var n int64
		fmt.Fscan(in, &n)
		if n&(n-1) == 0 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

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

func main() {
	defer writer.Flush()

	var t int
	fmt.Fscan(reader, &t)

	for i := 0; i < t; i++ {
		var n uint64
		fmt.Fscan(reader, &n)

		if bits.OnesCount64(n) == 1 {
			fmt.Fprintln(writer, "NO")
		} else {
			fmt.Fprintln(writer, "YES")
		}
	}
}

package main

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

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

func main() {
	defer writer.Flush()

	var t int
	fmt.Fscan(reader, &t)

	for i := 0; i < t; i++ {
		var n int64
		fmt.Fscan(reader, &n)

		var count int
		for n > 0 {
			if n&1 == 1 {
				count++
			}

			n >>= 1

			// fmt.Println("n: ", n)
		}

		if count == 1 {
			fmt.Fprintln(writer, "NO")
		} else {
			fmt.Fprintln(writer, "YES")
		}
	}
}

package main

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

func main() {
	a:=bufio.NewReader(os.Stdin)
	l, _ :=a.ReadString('\n')
	l=strings.Trim(strings.Trim(l,"\n"),"\r")
	ln, _ :=strconv.Atoi(l)
	for i:=0; i<ln;i++{
		s,_:=a.ReadString('\n')
		d, _ :=strconv.ParseInt(strings.Trim(strings.Trim(s,"\n"), "\r"),10 , 64)
		fmt.Printf("%s\n",fn(d))

	}
}

func fn(n int64) string {
	if n & (n - 1) == 0{
		return "NO"
	}
	return "YES"
}

// Written by : Syed Mujtaba
// Seek knowledge from the cradle to the grave
package main

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

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

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

func Abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	defer writer.Flush()

	var t int
	fmt.Scanf("%d\n", &t)
	for T := 0; T < t; T++ {
		var n int64
		scanf("%d\n", &n)
		for n%2 == 0 {
			n /= 2
		}
		if n == 1 {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

package main

import (
  "fmt"
)

func main() {
  var T int
  fmt.Scanf("%d ", &T);
  for ;T>0;T-- {
    var n int;
    fmt.Scanf("%d ", &n);
    for ;n%2==0; {
      n /=2;
    }
    if(n==1) {
      fmt.Println("NO")
    } else {
      fmt.Println("YES")
    }
  }

}

package main

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

func solve(r *bufio.Reader) {
	var p int64
	fmt.Fscan(r, &p)

	for p%2 == 0 {
		p = p / 2
	}
	if p%2 == 1 && p != 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

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

package main

import (
	"fmt"
)

func solve() {
	var n uint64
	fmt.Scanf("%d\n", &n)

	if n%2 == 1 {
		fmt.Println("YES")
		return
	} else {
		for n > 1 {
			if n%2 == 1 {
				fmt.Println("YES")
				return
			}
			n /= 2
		}
	}
	fmt.Println("NO")
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

func solve(x int64) string {
	for x > 1 {
		if x%2 == 1 {
			return "YES"
		}
		x /= 2
	}
	return "NO"
}

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

	tt := int64(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int64(0)
		fmt.Fscanf(in, "%d\n", &n)
		fmt.Fprintf(out, "%s\n", solve(n))
		tt--
	}
	out.Flush()
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	isPowerOf2 := map[int64]bool{}

	for i := 1; i < 63; i++ {
		isPowerOf2[1<<i] = true
	}

	for t := scanInt(); t > 0; t-- {
		n := scanInt64()

		if isPowerOf2[n] {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		var n uint64
		s, _ := reader.ReadBytes('\n')
		readUint64(s, 0, &n)
		res := solve(n)

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n uint64) bool {
	if n == 1 {
		return false
	}
	return n&(n-1) > 0
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
func slove() {
	sc.Scan()
	x , _ := strconv.ParseInt(sc.Text(), 10, 64)
	if (x & (x - 1) != 0) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
var T int
func main() {
	sc.Scan()
	T, _ := strconv.ParseInt(sc.Text(), 10, 32)
	for T > 0{
		T--
		slove()
	}
}

package main

import . "fmt"

func main() {
	var t int
	Scan(&t)
	solve := func() {
		var n int64
		Scan(&n)
		if n & (n - 1) > 0 {
			Println(`Yes`)
		} else {
			Println(`No`)
		}
	}
	for t > 0 {
		solve()
		t--
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		var x int64
		fmt.Scan(&x)
		for (x % 2 == 0) {
			x = x / 2
		}
		if (x == 1) {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

import "fmt"

func check(n int64) bool {
    for n % 2 == 0 {
        n /= 2
    }
    return n != 1
}

func main() {
    var t int
    var n int64
    fmt.Scan(&t)
    for i := 0; i < t; i++ {
        fmt.Scan(&n)
        if check(n) {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

package main

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

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

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

func main() {
	defer writer.Flush()
	var t int
	var n int64
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		scanf("%d\n", &n)
		for n % 2 == 0 {
			n /= 2
		}
		if n == 1 {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

package main

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

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

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

func min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var x uint64 = 0
		scanf("%d\n", &x)

		for x % 2 == 0 {
			x = x / 2
		}

		if x == 1 {
			printf("NO\n")
		} else if x % 2 != 0 {
			printf("YES\n")
		}
	}
}

package main

import "fmt"

func judge(x int64) (result bool) {
	for x > 1 {
		if x%2 == 0 {
			x = x / 2
		}
		if x%2 == 1 && x != 1 {
			return true
		}
	}
	return false
}
func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		var x int64
		fmt.Scan(&x)
		if judge(x) == true {
			fmt.Println("YES")
		}
		if judge(x) == false {
			fmt.Println("NO")
		}
	}
}

package main

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

func MIN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

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

		initial := n
		for i := 1; i < 100; i++ {
			if initial%2 == 0 {
				initial = initial / 2
			} else {
				break
			}
		}
		if initial == 1 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}

	}
}

package main

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

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

	solve := func(Case int) {
		var n int64
		Fscan(in, &n)
		if n&(n-1) > 0 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

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

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

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

package main

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

/*

 */

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

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

	for ; t > 0; t-- {
		var n int64
		scanf("%d\n", &n)

		found := false

		sqrt := int64(math.Ceil(math.Sqrt(float64(n))))

		for div1 := int64(1); div1 <= sqrt; div1++ {
			div2 := n / div1
			if n%div1 == 0 && ((n%div1 != 0 && div1 != 1) || div2%2 != 0) {
				found = true
				break
			}
		}

		if found {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

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 min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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))
}

package main

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

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, _ := strconv.Atoi(strings.TrimSpace(s))
	return num
}

// ReadInput reads the standard input and return it as a string
func ReadInput() string {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	return input
}

func findOddDivisor(n int) string {
	if n <= 2 {
		return "NO"
	}

	if n%2 != 0 {
		return "YES"
	}

	for i := 2; i <= int(math.Sqrt(float64(n))); i++ {
		if n%i == 0 && (n/i)%2 != 0 {
			return "YES"
		}
	}

	return "NO"
}

func main() {
	input := ReadInput()
	test_cases := ParseInt(input)

	for i := 0; i < test_cases; i++ {
		cur := ReadInput()
		fmt.Println(cur)
		num := ParseInt(cur)
		fmt.Println(findOddDivisor(num))
	}
}

package main

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

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, _ := strconv.Atoi(strings.TrimSpace(s))
	return num
}

// ReadInput reads the standard input and return it as a string
func ReadInput() string {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	return input
}

func findOddDivisor(n int) string {
	fmt.Println(n)
	if n <= 2 {
		return "NO"
	}

	if n%2 != 0 {
		return "YES"
	}

	for i := 2; i <= int(math.Sqrt(float64(n))); i++ {
		if n%i == 0 && (n/i)%2 != 0 {
			return "YES"
		}
	}

	return "NO"
}

func main() {
	input := ReadInput()
	test_cases := ParseInt(input)

	for i := 0; i < test_cases; i++ {
		cur := ReadInput()
		num := ParseInt(cur)
		fmt.Println(findOddDivisor(num))
	}
}

package main

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

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, _ := strconv.Atoi(strings.TrimSpace(s))
	return num
}

// ReadInput reads the standard input and return it as a string
func ReadInput() string {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	return input
}

func findOddDivisor(n int) string {
	if n <= 2 {
		return "NO"
	}

	if n%2 != 0 {
		return "YES"
	}

	for i := 2; i <= int(math.Sqrt(float64(n))); i++ {
		if n%i == 0 && (n/i)%2 != 0 {
			return "YES"
		}
	}

	return "NO"
}

func main() {
	input := ReadInput()
	test_cases := ParseInt(input)

	for i := 0; i < test_cases; i++ {
		cur := ReadInput()
		num := ParseInt(cur)
		fmt.Println(findOddDivisor(num))
	}
}

package main

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

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int64 {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int64
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int64 {
	num, _ := strconv.ParseInt(strings.TrimSpace(s), 10, 64)
	return num
}

// ReadInput reads the standard input and return it as a string
func ReadInput() string {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	return input
}

func findOddDivisor(n int64) string {
	if n <= 2 {
		return "NO"
	}

	if n%2 != 0 {
		return "YES"
	}

	for i := 2; int64(i) <= int64(math.Sqrt(float64(n))); i++ {
		if n%int64(i) == 0 && (n/int64(i))%2 != 0 {
			return "YES"
		}
	}

	return "NO"
}

func main() {
	input := ReadInput()
	test_cases := ParseInt(input)

	for i := 0; int64(i) < test_cases; i++ {
		cur := ReadInput()
		num := ParseInt(cur)
		fmt.Println(findOddDivisor(num))
	}
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int64
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &n)

		fmt.Fprintln(out, solve(n))

	}

}

func solve(n int64) string {

	if n%2 == 1 {
		return "YES"
	}

	/*d := int64(3)

	for d <= int64(math.Sqrt(float64(n))) {

		if n%d == 0 {
			return "YES"
		}

		d += 2

	}*/

	return "NO"

}

package main

import "fmt"

func solve() {
	var n int64
	fmt.Scanln(&n)
	if n%2 == 1 {
		fmt.Println("YES")
		return
	}
	for j := int64(1); j*j <= n; j++ {
		if n%j == 0 {
			k := n / j
			if ((j&1) == 1 && j > 1) || ((k&1) == 1 && k > 1) {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}
func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n int64
		Fscan(in, &n)

		if n & (n-1) == 0 {
			Fprintln(out, "YES")

		} else {
			Fprintln(out, "NO")
		}
	}

}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int64
		fmt.Scan(&n)

		if n&(n-1) == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int64
		fmt.Scan(&n)
		if n&1 == 1 && n > 2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import "fmt"

func main() {
	var t, n int
	fmt.Scanln(&t)
	for {
		fmt.Scanln(&n)
		for n%2 == 0 {
			n /= 2
		}
		if n != 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
		if t == 0 {
			break
		}
	}
}

package main

import "fmt"

func main() {
	t, n := 0, 0
	fmt.Scan(t)
	for t > 0 {
		fmt.Scan(n)
		for n%2 == 0 {
			n /= 2
		}
		if n != 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var N,x int
	Fscan(in, &N)
	for tt:=0; tt < N; tt ++ {
		Fscan(in, &x)
		for x>0 && x&1 == 0 {
			x = x >> 1
		}
		ans := "YES\n"
		if x == 1 {
			ans = "NO\n"
		}
		out.WriteString(ans)
	}
}

package main

import (
	. "fmt"
)

func main(){
	var t int;
	Scan(&t);
	for i:=0;i<t;i++ {
		var n int64;
		Scan(&n);
		if n%2 == 1 {
			Println("YES");
		} else{
			Println("NO");
		}
	}
}

package main

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

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

func Max(x, y int64) int64 {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	t := 10000
	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		if n&(n-1) == 0 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

func main() {
	a:=bufio.NewReader(os.Stdin)
	l, _ :=a.ReadString('\n')
	l=strings.Trim(strings.Trim(l,"\n"),"\r")
	ln, _ :=strconv.Atoi(l)
	for i:=0; i<ln;i++{
		s,_:=a.ReadString('\n')
		d, _ :=strconv.ParseInt(strings.Trim(strings.Trim(s,"\n"), "\r"),10 , 64)
		fmt.Printf("%s\n",fn(d))

	}
}

func fn(n int64) string {
	if !(n%2==0) || n%6==0{
		return "YES"
	}
	return "NO"
}


We start with a permutation $$$a_1, a_2, \ldots, a_n$$$ and with an empty array $$$b$$$. We apply the following operation $$$k$$$ times.On the $$$i$$$-th iteration, we select an index $$$t_i$$$ ($$$1 \le t_i \le n-i+1$$$), remove $$$a_{t_i}$$$ from the array, and append one of the numbers $$$a_{t_i-1}$$$ or $$$a_{t_i+1}$$$ (if $$$t_i-1$$$ or $$$t_i+1$$$ are within the array bounds) to the right end of the array $$$b$$$. Then we move elements $$$a_{t_i+1}, \ldots, a_n$$$ to the left in order to fill in the empty space.You are given the initial permutation $$$a_1, a_2, \ldots, a_n$$$ and the resulting array $$$b_1, b_2, \ldots, b_k$$$. All elements of an array $$$b$$$ are distinct. Calculate the number of possible sequences of indices $$$t_1, t_2, \ldots, t_k$$$ modulo $$$998\,244\,353$$$.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 100\,000$$$), denoting the number of test cases, followed by a description of the test cases. The first line of each test case contains two integers $$$n, k$$$ ($$$1 \le k < n \le 200\,000$$$): sizes of arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$): elements of $$$a$$$. All elements of $$$a$$$ are distinct. The third line of each test case contains $$$k$$$ integers $$$b_1, b_2, \ldots, b_k$$$ ($$$1 \le b_i \le n$$$): elements of $$$b$$$. All elements of $$$b$$$ are distinct. The sum of all $$$n$$$ among all test cases is guaranteed to not exceed $$$200\,000$$$.

For each test case print one integer: the number of possible sequences modulo $$$998\,244\,353$$$.

Note$$$\require{cancel}$$$Let's denote as $$$a_1 a_2 \ldots \cancel{a_i} \underline{a_{i+1}} \ldots a_n \rightarrow a_1 a_2 \ldots a_{i-1} a_{i+1} \ldots a_{n-1}$$$ an operation over an element with index $$$i$$$: removal of element $$$a_i$$$ from array $$$a$$$ and appending element $$$a_{i+1}$$$ to array $$$b$$$.In the first example test, the following two options can be used to produce the given array $$$b$$$:  $$$1 2 \underline{3} \cancel{4} 5 \rightarrow 1 \underline{2} \cancel{3} 5 \rightarrow 1 \cancel{2} \underline{5} \rightarrow 1 2$$$; $$$(t_1, t_2, t_3) = (4, 3, 2)$$$;  $$$1 2 \underline{3} \cancel{4} 5 \rightarrow \cancel{1} \underline{2} 3 5 \rightarrow 2 \cancel{3} \underline{5} \rightarrow 1 5$$$; $$$(t_1, t_2, t_3) = (4, 1, 2)$$$. In the second example test, it is impossible to achieve the given array no matter the operations used. That's because, on the first application, we removed the element next to $$$4$$$, namely number $$$3$$$, which means that it couldn't be added to array $$$b$$$ on the second step.In the third example test, there are four options to achieve the given array $$$b$$$:  $$$1 4 \cancel{7} \underline{3} 6 2 5 \rightarrow 1 4 3 \cancel{6} \underline{2} 5 \rightarrow \cancel{1} \underline{4} 3 2 5 \rightarrow 4 3 \cancel{2} \underline{5} \rightarrow 4 3 5$$$; $$$1 4 \cancel{7} \underline{3} 6 2 5 \rightarrow 1 4 3 \cancel{6} \underline{2} 5 \rightarrow 1 \underline{4} \cancel{3} 2 5 \rightarrow 1 4 \cancel{2} \underline{5} \rightarrow 1 4 5$$$; $$$1 4 7 \underline{3} \cancel{6} 2 5 \rightarrow 1 4 7 \cancel{3} \underline{2} 5 \rightarrow \cancel{1} \underline{4} 7 2 5 \rightarrow 4 7 \cancel{2} \underline{5} \rightarrow 4 7 5$$$; $$$1 4 7 \underline{3} \cancel{6} 2 5 \rightarrow 1 4 7 \cancel{3} \underline{2} 5 \rightarrow 1 \underline{4} \cancel{7} 2 5 \rightarrow 1 4 \cancel{2} \underline{5} \rightarrow 1 4 5$$$;

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	//out := bufio.NewWriter(os.Stdout)
	matA := make([]int, 200100)
	matB := make([]int, 200100)
	matIndex := make([]int, 200100)
	numFlag := make([]int, 200100)
	var t int
	var n, k int
	var mod uint64 = uint64(998244353)
	fmt.Fscanf(in, "%d\n", &t)
	for loopt := 0; loopt < t; loopt++ {
		fmt.Fscanf(in, "%d %d\n", &n, &k)

		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &matA[i])
			matIndex[matA[i]] = i
			numFlag[i+1] = 0
		}
		fmt.Fscanf(in, "\n")
		for i := 0; i < k; i++ {
			fmt.Fscanf(in, "%d", &matB[i])
		}
		fmt.Fscanf(in, "\n")

		//for i:= 0;i < n;i++{
		//	fmt.Printf("%d ",matA[i])
		//}
		//fmt.Printf("\n")
		//for i:= 0;i < k;i++{
		//	fmt.Printf("%d ",matB[i])
		//}
		//fmt.Printf("\n")

		ans := uint64(1)
		maybe := 2
		for i := k - 1; i >= 0; i-- {
			maybe = 2
			if matIndex[matB[i]] == 0 {
				maybe--
			} else if numFlag[matA[matIndex[matB[i]]-1]] == 1 {
				maybe--
			}

			if matIndex[matB[i]] == n-1 {
				maybe--
			} else if numFlag[matA[matIndex[matB[i]]+1]] == 1 {
				maybe--
			}
			ans = (ans * uint64(maybe)) % mod
			//fmt.Printf("i=%d,maybe=%d\n",i,maybe)
			numFlag[matB[i]] = 1
		}
		fmt.Printf("%d\n", ans)
	}
	//fmt.Fprintln(out, solve(mat, m, n, d))
	//mat := []int64{8,10,15,23,5}
	//fmt.Printf("%v\n",solve(mat,11,5,2))
	//
	//
	//mat = []int64{20, 5, 8, 2, 18, 16, 2, 16, 16, 1, 5, 16, 2, 13, 6, 16, 4, 17, 21, 7}
	//fmt.Printf("%v\n",solve(mat,16,20,2))

}