package main

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

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

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    t := nextInt()
    for k := 0; k < t; k++ {
        l := nextInt64()
        r := nextInt64()
        if r & (r + 1) == 0 {
            fmt.Fprintln(out, r)
            continue
        }
        var a int64
        a = 1
        for a - 1 < r {
            a = a << 1
        }
        a--
        if a >= l && a <= r {
            fmt.Fprintln(out, a)
        } else {
            var x uint
            for l <= r {
                l = l | (1 << x)
                x++
            }
            x--
            l = l ^ (1 << x)
            l = l ^ 0
            fmt.Fprintln(out, l)
        }
    }
}

package main

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

var (
	in  *bufio.Reader
	out *bufio.Writer
)

func init() {
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
}

func main() {
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		var l, r int64
		fmt.Fscan(in, &l, &r)
		x := l
		for j := uint(0); x|(1<<j) <= r; j++ {
			x |= 1 << j
		}
		fmt.Fprintln(out, x)
	}
}

package main

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

func scanInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	pow := make([]int64, 61)
	x := int64(1)
	for i := range pow {
		pow[i] = x
		x *= 2
	}
	n := int(scanInt64(scanner))
	for i := 0; i < n; i++ {
		min, max := scanInt64(scanner), scanInt64(scanner)
		best := int64(0)
		for m := 60; m != 0; m-- {
			count := m
			x := int64(0)
			pos := 60
			for {
				for pos != -1 && pow[pos] > min-x {
					pos--
				}
				if pos == -1 {
					break
				}
				x += pow[pos]
				count--
			}
			//writer.WriteString(fmt.Sprintf("m = %d, x = %d, count = %d\n",
			//		m, x, count))
			for pos = 0; count != 0; pos++ {
				if x&pow[pos] == 0 {
					x += pow[pos]
					count--
				}
			}
			//writer.WriteString(fmt.Sprintf("m = %d, x = %d, count = %d\n",
			//		m, x, count))
			if x >= min && x <= max {
				best = x
				break
			}
		}
		writer.WriteString(fmt.Sprintf("%d\n", best))
	}
}

package main

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

func pow484A(n int64) int64 {
	msb := uint(0)
	for n >>= 1; n != 0; n >>= 1 {
		msb++
	}
	return int64(1) << msb
}

func f484A(l, r int64, i int) int64 {
	if l == r || (r+1)&r == 0 {
		return r
	}
	if common := l & r; common < r&^common {
		return pow484A(r) - 1
	}
	for ; i >= 0; i-- {
		pow2 := int64(1) << uint(i)
		if l&pow2 > 0 && r&pow2 > 0 {
			return pow2 | f484A(l-pow2, r-pow2, i-1)
		}
	}
	panic("err")
}

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

	var n int
	for Fscan(in, &n); n > 0; n-- {
		var l, r int64
		Fscan(in, &l, &r)
		Fprintln(out, f484A(l, r, 60))
	}
}

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

package main

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

func setBitNumber484A(n int64) int64 {
	if n == 0 {
		return 0
	}
	msb := uint(0)
	for n >>= 1; n != 0; n >>= 1 {
		msb++
	}
	return int64(1) << msb
}

func f484A(l, r int64, i int) int64 {
	if l == r || (r+1)&r == 0 {
		return r
	}
	if common := l & r; common < r&^common {
		return setBitNumber484A(r) - 1
	}
	for ; i >= 0; i-- {
		pow2 := int64(1) << uint(i)
		if l&pow2 > 0 && r&pow2 > 0 {
			return pow2 | f484A(l-pow2, r-pow2, i-1)
		}
	}
	panic("err")
}

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

	var n int
	for Fscan(in, &n); n > 0; n-- {
		var l, r int64
		Fscan(in, &l, &r)
		Fprintln(out, f484A(l, r, 60))
	}
}

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

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	pow := make([]int64, 61)
	x := int64(1)
	for i := range pow {
		pow[i] = x
		x *= 2
	}
	n := scanInt(scanner)
	for i := 0; i < n; i++ {
		min, max := int64(scanInt(scanner)), int64(scanInt(scanner))
		best := int64(0)
		for m := 60; m != 0; m-- {
			count := m
			x := int64(0)
			pos := 60
			for {
				for pos != -1 && pow[pos] > min-x {
					pos--
				}
				if pos == -1 {
					break
				}
				x += pow[pos]
				count--
			}
			//writer.WriteString(fmt.Sprintf("m = %d, x = %d, count = %d\n",
			//		m, x, count))
			for pos = 0; count != 0; pos++ {
				if x&pow[pos] == 0 {
					x += pow[pos]
					count--
				}
			}
			//writer.WriteString(fmt.Sprintf("m = %d, x = %d, count = %d\n",
			//		m, x, count))
			if x >= min && x <= max {
				best = x
				break
			}
		}
		writer.WriteString(fmt.Sprintf("%d\n", best))
	}
}

package main

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

var (
	in  *bufio.Reader
	out *bufio.Writer
)

func init() {
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
}

func main() {
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		var l, r int64
		fmt.Fscan(in, &l, &r)
		x := l
		for j := uint(0); x|(1<<j) < r; j++ {
			x |= 1 << j
		}
		fmt.Fprintln(out, x)
	}
}

package main

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

func Sol484A(reader io.Reader, writer io.Writer) {
	setBitNumber := func(n int64) int64 {
		if n == 0 {
			return 0
		}
		msb := uint(0)
		for n >>= 1; n != 0; n >>= 1 {
			msb++
		}
		return int64(1) << msb
	}

	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	for Fscan(in, &n); n > 0; n-- {
		var l, r int64
		Fscan(in, &l, &r)
		if l == r || (r+1)&r == 0 {
			Fprintln(out, r)
			continue
		}
		if common := l & r; common < r&^common {
			Fprintln(out, setBitNumber(r)-1)
			continue
		}
		found := false
		base := int64(0)
		for i := 60; i >= 0; i-- {
			pow2 := int64(1) << uint(i)
			if l&pow2 > 0 && r&pow2 > 0 {
				found = true
				base |= pow2
			} else if found {
				break
			}
		}
		r &^= base
		if r == 1 {
			Fprintln(out, base|r)
		} else {
			Fprintln(out, base|(setBitNumber(r)-1))
		}
	}
}

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

package main

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

func Sol484A(reader io.Reader, writer io.Writer) {
	setBitNumber := func(n int64) int64 {
		if n == 0 {
			return 0
		}
		msb := uint(0)
		for n >>= 1; n != 0; n >>= 1 {
			msb++
		}
		return int64(1) << msb
	}

	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	for Fscan(in, &n); n > 0; n-- {
		var l, r int64
		Fscan(in, &l, &r)
		if l == r || (r+1)&r == 0 {
			Fprintln(out, r)
			continue
		}
		common := l & r
		if common < r&^common {
			Fprintln(out, setBitNumber(r)-1)
			continue
		}
		found := false
		base := int64(0)
		for i := 60; i >= 0; i-- {
			pow2 := int64(1) << uint(i)
			if l&pow2 > 0 && r&pow2 > 0 {
				found = true
				base |= pow2
			} else if found {
				break
			}
		}
		r &^= base
		Fprintln(out, base|(setBitNumber(r)-1))
	}
}

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


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 main() {
	defer writer.Flush()

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

	for k := 0; k < t; k++ {
		var l, r uint64
		scanf("%d %d\n", &l, &r)

		x := l
		y := x + x

		if y <= r {
			printf("%d %d\n", x, y)
		} else {
			printf("-1 -1\n")
		}
	}
}

package main

import  (
	"fmt"
)

func main () {
	var cases int
	fmt.Scanln(&cases)
	for i:=0 ;i<cases ;i++{
		var l,r int
		fmt.Scanln(&l,&r)
		if l*2 <= r {
			fmt.Println(l,2*l)
		} else {
			fmt.Println(-1,-1)
		}
	}
}

package main

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

var rw = newFastIO(os.Stdin, os.Stdout)

func main() {
	defer rw.Flush()
	nTest := 1
	nTest = rw.nextInt()
	for i := 0; i < nTest; i++ {
		solveCase()
	}
}

func solveCase() {
	l := rw.nextInt()
	r := rw.nextInt()
	if r >= l*2 {
		rw.printlnInts(l, l*2)
	} else {
		rw.printlnInts(-1, -1)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	neg := false
	if f.p[0] == '-' {
		neg = true
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	if neg {
		return -n
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		l := sint64()
		r := sint64()
		x, y := sol(l, r)
		printf("%d %d\n", x, y)
	}
}

func sol(l, r int64) (int64, int64) {
	if 2*l > r {
		return -1, -1
	}
	return l, l * 2
}

package main

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

func main() {
	var t, l, r int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &l, &r)
		if l*2 <= r {
			fmt.Println(l, l*2)
		} else {
			fmt.Println(-1, -1)
		}
	}
}

package main

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

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

	T:= 0
	for Fscan(in, &T); T > 0; T-- {
		var l,r int
		Fscan(in, &l,&r);
		if 2*l<=r{
			Fprintln(out,l,2*l)
		} else {
			Fprintln(out,-1,-1)
		}
	}
}

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

package main

import "fmt"

func main(){
	var testCnt int
	var l, r int
	fmt.Scanf("%d\n",&testCnt)
	for i:=0; i<testCnt; i++ {
		fmt.Scanf("%d %d\n",&l,&r)
		if 2*l > r{
			fmt.Printf("%d %d\n",-1,-1)
		}else {
			fmt.Printf("%d %d\n",l,2*l)
		}
	}
}

package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		l, r := io.nextInt(), io.nextInt()
		x, y := -1, -1
		if 2*l <= r {
			x, y = l, 2*l
		}
		io.println(x, y)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	neg := false
	if f.p[0] == '-' {
		neg = true
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	if neg {
		return -n
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 3*1024*1024)
	scanner.Split(bufio.ScanWords)

	input := func() uint64 {
		scanner.Scan()
		i, _ := strconv.ParseUint(scanner.Text(), 10, 64)
		return i
	}

	for t := input(); t > 0; t-- {
		l, r := input(), input()

		if 2*l > r {
			fmt.Println(-1, -1)
		} else {
			fmt.Println(l, 2*l)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, x, y int;
	fmt.Scanf("%d\n", &t);
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d\n", &x, &y);
		a := x;
		b := 2 * x;
		if b > y {
			a = -1;
			b = -1;
		}
		fmt.Printf("%d %d\n", a, b);
	}
}

package main

import "fmt"

func main() {
	var i, t, x, y, a, b int;
	fmt.Scanf("%d\n", &t);
	for i = 0; i < t; i++ {
		fmt.Scanf("%d %d\n", &x, &y);
		a = x;
		b = 2 * x;
		if b > y {
			a = -1;
			b = -1;
		}
		fmt.Printf("%d %d\n", a, b);
	}
}

/*
URL:
https://codeforces.com/contest/1389/problem/A
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

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

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

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

const (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	l, r int64
)

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		l, r = ReadInt64_2()

		solve()
	}
}

func solve() {
	x := l
	for i := int64(2); ; i++ {
		y := x * i
		lcmxy := Lcm(x, y)
		if l <= lcmxy && lcmxy <= r {
			fmt.Println(x, y)
			return
		}

		if lcmxy > r {
			break
		}
	}
	fmt.Println(-1, -1)
}

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

	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

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

	return a
}

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

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

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

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

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

	var T, l, r int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &l, &r)
		if 2*l > r {
			Fprintln(out, -1, -1)
		} else {
			Fprintln(out, l, 2*l)
		}
	}
}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 1; i <= t; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		if r < 2*l {
			fmt.Println("-1 -1")
			continue
		}
		fmt.Printf("%d %d\n", l, 2*l)
	}
}

package main

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

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

	var t int

	fmt.Fscan(input, &t)

	for z := 0; z < t; z++ {
		var l, r int
		fmt.Fscan(input, &l, &r)

		if l*2 > r {
			fmt.Println("-1 -1")
		} else {
			fmt.Printf("%d %d\n", l, l*2)
		}

	}
}

package main

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

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

	var t, l, r int

	fmt.Fscan(input, &t)

	for z := 0; z < t; z++ {
		fmt.Fscan(input, &l, &r)

		if l*2 > r {
			fmt.Println("-1 -1")
		} else {
			fmt.Printf("%d %d\n", l, l*2)
		}

	}
}

package main

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

func solve() {
	x, y := readInt64(), readInt64()
	if x*2 <= y {
		fmt.Println(x, x*2)
	} else {
		fmt.Println(-1, -1)
	}
}

func main() {
	k := readInt()
	for i := 0; i < k; i++ {
		solve()
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

package main

import "fmt"

func main() {
	var tt, x, y int
	fmt.Scan(&tt)
	for tt > 0 {
		fmt.Scan(&x, &y)
		if x*2 <= y {
			fmt.Printf("%d %d\n", x, x*2)
		} else {
			fmt.Println("-1 -1")
		}
		tt--
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var l, r int
		fmt.Scanf("%d %d\n", &l, &r)
		y := l * 2
		if y > r {
			fmt.Println("-1 -1")
		} else {
			fmt.Printf("%d %d\n", l, y)
		}
	}
}

package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	var gcd func(i, j int) int
	gcd = func(i, j int) int {
		if j == 0 {
			return i
		}
		return gcd(j, i%j)
	}

	for t := io.nextInt(); t > 0; t-- {
		l, r := io.nextInt(), io.nextInt()
		x, y := -1, -1
		for i := l; i < l+10 && i <= r; i++ {
			for j := i + 1; j < l+10 && j <= r; j++ {
				lcm := int64(i) * int64(j) / int64(gcd(i, j))
				if lcm <= int64(r) {
					x, y = i, j
				}
			}
		}
		io.println(x, y)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	neg := false
	if f.p[0] == '-' {
		neg = true
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	if neg {
		return -n
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

import "fmt"

func main() {
	var x, y int;
	fmt.Scanf("%d %d", &x, &y);
	fmt.Printf("%d %d\n", x, x);
}

package main

import "fmt"

func main() {
	var i, t, x, y, a, b int;
	fmt.Scanf("%d", &t);
	for i = 0; i < t; i++ {
		fmt.Scanf("%d %d", &x, &y);
		a = x;
		b = 2 * x;
		if b > y {
			a = -1;
			b = -1;
		}
		fmt.Printf("%d %d\n", a, b);
	}
}

package main

import "fmt"

func main() {
	var i, t, x, y int;
	fmt.Scanf("%d", &t);
	for i = 0; i < t; i++ {
		fmt.Scanf("%d %d", &x, &y);
		fmt.Printf("%d %d\n", x, x);
	}
}

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

// greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// find Least Common Multiple (LCM) via GCD
func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

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

func main() {
	defer writer.Flush()

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

	for k := 0; k < t; k++ {
		var l, r int
		scanf("%d %d\n", &l, &r)

		var f bool
		// printf("-> %d %d\n", l, r)

		for x := l; x < r; x++ {
			for y := x + 1; y <= r; y++ {
				lcm := LCM(x, y)
				// printf("check %d %d -> %d\n", x, y, lcm)
				// printf("%d", LCM(13, 37))
				if lcm >= l && lcm <= r {
					printf("%d %d\n", x, y)
					f = true
					break
				}
			}
			if f {
				break
			}
		}
		if !f {
			printf("-1 -1\n")
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var l, r int
		fmt.Scanf("%d %d\n", &l, &r)
		y := l * 2
		if y > r {
			println("-1 -1\n")
		} else {
			fmt.Printf("%d %d\n", l, y)
		}
	}
}


package main

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

func solve(input io.Reader, output io.Writer) {
	var result string
	var t, n, m int
	var a11, a12, a21, a22 int
	fmt.Fscanf(input, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(input, "%d %d\n", &n, &m)
		result = "NO"
		for j := 0; j < n; j++ {
			fmt.Fscanf(input, "%d %d\n", &a11, &a12)
			fmt.Fscanf(input, "%d %d\n", &a21, &a22)

			if a12 == a21 && m % 2 == 0 {
				result = "YES"
			}
		}
 		fmt.Fprintln(output, result)
	}
}

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

package main

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

func print( a ...interface{}) { fmt.Fprint(w, a...) }
func scan( a ...interface{})  { fmt.Fscan(r, a...) }

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

func main() {
	defer w.Flush()
	var q int
	scan(&q)
	for ; q > 0; q-- {
		var n int
		scan(&n)
		var m int
		scan(&m)
		var bl = false
		if m % 2 != 0 {
			print("NO\n")
			for i := 0; i < n; i++ {
				var a, b, c, d int
				scan(&a, &b, &c, &d)
			}
		}else{
			for i := 0; i < n; i++ {
				var a, b, c, d int
				scan(&a, &b, &c, &d)
				if !bl && b == c {
					bl = true
				}
			}
			if bl {
				print("YES\n")
			}else {
				print("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, m, a, b, c, d int
	fmt.Scan(&t)
	for t != 0 {
		var matrix []([2][2]int) = make([]([2][2]int), 0)
		fmt.Scan(&n, &m)
		for i := 0; i < n; i++ {
			fmt.Scan(&a, &b)
			fmt.Scan(&c, &d)
			var x [2][2]int
			x[0][0] = a
			x[0][1] = b
			x[1][0] = c
			x[1][1] = d
			matrix = append(matrix, x)
		}
		if m%2 != 0 {
			fmt.Println("NO")
		} else {
			okay := false
			for i := 0; i < n; i++ {
				b := matrix[i][0][1]
				c := matrix[i][1][0]
				okay = okay || (b == c)
			}
			if okay {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
		t--
	}
}

package main

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

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

func main() {
	defer writer.Flush()
	var testCaseNum int
	fmt.Fscan(reader, &testCaseNum)

	for testCase := 0; testCase < testCaseNum; testCase++ {
		available := false
		var n, m int
		fmt.Fscan(reader, &n, &m)

		var a, b, c, d int
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a, &b, &c, &d)
			if b == c {
				available = true
			}
		}

		if !available || m&1 == 1 {
			writer.WriteString("NO\n")
		} else {
			writer.WriteString("YES\n")
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var n, m int
		fmt.Scanf("%d %d\n", &n, &m)
		possible := false
		for j := 0; j < n; j++ {
			var a, b, c, d int
			fmt.Scanf("%d %d\n%d %d\n", &a, &b, &c, &d)
			if b == c {
				possible = true
			}
		}
		if possible && m%2 == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

	var T, n, m, x1, y1, x2, y2 int
	fmt.Fscan(r, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(r, &n, &m)
		b := false
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &x1, &y1)
			fmt.Fscan(r, &x2, &y2)
			if !b && y1 == x2 {
				b = true
			}
		}
		if m % 2 != 0 {
			fmt.Fprint(w, "NO\n")
			continue
		}
		if b {
			fmt.Fprint(w, "YES\n")
		}else {
			fmt.Fprint(w, "NO\n")
		}
	}
}

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

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

type block struct {
	a, b, c, d int
}

func solve() {
	n := nextInt()
	m := nextInt()
	arr := make([]block, n)
	for i, _ := range arr {
		arr[i] = block{nextInt(), nextInt(), nextInt(), nextInt()}
	}
	if m % 2 == 1 {
		printf("NO\n")
		return
	}
	flag1 := false
	for _, v := range arr {
		if v.b == v.c {
			flag1 = true
		}
	}
		if flag1 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
		return

}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)

	defer out.Flush()

	for t := nextInt(); t > 0; t-- {
		solve()
	}
}

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 solve() {
	var n, m int
	scanf("%d %d\n", &n, &m)
	issym := false

	for i := 0; i < n; i++ {
		var a, b, c, d int
		scanf("%d %d\n%d %d\n", &a, &b, &c, &d)
		issym = issym || (b == c)
	}
	issym = issym && m % 2 == 0
	if issym {
		printf("%s\n", "YES")
	} else {
		printf("%s\n", "NO")
	}
}

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

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

func main() {
	t := ReadInt()
	for i := 0; i < t; i++ {
		n, m := ReadInt64(), ReadInt64()
		matrix := make([][]int64, n)
		for i := int64(0); i < n; i++ {
			matrix[i] = ReadInt64s(4)
		}
		if solve(n, m, matrix) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func solve(n, m int64, matrix [][]int64) bool {
	if m%2 == 1 {
		return false
	}
	for i := 0; i < len(matrix); i++ {
		if matrix[i][1] == matrix[i][2] {
			return true
		}
	}
	return false
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) []int64 {
	v := make([]int64, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

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

// ==================== 以上是模版 ====================
func solve() {
	n := nextInt()
	m := nextInt()
	//fmt.Printf("n:%d,m:%d\n", n, m)
	ok := 0
	for ; n > 0; n-- {
		_, b, c, _ := nextInt(), nextInt(), nextInt(), nextInt()
		//fmt.Printf("b:%d,c:%d\n", b, c)
		if b == c {
			ok = 1
		}
	}
	if ok == 1 && m%2 == 0 {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

func getIn() *bufio.Reader {
	x := `6
3 4
1 2
5 6
5 7
7 4
8 9
9 8
2 5
1 1
1 1
2 2
2 2
1 100
10 10
10 10
1 2
4 5
8 4
2 2
1 1
1 1
1 2
3 4
1 2
1 1
1 1`
	return bufio.NewReaderSize(strings.NewReader(x), 8192)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	//in = getIn()
	// 要求： /  , 至少有一个相同的
	// 要求：

	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()

	for t := nextInt(); t > 0; t-- {
		solve()
	}

}

package main
import."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n, m, a, b, c, d int
	for Scan(&T); T > 0; T-- {
		ok := false
		for Scan(&n, &m); n > 0; n-- {
			Scan(&a, &b, &c, &d)
			ok = ok || b == c
		}
		if ok && m&1 == 0 {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

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

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

	var T, n, m, x1, y1, x2, y2 int
	fmt.Fscan(r, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(r, &n, &m)
		b1, b2 := false, false
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &x1, &y1)
			fmt.Fscan(r, &x2, &y2)
			if !b1 && x1 == y2 {
				b1 = true

			}
			if !b2 && y1 == x2 {
				b2 = true
			}
		}
		if m % 2 != 0 {
			fmt.Fprint(w, "NO\n")
			continue
		}
		if b1 && b2 {
			fmt.Fprint(w, "YES\n")
		}else {
			fmt.Fprint(w, "NO\n")
		}
	}
}

package main

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

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

	var T, n, m, x1, y1, x2, y2 int
	fmt.Fscan(r, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(r, &n, &m)
		b1, b2 := false, false
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &x1, &y1)
			fmt.Fscan(r, &x2, &y2)
			if x1 == y2 {
				b1 = true
			}
			if y1 == x2 {
				b2 = true
			}
		}
		if m % 2 != 0 {
			fmt.Fprint(w, "NO\n")
			continue
		}
		if b1 && b2 {
			fmt.Fprint(w, "YES\n")
		}else {
			fmt.Fprint(w, "NO\n")
		}
	}
}

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

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

type block struct {
	a, b, c, d int
}

func solve() {
	n := nextInt()
	m := nextInt()
	arr := make([]block, n)
	for i, _ := range arr {
		arr[i] = block{nextInt(), nextInt(), nextInt(), nextInt()}
	}
	if m % 2 == 1 {
		printf("NO\n")
		return
	}
	flag1 := false
	for _, v := range arr {
		if v.b == v.c {
			flag1 = true
		}
	}
	if m == 2 {
		if flag1 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
		return
	}
	flag := false
	for i, x := range arr {
		for j, y := range arr {
			if i < j && x.a == y.a && x.d == y.d && x.c == y.b && x.b == y.c {
				flag = true
			}
		}
	}
	if flag || flag1 {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)

	defer out.Flush()

	for t := nextInt(); t > 0; t-- {
		solve()
	}
}

package main

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

func print( a ...interface{}) { fmt.Fprint(w, a...) }
func scan( a ...interface{})  { fmt.Fscan(r, a...) }

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

func main() {
defer w.Flush()
	var q int
	scan(&q)
	for ; q > 0; q-- {
		var n int
		scan(&n)
		var m int
		scan(&m)
		var bl = false
		if m % 2 != 0 {
			print("NO\n")
			for i := 0; i < n; i++ {
				var a, b, c, d int
				scan(&a, &b, &c, &d)
			}
		}else{
			for i := 0; i < n; i++ {
				var a, b, c, d int
				scan(&a, &b, &c, &d)
				if !bl && a == d && b == c {
					bl = true
				}
			}
			if bl {
				print("YES\n")
			}else {
				print("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, m, a, b, c, d int
	fmt.Scan(&t)
	for t != 0 {
		var matrix []([2][2]int) = make([]([2][2]int), 0)
		fmt.Scan(&n, &m)
		for i := 0; i < n; i++ {
			fmt.Scan(&a, &b)
			fmt.Scan(&c, &d)
			var x [2][2]int
			x[0][0] = a
			x[0][1] = b
			x[1][0] = c
			x[1][1] = d
			matrix = append(matrix, x)
		}
		if m != 2 {
			if m%2 != 0 {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		} else {
			for i := 0; i < n; i++ {
				a := matrix[i][0][0]
				b := matrix[i][0][1]
				c := matrix[i][1][0]
				d := matrix[i][1][1]

				if a == d && c == b {
					fmt.Println("YES")
					break
				} else {
					fmt.Println("NO")
					break
				}
			}
		}
		t--
	}
}


package main
import (
	"fmt"
	//"sort"
	"bufio"
	"os"
	"strconv"
)
func main() {
	var n,i,k,a int
	var p [100010]int
	fmt.Scan(&n,&k)
	input := bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	for i=1;i<=n;i++ {
		input.Scan()
		bb,_:=strconv.Atoi(input.Text())
		a=bb
		p[i%k]+=a
	}
	p[k]=p[0]
	a=1
	for i=2;i<=k;i++ {
		if p[i]<p[a] {
			a=i
		}
	}
	fmt.Println(a)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)

    ScanInts := func(a... *int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }

    var n,k,a int
    ScanInts(&n,&k)
    c := make([]int,k)
    for i := 0; i < n; i++ {
        ScanInts(&a)
        c[i%k] += a
    }
    min, ans := 1000000000, 0
    for i := 0; i < k; i++ {
        if min > c[i] { min = c[i]; ans = i+1 }
    }
    fmt.Println(ans)
}


package main

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

type IntArray []int

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

const SIZE = 100111

var num [SIZE]int
var typenum [SIZE][2]int

func main() {
	var t int
	r := bufio.NewReader(os.Stdin)
	Fscan(r, &t)
	for te := 0; te < t; te++ {
		var n int
		Fscan(r, &n)
		for i := 0; i < n; i++ {
			Fscan(r, &num[i])
			typenum[num[i]][0] = 0
			typenum[num[i]][1] = 0
		}
		for i := 0; i < n; i++ {
			typenum[num[i]][i&1]++
		}
		sort.Sort(IntArray(num[:n]))
		r := true
		for i := 0; i < n; i++ {
			if typenum[num[i]][i&1] > 0 {
				typenum[num[i]][i&1]--
			} else {
				r = false
			}
		}
		if r {
			Printf("YES\n")
		} else {
			Printf("NO\n")
		}
	}
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		a := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		ans := solve(a, n)

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

	}
}

//4 3 2 5
// -> -> -> ->

//3 4 2 5
//<- <- -> ->

//

type pair struct {
	v int
	index int
}

func solve(a[]int, n int) bool {

	mp := make([][]int, 1e5 + 1)

	for i := 0; i < n; i++ {
		mp[a[i]] = append(mp[a[i]], i + 1)
	}

	dedup := make(map[int]bool)

	for i := 0; i < n; i++ {
		dedup[a[i]] = true
	}

	var b []int

	for k, _ := range dedup {
		b = append(b, k)
	}

	sort.Ints(b)

	start := 1

	for i := 0; i < len(b); i++ {
		c := b[i]

		indexes := mp[c]

		//5 indexes
		//1 2 3 4 5

		odd := 0
		even := 0

		oddPos := 0
		evenPos := 0

		for j := 0; j < len(indexes); j++ {
			index := indexes[j]

			if index % 2 == 0 {
				even ++
			} else {
				odd ++
			}
			if start % 2 == 0 {
				evenPos++
			} else {
				oddPos++
			}

			start++
		}

		if odd != oddPos || even != evenPos {
			return false
		}
	}
	return true
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%s\n", sol(n, a))
	}
}

func sol(n int64, a []int64) string {
	even := []int64{}
	odd := []int64{}
	for i := range a {
		if i&1 == 0 {
			even = append(even, a[i])
		} else {
			odd = append(odd, a[i])
		}
	}
	sort.Slice(even, func(il, ir int) bool {
		return even[il] < even[ir]
	})
	sort.Slice(odd, func(il, ir int) bool {
		return odd[il] < odd[ir]
	})
	for i := range odd {
		if !(odd[i] >= even[i]) {
			return "NO"
		}
		if i+1 < len(even) && !(odd[i] <= even[i+1]) {
			return "NO"
		}
	}
	return "YES"
}

package main

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

var in *bufio.Reader

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

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

	sort.Ints(a)
	odd, even := make(map[int]int), make(map[int]int)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			even[a[i]]++
		} else {
			odd[a[i]]++
		}
	}

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			if even[b[i]] == 0 {
				fmt.Println("NO")
				return
			} else {
				even[b[i]]--
			}
		} else {
			if odd[b[i]] == 0 {
				fmt.Println("NO")
				return
			} else {
				odd[b[i]]--
			}
		}
	}
	fmt.Println("YES")
}

func main() {
	in = bufio.NewReader(os.Stdin)

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1545A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var T, n int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		b := []int{}
		for i := range a {
			Fscan(in, &a[i])
			if i&1 == 0 {
				b = append(b, a[i])
			}
		}
		sort.Ints(a)
		sort.Ints(b)
		for i, v := range b {
			if v != a[i*2] {
				Fprintln(out, "NO")
				continue o
			}
		}
		Fprintln(out, "YES")
	}
}

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

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%s\n", sol(n, a))
	}
}

func sol(n int64, a []int64) string {
	even := []int64{}
	odd := []int64{}
	for i := range a {
		if i % 2 == 0 {
			even = append(even, a[i])
		} else {
			odd = append(odd, a[i])
		}
	}
	sort.Slice(even, func(il, ir int) bool {
		return even[il] < even[ir]
	})
	sort.Slice(odd, func(il, ir int) bool {
		return odd[il] < odd[ir]
	})
	for i := range odd {
		if !(odd[i] >= even[i]) {
			return "NO"
		}
		if i+1 < len(even) && !(odd[i] <= even[i+1]) {
			return "NO"
		}
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%s\n", sol(n, a))
	}
}

func sol(n int64, a []int64) string {
	even := []int64{}
	odd := []int64{}
	for i := range a {
		if i & 1 == 0 {
			even = append(even, a[i])
		} else {
			odd = append(odd, a[i])
		}
	}
	sort.Slice(even, func(il, ir int) bool {
		return even[il] < even[ir]
	})
	sort.Slice(odd, func(il, ir int) bool {
		return odd[il] < odd[ir]
	})
	for i := range odd {
		if !(odd[i] >= even[i]) {
			return "NO"
		}
		if i+1 < len(even) && !(odd[i] <= even[i+1]) {
			return "NO"
		}
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%s\n", sol(n, a))
	}
}

func sol(n int64, a []int64) string {
	even := []int64{}
	odd := []int64{}
	for i := range a {
		if i == 1 {
			even = append(even, a[i])
		} else {
			odd = append(odd, a[i])
		}
	}
	sort.Slice(even, func(il, ir int) bool {
		return even[il] < even[ir]
	})
	sort.Slice(odd, func(il, ir int) bool {
		return odd[il] < odd[ir]
	})
	for i := range odd {
		if !(odd[i] >= even[i]) {
			return "NO"
		}
		if i+1 < len(even) && !(odd[i] <= even[i+1]) {
			return "NO"
		}
	}
	return "YES"
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		a := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		ans := solve(a, n)

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

	}
}

//4 3 2 5
// -> -> -> ->

//3 4 2 5
//<- <- -> ->

//

type pair struct {
	v int
	index int
}

func solve(a[]int, n int) bool {

	mp := make([][]int, 1e5 + 1)

	for i := 0; i < n; i++ {
		mp[a[i]] = append(mp[a[i]], i + 1)
	}

	dedup := make(map[int]bool)

	for i := 0; i < n; i++ {
		dedup[a[i]] = true
	}

	var b []int

	for k, _ := range dedup {
		b = append(b, k)
	}

	sort.Ints(b)

	start := 1

	for i := 0; i < len(b); i++ {
		c := b[i]

		indexes := mp[c]

		//5 indexes
		//1 2 3 4 5

		odd := 0
		even := 0

		oddPos := 0
		evenPos := 0

		for j := 0; j < len(indexes); j++ {
			index := indexes[j]

			if index % 2 == 0 {
				even ++
			} else {
				odd ++
			}
			if start % 2 == 0 {
				evenPos++
			} else {
				oddPos++
			}

			if odd != oddPos || even != evenPos {
				return false
			}

			start++
		}
	}
	return true
}

package main

import (
	. "fmt"
	"sort"
)

type IntArray []int

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

const SIZE = 100111

var num [SIZE]int
var typenum [SIZE][2]int

func main() {
	var t int
	Scanf("%d", &t)
	for te := 0; te < t; te++ {
		var n int
		Scanf("%d", &n)
		//Scanln(num)
		for i := 0; i < n; i++ {
			Scanf("%d", &num[i])
			typenum[num[i]][0] = 0
			typenum[num[i]][1] = 0
		}
		for i := 0; i < n; i++ {
			typenum[num[i]][i&1]++
		}
		sort.Sort(IntArray(num[:n]))
		r := true
		for i := 0; i < n; i++ {
			if typenum[num[i]][i&1] > 0 {
				typenum[num[i]][i&1]--
			} else {
				r = false
			}
		}
		if r {
			Printf("YES\n")
		} else {
			Printf("NO\n")
		}
	}
}

package main

import (
	. "fmt"
	"sort"
)

type IntArray []int

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

const SIZE = 100111

var num [SIZE]int
var typenum [SIZE][2]int

func main() {
	var t int
	Scanf("%d", &t)
	for te := 0; te < t; te++ {
		var n int
		Scanf("%d", &n)
		for i := 0; i < n; i++ {
			Scanf("%d", &num[i])
			typenum[num[i]][0] = 0
			typenum[num[i]][1] = 0
		}
		for i := 0; i < n; i++ {
			typenum[num[i]][i&1]++
		}
		sort.Sort(IntArray(num[:n]))
		r := true
		for i := 0; i < n; i++ {
			if typenum[num[i]][i&1] > 0 {
				typenum[num[i]][i&1]--
			} else {
				r = false
			}
		}
		if r {
			Printf("YES\n")
		} else {
			Printf("NO\n")
		}
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF722C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var fa []int
	initFa := func(n int) {
		fa = make([]int, n)
		for i := range fa {
			fa[i] = i
		}
	}
	var find func(int) int
	find = func(x int) int {
		if fa[x] != x {
			fa[x] = find(fa[x])
		}
		return fa[x]
	}

	var n int
	Fscan(in, &n)
	arr := make([]int, n)
	for i := range arr {
		Fscan(in, &arr[i])
	}
	pos := make([]int, n)
	for i := range pos {
		Fscan(in, &pos[i])
	}

	ans := make([]int64, n)
	vis := make([]bool, n+2)
	sum := make([]int64, n+1)
	initFa(n + 1)
	max := int64(0)
	for i := n - 1; i >= 0; i-- {
		ans[i] = max
		p := pos[i]
		vis[p] = true
		sum[p] += int64(arr[p-1])
		if vis[p-1] {
			f := find(p - 1)
			sum[p] += sum[f]
			fa[f] = p
		}
		if vis[p+1] {
			f := find(p + 1)
			sum[p] += sum[f]
			fa[f] = p
		}
		if sum[p] > max {
			max = sum[p]
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

package main

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

type Int int64

func Max(a, b Int) Int {
	if a < b {
		return b
	}
	return a
}

func find(j Int) Int {
	if parent[j] == j {
		return j
	}
	return find(parent[j])
}

func union(p, q Int) {
	parentP := find(p)
	parentQ := find(q)
	if parentP != parentQ {
		if sum[parentQ] > sum[parentP] {
			parent[parentP] = parentQ
			sum[parentQ] += sum[parentP]
		} else {
			parent[parentQ] = parentP
			sum[parentP] += sum[parentQ]
		}
	}
}

var a, b, sum, parent, out []Int
var active []bool

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n Int
	fmt.Fscanf(r, "%v\n", &n)
	a, b, sum, parent, out, active = make([]Int, n), make([]Int, n), make([]Int, n), make([]Int, n), make([]Int, n), make([]bool, n+2)
	for i := Int(0); i < n; i++ {
		if i == n-1 {
			fmt.Fscanf(r, "%v\n", &a[i])
		} else {
			fmt.Fscanf(r, "%v ", &a[i])
		}
		parent[i] = i
	}
	copy(sum, a)
	max := Int(0)
	for i := Int(0); i < n; i++ {
		fmt.Fscanf(r, "%v ", &b[i])
		b[i]--
	}
	for i := n - 1; i >= 0; i-- {
		active[b[i]] = true
		if active[b[i]+1] {
			union(b[i], b[i]+1)
		}
		if b[i]-1 >= 0 && active[b[i]-1] {
			union(b[i]-1, b[i])
		}
		out[i] = max
		max = Max(max, sum[find(b[i])])
	}
	for _, o := range out {
		fmt.Fprintf(w, "%v\n", o)
	}
}

package main

import "fmt"
import "bufio"
import "os"

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n int
	var a, pos []int
	var res []int64

	fmt.Fscanf(bufin, "%d\n", &n)

	a = make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscanf(bufin, "%d\n", &a[i])
	}

	pos = make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscanf(bufin, "%d\n", &pos[i])
	}

	left := make([]int, n+2)
	right := make([]int, n+2)
	sum := make([]int64, n+2)

	for i := 0; i <= n+1; i++ {
		left[i] = -1
		right[i] = -1
		sum[i] = 0
	}

	res = make([]int64, n+1)
	max := int64(0)

	for i := n; i >= 1; i-- {
		res[i] = max

		p := pos[i]
		left[p] = p
		right[p] = p
		sum[p] = int64(a[p])

		l := left[p-1]
		if l != -1 {
			left[p] = l
			sum[p] += sum[p-1]
		}

		r := right[p+1]
		if r != -1 {
			right[p] = r
			sum[p] += sum[p+1]
		}

		if l != -1 {
			right[l] = right[p]
			sum[l] = sum[p]
		}

		if r != -1 {
			left[r] = left[p]
			sum[r] = sum[p]
		}

		if max < sum[p] {
			max = sum[p]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Fprintf(bufout, "%d\n", res[i])
	}
}

package main

import "fmt"
import "bufio"
import "os"

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n int
	var a, pos []int
	var res []int64

	fmt.Fscan(bufin, &n)

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

	pos = make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(bufin, &pos[i])
	}

	left := make([]int, n+2)
	right := make([]int, n+2)
	sum := make([]int64, n+2)

	for i := 0; i <= n+1; i++ {
		left[i] = -1
		right[i] = -1
		sum[i] = 0
	}

	res = make([]int64, n+1)
	max := int64(0)

	for i := n; i >= 1; i-- {
		res[i] = max

		p := pos[i]
		left[p] = p
		right[p] = p
		sum[p] = int64(a[p])

		l := left[p-1]
		if l != -1 {
			left[p] = l
			sum[p] += sum[p-1]
		}

		r := right[p+1]
		if r != -1 {
			right[p] = r
			sum[p] += sum[p+1]
		}

		if l != -1 {
			right[l] = right[p]
			sum[l] = sum[p]
		}

		if r != -1 {
			left[r] = left[p]
			sum[r] = sum[p]
		}

		if max < sum[p] {
			max = sum[p]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Fprintln(bufout, res[i])
	}
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/722/C

package main

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

func findRoot(i int64, roots []int64) int64 {
	if i != roots[i] {
		roots[i] = findRoot(roots[i], roots)
	}
	return roots[i]
}

func Solve(n int64, a, b []int64) []int64 {
	roots := make([]int64, n+1)
	for i := int64(1); i <= n; i++ {
		roots[i] = i
	}
	sums := make([]int64, n+1)
	visited := make([]bool, n+2)
	ans := make([]int64, n)
	max := int64(0)
	for i := n - 1; i >= 0; i-- {
		ans[i] = max
		bi := b[i]
		visited[bi] = true
		sums[bi] += a[bi-1]
		if visited[bi-1] {
			root := findRoot(bi-1, roots)
			roots[root] = bi
			sums[bi] += sums[root]
		}
		if visited[bi+1] {
			root := findRoot(bi+1, roots)
			roots[root] = bi
			sums[bi] += sums[root]
		}
		if sums[b[i]] > max {
			max = sums[b[i]]
		}
	}
	return ans
}

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

	var n int64
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fscanf(reader, "\n")
	b := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(reader, "%d", &b[i])
	}
	fmt.Fscanf(reader, "\n")

	ans := Solve(n, a, b)
	for _, elem := range ans {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		a[i] = t
	}
	fmt.Fscanf(in, "\n")
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		b[i] = t
	}
	for i := 0; i < n; i++ {
		if a[i] == 1 || b[i] == 1 {
			fmt.Fprintf(out, "-1\n")
			return
		}
	}
	q1 := n - 1
	q2 := 0
	for i := 0; i < 2*n; i++ {
		var sp float64
		if i%2 == 0 {
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &b[i])
	}
	for i := 0; i < n; i++ {
		if a[i] == 1 || b[i] == 1 {
			fmt.Fprintf(out, "-1\n")
			return
		}
	}
	q1 := n - 1
	q2 := 0
	for i := 0; i < 2*n; i++ {
		var sp float64
		if i%2 == 0 {
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		a[i] = t
	}
	fmt.Fscanf(in, "\n")

	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		b[i] = t
	}
	q1 := n - 1
	q2 := 0
	noAnswer := false
	for i := 0; i < 2*n; i++ {
		sp := 0.0
		if i%2 == 0 {
			if b[q2] == 1 {
				noAnswer = true
				break
			}
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			if a[q1] == 1 {
				noAnswer = true
				break
			}
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	if noAnswer {
		fmt.Fprintf(out, "-1\n")
	} else {
		fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	}
	return
}

package main

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

func valiate(tar float64, a int, b []int) bool {
	for i := 0; i < len(b); i++ {
		cost := (tar + float64(a)) / float64(b[i])
		tar -= cost
		if tar < 0 {
			return false
		}
	}
	return true
}

func solve(a int, b []int) float64 {
	l, r, best, count := 0.0, 2e9, -1.0, 2000
	for l <= r && count > 0 {
		mid := (l + r) / 2
		count = count - 1
		// Works, means there is enough fuel
		if valiate(mid, a, b) {
			r, best = mid, mid
		} else {
			l = mid
		}
	}
	return best
}

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, a := scanNum(), scanNum()
	b := make([]int, n*2)
	for i := 0; i < n; i++ {
		b[i*2] = scanNum()
	}
	b[n*2-1] = scanNum()
	for i := 0; i < n-1; i++ {
		b[i*2+1] = scanNum()
	}

	res := solve(a, b)
	if res < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(res)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		a[i] = t
	}
	fmt.Fscanf(in, "\n")

	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		b[i] = t
	}
	//fmt.Println(a)
	//fmt.Println(b)
	q1 := n - 1
	q2 := 0
	noAnswer := false
	for i := 0; i < 2*n; i++ {
		sp := 0.0
		if i%2 == 0 {
			if b[q2] == 1 {
				noAnswer = true
				break
			}
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			if a[q1] == 1 {
				noAnswer = true
				break
			}
			sp = float64(a[q1])
			q1--
		}
		//fmt.Println(sp)
		weight = weight + weight/(sp-1.0)
	}
	if noAnswer {
		fmt.Fprintf(out, "-1\n")
	} else {
		fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	weight := float64(0)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &b[i])
	}
	for i := 0; i < n; i++ {
		if a[i] == 1 || b[i] == 1 {
			fmt.Fprintf(out, "-1\n")
			return
		}
	}
	q1 := n - 1
	q2 := 0
	for i := 0; i < 2*n; i++ {
		var sp float64
		if i%2 == 0 {
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	fmt.Fprintf(out, "%.9f\n", weight)
	return
}

package main

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

func valiate(tar float64, a int, b []int) bool {
	for i := 0; i < len(b); i++ {
		cost := (tar + float64(a)) / float64(b[i])
		tar -= cost
		if tar < 0 {
			return false
		}
	}
	return true
}

func solve(a int, b []int) float64 {
	l, r, best, count := 0.0, 1e9, -1.0, 1000
	for l <= r && count > 0 {
		mid := (l + r) / 2
		count = count - 1
		// Works, means there is enough fuel
		if valiate(mid, a, b) {
			r, best = mid, mid
		} else {
			l = mid
		}
	}
	return best
}

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, a := scanNum(), scanNum()
	b := make([]int, n*2)
	for i := 0; i < n; i++ {
		b[i*2] = scanNum()
	}
	b[n*2-1] = scanNum()
	for i := 0; i < n-1; i++ {
		b[i*2+1] = scanNum()
	}

	res := solve(a, b)
	if res < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(res)
	}
}


// 16A-mic_rizal
package main

import (
    "fmt"
)

func main() {
    var n, m int
    fmt.Scan(&n, &m)
    s := make([]string, n)

    for i := 0; i < n; i++ {
        fmt.Scan(&s[i])
    }

    for i := 0; i < n; i++ {
        for j := 0; j < m-1; j++ {
            if s[i][j] != s[i][j+1] {
                fmt.Println("NO")
                return
            }
        }
    }

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

    fmt.Println("YES")
}

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, m int
	var prev byte
	prev = 'a'
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	for i := 0;i < n;i ++ {
		var s string
		fmt.Fscanf(reader, "%s\n", &s)
		b := []byte(s)
		if b[0] == prev {
			fmt.Printf("NO")
			return
		}
		prev = b[0]
		for j := 0;j < len(b);j ++ {
			if b[j] != b[0] {
				fmt.Printf("NO")
				return
			}
		}
	}
	fmt.Printf("YES")
	return
}

package main

import "os"
import "bufio"
import "strconv"
import "strings"

func main(){
	var n, m int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	last := ""
	iso := false
	var s, s1 string
	for i:=0; i<n; i++ {
		r.Scan()
		s = r.Text()
		s1 = strings.Repeat(string(s[0]), m)
		if s == s1 && string(s[0]) != string(last) {
			iso = true
		} else {
			iso = false
			break
		}
		last = string(s[0])
	}
	if iso == true {
		w.WriteString("YES\n")
	} else {
		w.WriteString("NO\n")
	}
	w.Flush()
}

package main

import "fmt"

func main() {
    var n,m int
    var s,prev string
    fmt.Scan(&n,&m)
    ans := true
    for i := 0; i < n; i++ {
        fmt.Scan(&s)
        for _, v := range s {
            if v != rune(s[0]) { ans = false; break; }
        }
        if (i != 0) && (s[0] == prev[0]) { ans = false }
        prev = s
    }
    if (ans) { fmt.Println("YES") } else { fmt.Println("NO") }
}

package main

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

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, m int
	fmt.Fscan(r, &n, &m)
	a := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}
	flag := true
	for _, e := range a {
		for _, c := range e {
			if rune(e[0]) != c {
				flag = false
				break
			}
		}
	}
	for i := 1; i < n ; i++ {
		if a[i-1] == a[i] {
			flag = false
			break
		}
	}
	if flag {
		fmt.Fprintln(w, "YES")
	} else {
		fmt.Fprintln(w, "NO")
	}
}