Consider the array $$$a$$$ composed of all the integers in the range $$$[l, r]$$$. For example, if $$$l = 3$$$ and $$$r = 7$$$, then $$$a = [3, 4, 5, 6, 7]$$$.Given $$$l$$$, $$$r$$$, and $$$k$$$, is it possible for $$$\gcd(a)$$$ to be greater than $$$1$$$ after doing the following operation at most $$$k$$$ times?   Choose $$$2$$$ numbers from $$$a$$$.  Permanently remove one occurrence of each of them from the array.  Insert their product back into $$$a$$$. $$$\gcd(b)$$$ denotes the greatest common divisor (GCD) of the integers in $$$b$$$.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. The description of test cases follows. The input for each test case consists of a single line containing $$$3$$$ non-negative integers $$$l$$$, $$$r$$$, and $$$k$$$ ($$$1 \leq l \leq r \leq 10^9, \enspace 0 \leq k \leq r - l$$$).

For each test case, print "YES" if it is possible to have the GCD of the corresponding array greater than $$$1$$$ by performing at most $$$k$$$ operations, and "NO" otherwise (case insensitive).

NoteFor the first test case, $$$a = [1]$$$, so the answer is "NO", since the only element in the array is $$$1$$$.For the second test case the array is $$$a = [3, 4, 5]$$$ and we have $$$1$$$ operation. After the first operation the array can change to: $$$[3, 20]$$$, $$$[4, 15]$$$ or $$$[5, 12]$$$ all of which having their greatest common divisor equal to $$$1$$$ so the answer is "NO".For the third test case, $$$a = [13]$$$, so the answer is "YES", since the only element in the array is $$$13$$$.For the fourth test case, $$$a = [4]$$$, so the answer is "YES", since the only element in the array is $$$4$$$.

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	t := readInt(input)

	for ; t > 0; t-- {
		nums := readArrInt(input)
		x := nums[0]
		y := nums[1]
		k := nums[2]

		if x == y && x > 1 {
			fmt.Println("YES")
		} else {
			if (y - x + 1 + x%2)/2 > k {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

package main

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

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

func main() {
	var test int

	fmt.Scan(&test)

	for test != 0 {
		var l,r,k int
		fmt.Fscan(in,&l,&r,&k)
		var odd_num int= (r-l+1)/2
		if l%2 > 0 && r%2 > 0{
			odd_num ++
		}
		if (l==r){
			if (r==1){
				fmt.Println("NO")
			}else{
				fmt.Println("YES")
			}
		}else if odd_num > k || (l==r && r==1){
			fmt.Println("NO")
		}else{
			fmt.Println("YES")
		}
		test --
	}
}

package main

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

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

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

	for t := 0; t < T; t++ {
		var l, r, k int64
		fmt.Fscan(in, &l, &r, &k)

		if r-l == 0 {
			if l > 1 {
				fmt.Fprintln(out, "YES")
			} else {
				fmt.Fprintln(out, "NO")
			}
		} else {
			var o, e int64
			if l%2 == 0 && r%2 == 0 {
				o = (r - l) / 2
				e = o + 1
			} else if l%2 == 1 && r%2 == 1 {
				e = (r - l) / 2
				o = e + 1
			} else {
				e = ((r - l) / 2) + 1
				o = e
			}

			if o-k > 0 {
				fmt.Fprintln(out, "NO")
			} else {
				fmt.Fprintln(out, "YES")
			}
		}
	}
}

package main

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

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

func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }

func main() {
	defer out.Flush()
	var t int;
	scan(&t);
	for i := 0; i < t; i++ {
		var l, r, k int;
		scan(&l, &r, &k);
		x := r - l + 1;
		if x == 1 {
			if l > 1 {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
			continue;
		}
		var e int;
		if x % 2 == 0 {
			if l % 2 == 0 {
				e = x / 2;
			} else {
				e = (x + 1) / 2;
			}
		} else {
			if l % 2 == 0 {
				e = (x + 1) / 2;
			} else {
				e = x / 2;
			}
		}
		if x - e > k {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

package main

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

var (
	in = bufio.NewReader(os.Stdin);
	t, l, r, k int
)

func main() {
	fmt.Fscan(in, &t);
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &l, &r, &k);
		x := r - l + 1;
		if x == 1 {
			if l > 1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			continue;
		}
		var e int;
		if x % 2 == 0 {
			if l % 2 == 0 {
				e = x / 2;
			} else {
				e = (x + 1) / 2;
			}
		} else {
			if l % 2 == 0 {
				e = (x + 1) / 2;
			} else {
				e = x / 2;
			}
		}
		if x - e > k {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

// generated by 1e9y at 22-01-2022
// template version: 2022-01-11

package main

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

func gcd(x, y uint64) uint64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

// 0000.A
func solve(l, r, k uint64) bool {
	if l == r {
		return l != 1
	}

	evens := r - l
	if l%2 == 0 {
		evens++
	}

	pairs := (r - l + 1) / 2
	// if (r-l+1)%2 == 1 {
	pairs++
	// }

	if l%2 == 0 || r%2 == 0 {
		return pairs-1 <= k
	} else {
		return pairs <= k
	}
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		slice := ReadUint64Slice(in)
		l, r, k := slice[0], slice[1], slice[2]
		Output(solve(l, r, k))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b,c int
		fmt.Fscan(in,&a,&b,&c)
		if c == 0 && a==b && a>1 {
			fmt.Fprintln(out,"YES")
			continue
		}
		if number_of_odds_inclusive(a,b) <= c {
			fmt.Fprintln(out,"YES")
		} else{
			fmt.Fprintln(out,"NO")
		}
	}
}
func number_of_odds_inclusive(l,u int) int {
	if l%2 != 0 && u%2 != 0 {
		return ((u-l)/2-1)+2
	}
	if l%2 != 0 || u%2 != 0 {
		return ((u-l)/2)+1
	}
	return ((u-l)/2)
}

package main

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

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

func main() {
	defer out.Flush()
	var t, l, r, k int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &l, &r, &k)
		if l == r && l != 1 || k >= (r+1)/2-l/2 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1629B
Date: 8/03/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1629/B
Problem: CF1629B
**/
func (in *CF1629B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		l, r, k := in.NextInt(), in.NextInt(), in.NextInt()

		total := r - (l - 1)
		even := int(math.Ceil((float64(r) - (float64(l) - 1.)) / 2.))
		x := l%2 != 0
		y := r%2 != 0
		if x && y {
			even--
		}

		odd := total - even

		if (even > 0 && odd <= k) || (total == 1 && r != 1 && l != 1) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}

}

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

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

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		lrk := getIntln(reader)
		l, r, k := lrk[0], lrk[1], lrk[2]
		if l == r {
			if l == 1 {
				writer.WriteString("NO\n")
			} else {
				writer.WriteString("YES\n")
			}
		} else {
			if l%2 == 1 && r%2 == 1 {
				if k >= (r-l+2)/2 {
					writer.WriteString("YES\n")
				} else {
					writer.WriteString("NO\n")
				}
			} else {
				if k >= (r-l+1)/2 {
					writer.WriteString("YES\n")
				} else {
					writer.WriteString("NO\n")
				}
			}
		}
	}
	writer.Flush()
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []int {
	b := strings.Split(getString(in), " ")
	res := make([]int, len(b))
	for k, v := range b {
		res[k] = parseInt(v)
	}
	return res
}

package main

import (
	"fmt"
	"os"
	"bufio"
)
var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)
func scan(a ...interface{})    { fmt.Fscan(reader, a...) }

func test(){
	var l, r, k int
	scan(&l, &r, &k)
	if r==l{
		if r==1{
			fmt.Println("NO")
		}else{
			fmt.Println("YES")
		}
		return
	}
	need := (r - l) / 2
	if (l % 2)==1 || (r % 2)==1{
		need++
	}
	if need <= k{
		fmt.Println("YES")
	}else{
		fmt.Println("NO")
	}

}

func main() {
	var cases int
	cases = 0
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		test()
	}
}

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var l, r, k int
	scan(&l, &r, &k)
	if r-l+1 == 1 {
		if l == 1 {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
		return
	}
	var div2 = r/2 - (l-1)/2
	if (r-l+1)-div2 <= k {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

package main

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

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

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

func scan(a ...interface{})    { fmt.Fscan(reader, a...) }
func print(a ...interface{})   { fmt.Fprint(writer, a...) }
func println(a ...interface{}) { fmt.Fprintln(writer, a...) }

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

func main() {
	defer writer.Flush()
	var t, l, r, k int
	scan(&t)
	for i := 0; i < t; i++ {
		scan(&l, &r, &k)
		if r == l {
			if r == 1 {
				println("NO")
			} else {
				println("YES")
			}
		} else {
			c := r - l + 1
			oc := c / 2
			if (c&1) == 1 && (l&1) == 1 {
				oc++
			}
			if k >= oc {
				println("YES")
			} else {
				println("NO")
			}
		}
	}
}

package main

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

/*
4
1 5 3
1 5 2
10 15 2
10 14 2
---
YES [1 2 3 4 5] -> [2 60]
NO [2 4 15]
NO [10 11 12 13 14 15]
YES [10 11 12 13 14]

1
1 5 2

1
10 14 2

1
13 13 0
*/

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

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

	for ; t > 0; t-- {
		var l, r, k int
		scanf("%d %d %d\n", &l, &r, &k)

		if l == r && l != 1 && k == 0 {
			fmt.Fprintln(writer, "YES")
			continue
		}

		cnt := r - l + 1
		divBy2Cnt := cnt / 2
		if l%2 == 0 {
			divBy2Cnt = (cnt + 1) / 2
		}

		leftCnt := cnt - k
		if divBy2Cnt >= leftCnt {
			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"
)

var yes = "YES"
var no = "NO"

func solve(l int, r int, k int) string {
	if r-l == 0 {
		if l == 1 {
			return no
		}
		return yes
	}
	n := r - l + 1
	o := n / 2
	if n%2 == 1 && l%2 == 1 {
		o++
	}
	if k >= o {
		return yes
	}
	return no
}

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

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

	for t := 0; t < T; t++ {
		var l int
		var r int
		var k int
		fmt.Fscan(in, &l)
		fmt.Fscan(in, &r)
		fmt.Fscan(in, &k)
		fmt.Fprintln(out, solve(l, r, k))
	}
	out.Flush()
}

package main

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

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

func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }

func main() {
	defer out.Flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var l, r, k int
		scan(&l, &r, &k)

		if l == r && l == 1 {
			printf("NO\n")
			continue
		}
		if l == r {
			printf("YES\n")
			continue
		}
		var even = (r - l + 1) / 2
		if (r-l+1)%2 == 1 && l%2 == 0 {
			even++
		}
		var needed = (r - l + 1) - even
		// printf("%d %d %d: needed = %d, k = %d\n", l, r, k, needed, k)
		if needed <= k {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

package main

import "fmt"

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

	for ; t > 0; t-- {
		var x, y, k int
		fmt.Scanf("%d %d %d\n", &x, y, k)
		if x == y && x > 1 {
			fmt.Println("YES")
		} else {
			if (y - x + 1 + x%2)/2 > k {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	}
}

package main

import "fmt"

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

	for i := 0; i < tcc; i++ {
		var l, r, k int
		fmt.Scanf("%d %d %d", &l, &r, &k)

		if l == r {
			if l == 1 {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		} else {
			var temp int
			if l%2 == 0 && r%2 == 0 {
				temp = (r - l + 1)/2
			} else {
				temp = (r - l + 1)/2 + 1
			}

			if temp <= k {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

package main

import "fmt"

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

package main

import "fmt"

func main() {
	var test int

	fmt.Scan(&test)

	for test != 0 {
		var l,r,k int
		fmt.Scanf("%d %d %d",&l,&r,&k)
		fmt.Println(l,r,k)
		odd_num := (r-l+1)/2
		if l%2 > 0 && r%2 > 0{
			odd_num ++
		}
		if (l==r){
			if (r==1){
				fmt.Println("NO")
			}else{
				fmt.Println("khacci")
				fmt.Println("YES")
			}
		}else if odd_num > k || (l==r && r==1){
			fmt.Println("NO")
		}else{
			fmt.Println("YES")
		}
		test --
	}
}

package main

import "fmt"

func main() {
	var test int

	fmt.Scan(&test)

	for test != 0 {
		var l,r,k int
		fmt.Scanf("%d %d %d",&l,&r,&k)
		odd_num := (r-l+1)/2
		if l%2 > 0 && r%2 > 0{
			odd_num ++
		}
		if (l==r){
			if (r==1){
				fmt.Println("NO")
			}else{
				fmt.Println("khacci")
				fmt.Println("YES")
			}
		}else if odd_num > k || (l==r && r==1){
			fmt.Println("NO")
		}else{
			fmt.Println("YES")
		}
		test --
	}
}

package main

import "fmt"

func main() {
	var test int

	fmt.Scan(&test)

	for test != 0 {
		var l,r,k int
		fmt.Scanf("%d %d %d",&l,&r,&k)
		odd_num := (r-l+1)/2
		if l%2 > 0 && r%2 > 0{
			odd_num ++
		}
		if (l==r){
			if (r==1){
				fmt.Println("NO")
			}else{
				fmt.Println("YES")
			}
		}else if odd_num > k || (l==r && r==1){
			fmt.Println("NO")
		}else{
			fmt.Println("YES")
		}
		test --
	}
}

package main

import "fmt"

func main() {
	var test int

	fmt.Scan(&test)

	for test != 0 {
		var l,r,k int
		fmt.Scanf("%d%d%d",&l,&r,&k)
		odd_num := (r-l+1)/2
		if l%2 > 0 && r%2 > 0{
			odd_num ++
		}
		if (l==r){
			if (r==1){
				fmt.Println("NO")
			}else{
				fmt.Println("YES")
			}
		}else if odd_num > k || (l==r && r==1){
			fmt.Println("NO")
		}else{
			fmt.Println("YES")
		}
		test --
	}
}

package main

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

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

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

	for t := 0; t < T; t++ {
		var l, r, k int64
		fmt.Fscan(in, &l, &r, &k)

		if r-l == 0 {
			if l > 1 {
				fmt.Fprintln(out, "YES")
			} else {
				fmt.Fprintln(out, "NO")
			}
		} else {
			var o, e int64
			if l%2 == 0 && r%2 == 0 {
				o = (r - l) / 2
				e = o + 1
			} else if l%2 == 1 && r%2 == 1 {
				e = (r - l) / 2
				o = e + 1
			} else {
				e = (r - l) / 2
				o = e
			}

			if o-k > 0 {
				fmt.Fprintln(out, "NO")
			} else {
				fmt.Fprintln(out, "YES")
			}
		}
	}
}

package main

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

func countPrimes(l, r int64) int64 {
	// Return if less than 1
	// Get the sqrt of the limit
	sqrtLimit := int64(math.Sqrt(float64(r)))

	// Create array
	numbers := make([]bool, r)

	// Set 1 to prime
	numbers[0] = true
	numPrimes := int64(0)

	// Count the number of olds
	if r%2 == 0 {
		numPrimes = r / 2
	} else {
		numPrimes = (r + 1) / 2
	}

	// Loop through odd numbers
	for i := int64(3); i <= sqrtLimit; i += 2 {
		if !numbers[i] {
			for j := i * i; j < r; j += i * 2 {
				if !numbers[j] {
					numbers[j] = true
					numPrimes -= 1
				}
			}
		}
	}

	return numPrimes
}

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

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

	for t := 0; t < T; t++ {
		var l, r, k int64
		fmt.Fscan(in, &l, &r, &k)

		if r-l == 0 {
			if l > 1 {
				fmt.Fprintln(out, "YES")
			} else {
				fmt.Fprintln(out, "NO")
			}
		} else {
			c := countPrimes(l, r)
			if c-k > 0 {
				fmt.Fprintln(out, "NO")
			} else {
				fmt.Fprintln(out, "YES")
			}
		}
	}
}

package main

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

var (
	in = bufio.NewReader(os.Stdin);
	t, l, r, k int
)

func main() {
	fmt.Fscan(in, &t);
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &l, &r, &k);
		x := r - l + 1;
		if x == 1 {
			fmt.Println("YES")
			continue;
		}
		var e int;
		if x % 2 == 0 {
			if l % 2 == 0 {
				e = x / 2;
			} else {
				e = (x + 1) / 2;
			}
		} else {
			if l % 2 == 0 {
				e = (x + 1) / 2;
			} else {
				e = x / 2;
			}
		}
		if x - e > k {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

// generated by 1e9y at 22-01-2022
// template version: 2022-01-11

package main

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

func gcd(x, y uint64) uint64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

// 0000.A
func solve(l, r, k uint64) bool {
	if l == r {
		return l != 1
	}

	evens := r - l
	if l%2 == 0 {
		evens++
	}

	pairs := (r - l + 1) / 2
	// if (r-l+1)%2 == 1 {
	pairs++
	// }

	if l%2 == 0 {
		return pairs-1 <= k
	} else {
		return pairs <= k
	}
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		slice := ReadUint64Slice(in)
		l, r, k := slice[0], slice[1], slice[2]
		Output(solve(l, r, k))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

// generated by 1e9y at 22-01-2022
// template version: 2022-01-11

package main

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

func gcd(x, y uint64) uint64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

// 0000.A
func solve(l, r, k uint64) bool {
	if l == r {
		return l != 1
	}

	evens := r - l
	if l%2 == 0 {
		evens++
	}

	pairs := (r - l + 1) / 2
	if (r-l+1)%2 == 1 {
		pairs++
	}

	if l%2 == 0 {
		return pairs-1 <= k
	} else {
		return pairs <= k
	}
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		slice := ReadUint64Slice(in)
		l, r, k := slice[0], slice[1], slice[2]
		Output(solve(l, r, k))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}


Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it's body extends to (1, m), then goes down 2 rows to (3, m), then goes left to (3, 1) and so on.Your task is to draw this snake for Fox Ciel: the empty cells should be represented as dot characters ('.') and the snake cells should be filled with number signs ('#').Consider sample tests in order to understand the snake pattern.

The only line contains two integers: n and m (3 ≤ n, m ≤ 50).  n is an odd number.

package main

import "fmt"

func main() {
	var ny, nx int
	fmt.Scan(&ny, &nx)
	c0 := make([]byte, nx)
	c1 := make([]byte, nx)
	c3 := make([]byte, nx)
	for i := range c0 {
		c0[i] = '#'
		c1[i] = '.'
		c3[i] = '.'
	}
	c1[nx-1] = '#'
	c3[0] = '#'
	for y := 0; y < ny; y++ {
		switch y % 4 {
		case 1:
			fmt.Println(string(c1))
		case 3:
			fmt.Println(string(c3))
		default:
			fmt.Println(string(c0))
		}
	}
}

package main
import "fmt"

func main() {
	var (
		n, m int
		index int
	)
	fmt.Scanln(&n, &m)
	for i := 1; i <= n; i ++ {
		if i%2 == 1 {
			printOddLine(m, i == n)
		}else {
			printEven(index, m)
			index ++
		}
	}
}

func printOddLine(m int, flg bool){
	for i := 0; i < m; i ++ {
		fmt.Print("#")
	}
	if !flg{
		fmt.Println()
	}
}

func printEven(index, m int){
	if index%2 == 1 {
		fmt.Print("#")
	}
	for i := 1; i < m; i ++ {
		fmt.Print(".")
	}
	if index%2 == 0 {
		fmt.Print("#")
	}
	fmt.Println()
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	left := false

	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			println(strings.Repeat("#", m))
		} else {
			if left {
				printf("#%s\n", strings.Repeat(".", m-1))
				left = false
			} else {
				printf("%s#\n", strings.Repeat(".", m-1))
				left = true
			}
		}
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

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

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

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

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

package main

import(
    "fmt"
)

func main(){
    var(
        n,m,f   int
        s       [][]byte
    )
    fmt.Scan(&n,&m)
    s = make([][]byte,n)
    for i:=0;i<n;i++{
        s[i]=make([]byte,m)
    }
    f=0
    for i:=0;i<n;i++{
        if i%2==0{
            for j:=0;j<m;j++{
                fmt.Print("#")
            }
        }else{
            if f==0{
                for j:=0;j<m-1;j++{
                    fmt.Print(".")
                }
                fmt.Print("#")
                f=1
            }else{
                fmt.Print("#")
                for j:=1;j<m;j++{
                    fmt.Print(".")
                }
                f=0
            }
        }
        fmt.Println()
    }
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n, m := getI(), getI()
  for i := 0; i < n; i++ {
    row := make([]byte, m)
    if i%2 == 0 {
      for j := 0; j < m; j++ {
        row[j] = '#'
      }
    } else {
      for j := 0; j < m; j++ {
        row[j] = '.'
      }
      if i%4 == 1 {
        row[m-1] = '#'
      } else {
        row[0] = '#'
      }
    }
    writer.WriteString(fmt.Sprintf("%s\n", string(row)))
  }
}

package main

import "fmt"

func main(){
	var n,m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	for i := 1; i <=n; i++ {
		for j := 1; j <=m; j++ {
			if i%2!=0 {
				fmt.Print("#")
			}
            if i%2==0 {
				if i%4==0 {
					if j==1 {
						fmt.Print("#")
					}else{
						fmt.Print(".")
					}
				}else{
					if j==m {
						fmt.Print("#")
					}else{
						fmt.Print(".")
					}
				}
			}

		}
		fmt.Println()
	}
}

package main

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

func GetScanner() func(a ...*int) {
    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())
        }
    }
    return ScanInts
}

func main() {
    var n, m int
    ScanInts := GetScanner()
    ScanInts(&n, &m)
    for i := 0; i < n; i++ {
        if i%2 == 0 {
            for j := 0; j < m; j++ {
                fmt.Print("#")
            }
            fmt.Println()
        } else {
            if i%4 == 1 {
                for j := 0; j < m-1; j++ {
                    fmt.Print(".")
                }
                fmt.Println("#")
            } else {
                fmt.Print("#")
                for j := 1; j < m; j++ {
                    fmt.Print(".")
                }
                fmt.Println()
            }
        }
    }
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	sharp := "##"
	point := ""
	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < m-2; i++ {
		sharp += "#"
		point += "."
	}
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			fmt.Println(sharp)
		}
		if i%4 == 1 {
			fmt.Println("." + point + "#")
		}
		if i%4 == 3 {
			fmt.Println("#" + point + ".")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if i%2 == 0 || (j == 0 && (i+1)%4 == 0) || (j == m-1 && (i+1)%4 == 2) {
				fmt.Print(string('#'))
			} else {
				fmt.Print(string('.'))
			}
		}
		fmt.Println()
	}
}

package main

import (
    "fmt"
)

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

    for i := 0; i < n; i++ {
        if i & 1 == 0 {
            for j := 0; j < m; j++ {
                fmt.Printf("#")
            }
            fmt.Println()
        } else {
            for j := 0; j < m; j++ {
                if i % 4 == 1 && j == m - 1 {
                    fmt.Printf("#")
                } else if i % 4 == 3 && j == 0 {
                    fmt.Printf("#")
                } else {
                    fmt.Printf(".")
                }
            }
            fmt.Println()
        }
    }
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
	line := readLine(reader)
	var n, m int = 0, 0
	fmt.Sscanf(line, "%d %d", &n, &m)
	swap := true
	for i := 0; i < n; i++ {
		line := ""
		for j := 0; j < m; j++ {
			if i%2 != 0 {
				line += "."
			} else {
				line += "#"
			}
		}
		if i%2 != 0 {
			if swap {
				line = line[:m-1] + "#"
			} else {
				line = "#" + line[1:]
			}
			swap = !swap
		}
		fmt.Println(line)
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

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

package main

import (
	"fmt"
)

func more(str string, count int)(res string){
	for i:= 0; i < count; i++{
		res += str;
	}
	return
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	for i:=0; i < n; i++{
		if i%2 == 0 {
			fmt.Println(more("#",m))
		} else {
			if (i/2)%2 == 0 {
				fmt.Println(more(".",m-1)+"#")
			} else {
				fmt.Println("#"+more(".",m-1))
			}
		}
	}
}

package main

import "fmt"

func main() {
	c,r := 0 , 0
	fmt.Scan(&r , &c)
	k := true
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			if i % 2 == 0 {
				fmt.Print("#")
			} else if k == true {
				if j == c - 1 {
					fmt.Print("#")
					k = false
				} else {
					fmt.Print(".")
				}
			} else {
				if j == 0 {
					fmt.Print("#")
				}else if j == c - 1 {
					fmt.Print(".")
					k = true
				} else {
					fmt.Print(".")
				}
			}
		}
		fmt.Println("")
	}
}

package main

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

const NewLine = '\r'

func readLine() string {
	reader := bufio.NewReader(os.Stdin)
	str, err := reader.ReadString(NewLine)
	if err != nil {
		fmt.Print(err)
		panic(err)
	}
	return strings.Replace(str, string(NewLine), "", -1)
}

func toInt(str string) int {
	i, err := strconv.Atoi(str)
	if err != nil {
		fmt.Print(err)
		panic(err)
	}
	return i
}

func readSnakeTable() (int, int) {
	line := readLine()
	arr := strings.Split(line, " ")

	return toInt(arr[0]), toInt(arr[1])
}

func snakeCells(n int) string {
	return strings.Repeat("#", n)
}

func snakeCell(n int, pos int) string {
	empty := strings.Repeat(".", n - 1)
	if  pos == 0 {
		return "#" + empty
	} else {
		return empty + "#"
	}
}

func main() {
	n, m := readSnakeTable()
	var state = 0
	for i := 0; i < n; i++ {
		switch state {
		case 0:
			fmt.Println(snakeCells(m))
		case 1:
			fmt.Println(snakeCell(m, 1))
		case 2:
			fmt.Println(snakeCells(m))
		case 3:
			fmt.Println(snakeCell(m, 0))
		}
		state = (state + 1) % 4
	}
}

package main

import (
	"fmt"
)

func main() {
	var rows, cols int
	fmt.Scanf("%d %d", &rows, &cols)

	grid := make([][]int, rows)

	var rlPadFlag bool

	for i := range(grid) {
		grid[i] = make([]int, cols)

		if i%2 == 1 {
			if !rlPadFlag {
				for j := 0; j < cols -1; j++ {
					grid[i][j] = 1
				}

				rlPadFlag = !rlPadFlag
			} else {
				for j := 1; j < cols; j++ {
					grid[i][j] = 1
				}

				rlPadFlag = !rlPadFlag
			}
		}
	}

	for _, row := range(grid) {
		for _, col := range(row) {
			switch col {
			case 1:
				fmt.Print(".")
				break
			default:
				fmt.Print("#")
			}
		}

		fmt.Println()
	}
}

package main

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

func main() {
	var n, m int

	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n, &m)

	p :=""
	sh := "##"
	for i:=0; i<m-2; i++{
		sh +="#"
		p +="."
	}
	for i:=0; i<n; i++{
		switch true {
		case i % 2 == 0:
			fmt.Fprintln(ocr, sh)
			ocr.Flush()
		case i % 4 == 1:
			fmt.Fprintln(ocr, "." + p +  "#")
			ocr.Flush()
		case i % 4 == 3:
			fmt.Fprintln(ocr, "#" + p +  ".")
			ocr.Flush()
		}
	}

}

package main

import (
	"fmt"
	"strings"
)

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

	hashFullStr := strings.Repeat("#", m)
	hashLeftStr := "#" + strings.Repeat(".", m-1)
	hashRightStr := strings.Repeat(".", m-1) + "#"

	states := []string{hashFullStr, hashRightStr, hashFullStr, hashLeftStr}
	for i := 0; i < n; i++ {
		fmt.Println(states[i%4])
	}
}

package main

import "fmt"

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

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if i%2 != 0 {
				fmt.Print("#")
			} else if j == 1 && i/2%2 == 0 {
				fmt.Print("#")
			} else if j == m && i/2%2 != 0 {
				fmt.Print("#")
			} else {
				fmt.Print(".")
			}
		}
		fmt.Println("")
	}
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n, m int

func main() {
	fmt.Fscan(reader, &n, &m)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			for j := 0; j < m; j++ {
				fmt.Print("#")
			}
			fmt.Println()
		} else if i/2%2 == 0 {
			for j := 0; j < m-1; j++ {
				fmt.Print(".")
			}
			fmt.Print("#")
			fmt.Println()
		} else {
			fmt.Print("#")
			for j := 0; j < m-1; j++ {
				fmt.Print(".")
			}
			fmt.Println()
		}
	}
}

package main

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

func main() {
	var n, m, en uint8
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	for i:=uint8(1); i <= n; i++{
		if i % 2 == 0{
			en++
			ee(en, m)
		}else{
			full(m)
		}
	}
}
func full(m uint8){
	for i:=uint8(0); i < m; i++{
		fmt.Print("#")
	}
	fmt.Println()
}
func ee(n uint8, m uint8){
	if(n % 2 != 0){
		for i:=uint8(0); i < m-1; i++{
			fmt.Print(".")
		}
		fmt.Print("#\n")
	}else{
		fmt.Print("#")
		for i:=uint8(0); i < m-1; i++{
			fmt.Print(".")
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
	"strings"
)

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

	for i := 1; i <= n; i++ {
		if i%4 == 0 {
			fmt.Println("#" + strings.Repeat(".", m-1))
		} else if i%2 == 0 {
			fmt.Println(strings.Repeat(".", m-1) + "#")
		} else {
			fmt.Println(strings.Repeat("#", m))
		}
	}
}

package main

import (
        "fmt"
)

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        for i := 0; i < n; i++ {
                for j := 0; j < m; j++ {
                        if (j == 0 && i%2 == 1 && i%4 != 1) || (j == m - 1 && i%4 == 1) {
                                fmt.Printf("#")
                        } else {
                                if i%2 == 0 {
                                        fmt.Printf("#")
                                } else {
                                        fmt.Printf(".")
                                }
                        }
                }
                fmt.Printf("\n")
        }
}

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() {

	var a, b int
	scanf("%d %d \n", &a, &b)
	toggle := false // default from last
	for i:=1; i<=a; i++ {
		once := false
		for j:=1; j<=b; j++ {
			if i % 2 == 0  {
				if toggle == true && j == 1 && !once {
					fmt.Printf("%s", "#")
					toggle = false
					once = true
				}else if toggle == false && j == b  && !once{
					fmt.Printf("%s", "#")
					toggle = true
					once = true
				}else {
					fmt.Printf("%s", ".")
				}
			}else {
				fmt.Printf("%s", "#")
			}
		}
		fmt.Println()
	}

}

package main

import "fmt"

func main() {
	var n, m int
	var flag bool
	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			for j := 0; j < m; j++ {
				fmt.Printf("#")
			}
			fmt.Printf("\n")
		} else {
			if flag {
				fmt.Printf("#")
				for j := 1; j < m; j++ {
					fmt.Printf(".")
				}
				fmt.Printf("\n")
				flag = false
			} else {
				for j := 1; j < m; j++ {
					fmt.Printf(".")
				}
				fmt.Printf("#\n")
				flag = true
			}
		}
	}
}

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 nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    m := nextInt()
    a := "#"
    b := ""
    for i := 0; i < m - 1; i++ {
        a += "#"
        b += "."
    }
    l := "#" + b
    r := b + "#"
    fmt.Fprintln(out, a);
    t := 0
    for i := 0; i < n / 2; i++ {
        if t == 0 {
            fmt.Fprintln(out, r)
        } else {
            fmt.Fprintln(out, l)
        }
        fmt.Fprintln(out, a)
        t = 1 - t
    }
}

package main

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

// https://codeforces.com/problemset/problem/510/A
// A. Fox And Snake
// time limit per test
// 2 seconds
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.

// A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it's body extends to (1, m), then goes down 2 rows to (3, m), then goes left to (3, 1) and so on.

// Your task is to draw this snake for Fox Ciel: the empty cells should be represented as dot characters ('.') and the snake cells should be filled with number signs ('#').

// Consider sample tests in order to understand the snake pattern.
// Input

// The only line contains two integers: n and m (3 ≤ n, m ≤ 50).

// n is an odd number.
// Output

// Output n lines. Each line should contain a string consisting of m characters. Do not output spaces.

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

	bufStdout := bufio.NewWriter(os.Stdout)
	defer bufStdout.Flush()

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			for i := 0; i < m; i++ {
				_, _ = bufStdout.WriteRune('#')
			}

		} else {
			if i%4 == 1 {
				for i := 0; i < m-1; i++ {
					_, _ = bufStdout.WriteRune('.')
				}
				_, _ = bufStdout.WriteRune('#')

			} else {
				_, _ = bufStdout.WriteRune('#')
				for i := 0; i < m-1; i++ {
					_, _ = bufStdout.WriteRune('.')
				}
			}

		}

		if i < n-1 {
			_, _ = bufStdout.WriteRune('\n')
		}
	}
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/510/A
// комментарии к решению
// Все используемые в выводе символы входят в ASCII таблицу
// и занимают 1 байт в кодировке UTF-8, поэтому можно выделить
// []byte необходимого размера и заполнить его, согласно
// предопределенной маске в задаче
func taskSolution(n int, m int) string {
	//if n < 3 || m < 3 {
	//	panic("invalid parameters")
	//}
	ans := make([]byte, 0, n*(m+1)+1)

	// init first line to prevent trimming \n at the end
	for j := 0; j < m; j += 1 {
		ans = append(ans, byte('#'))
	}

	for i := 1; i < n; i += 1 {
		ans = append(ans, byte('\n'))
		switch i % 4 {
		case 0, 2:
			for j := 0; j < m; j += 1 {
				ans = append(ans, byte('#'))
			}
		case 1:
			for j := 1; j < m; j += 1 {
				ans = append(ans, byte('.'))
			}
			ans = append(ans, byte('#'))
		case 3:
			ans = append(ans, byte('#'))
			for j := 1; j < m; j += 1 {
				ans = append(ans, byte('.'))
			}
		}
	}
	return string(ans)
}

func main() {
	var n, m int
	if _, err := fmt.Scan(&n, &m); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(n, m))
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/510/A
// комментарии к решению
// Все используемые в выводе символы входят в ASCII таблицу
// и занимают 1 байт в кодировке UTF-8, поэтому можно выделить
// []byte необходимого размера и заполнить его, согласно
// предопределенной маске в задаче
func taskSolution(n int, m int) string {
	if n < 3 || m < 3 {
		panic("")
	}
	ans := make([]byte, 0, n*(m+1))
	for i := 0; i < n; i += 1 {
		switch i % 4 {
		case 0, 2:
			for j := 0; j < m; j += 1 {
				ans = append(ans, byte('#'))
			}
		case 1:
			for j := 1; j < m; j += 1 {
				ans = append(ans, byte('.'))
			}
			ans = append(ans, byte('#'))
		case 3:
			ans = append(ans, byte('#'))
			for j := 1; j < m; j += 1 {
				ans = append(ans, byte('.'))
			}
		}
		ans = append(ans, byte('\n'))
	}
	return string(ans[:len(ans)-1])
}

func main() {
	var n, m int
	if _, err := fmt.Scan(&n, &m); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(n, m))
}

package main

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

var in *bufio.Scanner = bufio.NewScanner(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	a, b := make([]byte, m), make([]byte, m)
	for i := 0; i < m; i++ {
		a[i] = '#'
		b[i] = '.'
	}
	b[m - 1] = '#'
	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			fmt.Println(string(a))
		} else {
			fmt.Println(string(b))
			rev(b)
		}
	}

}

func rev(a []byte) {
	for i, j := 0, len(a) - 1; i <= j; {
		a[i], a[j] = a[j], a[i]
		i++
		j--
	}
}

func nextInt() int {
	in.Scan()
	res, _ := strconv.Atoi(in.Text())
	return res
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	for i := 0; i < n; i++ {
		b := make([]byte, m)
		for j := 0; j < m; j++ {
			if i%2 == 0 || (i%4 == 1 && j == m-1) || (i%4 == 3 && j == 0) {
				b[j] = '#'
			} else {
				b[j] = '.'
			}
		}
		fmt.Println(string(b))
	}
}

package main

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

func main() {
	var r, c int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &r, &c)
	s1 := strings.Repeat("#", c)
	s2 := strings.Repeat(".", c-1) + "#"
	s3 := "#" + strings.Repeat(".", c-1)
	toggle := true
	for i := 0; i < r; i++ {
		if i%2 == 0 {
			fmt.Println(s1)
		} else {
			if toggle {
				fmt.Println(s2)
			} else {
				fmt.Println(s3)
			}
			toggle = !toggle
		}
	}
}

package main

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

func GetScanner() func(a ...*int) {
    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())
        }
    }
    return ScanInts
}

func main() {
    var n, m int
    ScanInts := GetScanner()
    ScanInts(&n, &m)
    for i := 0; i < n; i++ {
        if i%2 == 0 {
            for j := 0; j < m; j++ {
                fmt.Print("*")
            }
            fmt.Println()
        } else {
            if i%4 == 1 {
                for j := 0; j < m-1; j++ {
                    fmt.Print(".")
                }
                fmt.Println("*")
            } else {
                fmt.Print("*")
                for j := 1; j < m; j++ {
                    fmt.Print(".")
                }
                fmt.Println()
            }
        }
    }
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	sharp := "##"
	point := ""
	fmt.Scanf("%d %d \n", &n, &m)
	for i := 0; i < m-2; i++ {
		sharp += "#"
		point += "."
	}
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			println(sharp)
		}
		if i%4 == 1 {
			println("." + point + "#")
		}
		if i%4 == 3 {
			println("#" + point + ".")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	sharp := "##"
	point := ""
	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < m-2; i++ {
		sharp += "#"
		point += "."
	}
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			println(sharp)
		}
		if i%4 == 1 {
			println("." + point + "#")
		}
		if i%4 == 3 {
			println("#" + point + ".")
		}
	}
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
	line := readLine(reader)
	var n, m int = 0, 0
	fmt.Sscanf(line, "%d %d", &n, &m)
	fmt.Println(n, m)
	swap := true
	for i := 0; i < n; i++ {
		line := ""
		for j := 0; j < m; j++ {
			if i%2 != 0 {
				line += "."
			} else {
				line += "#"
			}
		}
		if i%2 != 0 {
			if swap {
				line = line[:m-1] + "#"
			} else {
				line = "#" + line[1:]
			}
			swap = !swap
		}
		fmt.Println(line)
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

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

package main

import "fmt"

func main() {
	c,r := 0 , 0
	fmt.Scan(&r , &c)
	k := true
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			if i % 2 == 0 {
				fmt.Print("#")
			} else if k == true {
				if j == c - 1 {
					fmt.Print("#")
					k = false
				} else {
					fmt.Print(".")
				}
			} else {
				if j == 0 {
					fmt.Print("#")
				}else if j == c - 1 {
					k = true
				} else {
					fmt.Print(".")
				}
			}
		}
		fmt.Println("")
	}
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n, m int

func main() {
	fmt.Fscan(reader, &n, &m)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			for j := 0; j < m; j++ {
				fmt.Print("#")
			}
			fmt.Println()
		} else if i/2%2 == 0 {
			for j := 0; j < m-1; j++ {
				fmt.Print(".")
			}
			fmt.Print("#")
			fmt.Println()
		} else {
			fmt.Print("#")
			for j := 0; j < m-1; j++ {
				fmt.Print(".")
			}
			fmt.Println()
		}
	}
	fmt.Println(n)
}


There are $$$n$$$ distinct points on a coordinate line, the coordinate of $$$i$$$-th point equals to $$$x_i$$$. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to consider each pair of points, not only adjacent. Note that any subset containing one element satisfies the condition above. Among all these subsets, choose a subset with maximum possible size.In other words, you have to choose the maximum possible number of points $$$x_{i_1}, x_{i_2}, \dots, x_{i_m}$$$ such that for each pair $$$x_{i_j}$$$, $$$x_{i_k}$$$ it is true that $$$|x_{i_j} - x_{i_k}| = 2^d$$$ where $$$d$$$ is some non-negative integer number (not necessarily the same for each pair of points).

The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of points. The second line contains $$$n$$$ pairwise distinct integers $$$x_1, x_2, \dots, x_n$$$ ($$$-10^9 \le x_i \le 10^9$$$) — the coordinates of points.

In the first line print $$$m$$$ — the maximum possible number of points in a subset that satisfies the conditions described above. In the second line print $$$m$$$ integers — the coordinates of points in the subset you have chosen. If there are multiple answers, print any of them.

NoteIn the first example the answer is $$$[7, 3, 5]$$$. Note, that $$$|7-3|=4=2^2$$$, $$$|7-5|=2=2^1$$$ and $$$|3-5|=2=2^1$$$. You can't find a subset having more points satisfying the required property.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF988D(_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([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		a[i] += 1e9
	}
	sort.Ints(a)
	var ans []int
o:
	for i := 0; i < 31; i++ {
		d := 1 << i
		g := map[int][]int{}
		for _, x := range a {
			g[x%d] = append(g[x%d], x)
		}
		for _, xs := range g {
			for j := 0; j < len(xs); {
				b := []int{}
				for j0 := j; j < len(xs) && xs[j] == xs[j0]+(j-j0)*d; j++ {
					b = append(b, xs[j]-1e9)
					if len(b) == 3 {
						ans = b
						break o
					}
				}
				if len(b) > len(ans) {
					ans = b
				}
			}
		}
	}
	Fprintln(out, len(ans))
	for _, v := range ans {
		Fprint(out, v, " ")
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF988D(_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([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		a[i] += 1e9
	}
	sort.Ints(a)
	var ans []interface{}
o:
	for i := 0; i < 31; i++ {
		d := 1 << i
		g := map[int][]int{}
		for _, x := range a {
			g[x%d] = append(g[x%d], x)
		}
		for _, xs := range g {
			for j := 0; j < len(xs); {
				b := []interface{}{}
				for j0 := j; j < len(xs) && xs[j] == xs[j0]+(j-j0)*d; j++ {
					b = append(b, xs[j]-1e9)
					if len(b) == 3 {
						ans = b
						break o
					}
				}
				if len(b) > len(ans) {
					ans = b
				}
			}
		}
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

const (
	MaxN = 200005
	Pow = 31
)

var n int
var a []int64
var best []int64
var max int
var c map[int64]bool

func check(b []int64) {
	if max < len(b) {
		max = len(b)
		best = b
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	c = make(map[int64]bool)
	fmt.Fscanf(buf, "%d\n", &n)
	for i := 0; i < n; i++ {
		var tmp int64
		fmt.Fscanf(buf, "%d", &tmp)
		c[tmp] = true
	}
	for k := range c {
		a = append(a, k)
	}

	l := len(a)
	max = 1
	best = []int64{a[0]}
l:
	for i := 0; i < l; i++ {
		for j := 0; j < 31; j++ {
			for _, sign := range []int64{-1, 1} {
				t1 := a[i] + sign * 1<<uint64(j)
				if c[t1] {
					t2 := a[i] + sign * 1<<uint64(j+1)
					if c[t2] {
						check([]int64{a[i], t1, t2})
						break l
					} else {
						check([]int64{a[i], t1})
					}
				}
			}
		}
	}
	fmt.Println(max)
	for i := 0; i < max; i++ {
		fmt.Printf("%d ", best[i])
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF988D(_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([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		a[i] += 1e9
	}
	sort.Ints(a)
	var ans []interface{}
	for i := 0; i < 31; i++ {
		d := 1 << i
		g := map[int][]int{}
		for _, x := range a {
			g[x%d] = append(g[x%d], x)
		}
		for _, xs := range g {
			for j := 0; j < len(xs); {
				b := []interface{}{}
				for j0 := j; j < len(xs) && xs[j] == xs[j0]+(j-j0)*d; j++ {
					b = append(b, xs[j]-1e9)
				}
				if len(b) > len(ans) {
					ans = b
				}
			}
		}
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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


Filya just learned new geometry object — rectangle. He is given a field consisting of n × n unit cells. Rows are numbered from bottom to top with integer from 1 to n. Columns are numbered from left to right with integers from 1 to n. Cell, located at the intersection of the row r and column c is denoted as (r, c). Filya has painted two rectangles, such that their sides are parallel to coordinate axes and each cell lies fully inside or fully outside each of them. Moreover, no cell lies in both rectangles.Later, hedgehog Filya became interested in the location of his rectangles but was unable to find the sheet of paper they were painted on. They were taken by Sonya and now she wants to play a little game with Filya. He tells her a query rectangle and she replies with the number of initial rectangles that lie fully inside the given query rectangle. The query rectangle should match the same conditions as initial rectangles. Rectangle lies fully inside the query if each o its cells lies inside the query.Filya knows Sonya really well, so is sure that if he asks more than 200 questions she will stop to reply.

The first line of the input contains an integer n (2 ≤ n ≤ 216) — size of the field. For each query an integer between 0 and 2 is returned — the number of initial rectangles that lie fully inside the query rectangle.

To make a query you have to print "? x1 y1 x2 y2" (without quotes) (1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ n), where (x1, y1) stands for the position of the bottom left cell of the query and (x2, y2) stands for the up right cell of the query. You are allowed to ask no more than 200 queries. After each query you should perform "flush" operation and read the answer. In case you suppose you've already determined the location of two rectangles (or run out of queries) you should print "! x11 y11 x12 y12 x21 y21 x22 y22" (without quotes), where first four integers describe the bottom left and up right cells of the first rectangle, and following four describe the corresponding cells of the second rectangle. You can print the rectangles in an arbitrary order. After you have printed the answer, print the end of the line and perform "flush". Your program should terminate immediately after it print the answer.

package main

import (
	"fmt"
	"sort"
)

var cache = make(map[struct{ x1, y1, x2, y2 int }]int)

func query(x1, y1, x2, y2 int) int {
	if answer, ok := cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}]; ok {
		return answer
	}
	fmt.Println("?", x1+1, y1+1, x2+1, y2+1)
	var result int
	fmt.Scan(&result)
	cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}] = result
	return result
}

func findRect(x1, y1, x2, y2 int) (int, int, int, int) {
	w, h := x2-x1+1, y2-y1+1

	left := sort.Search(w, func(x int) bool {
		x += x1
		return query(x, y1, x2, y2) == 0
	}) + x1 - 1
	right := sort.Search(w, func(x int) bool {
		x += x1
		return query(x1, y1, x, y2) > 0
	}) + x1
	top := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y, x2, y2) == 0
	}) + y1 - 1
	bottom := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y1, x2, y) > 0
	}) + y1

	return left, top, right, bottom
}

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

	splitX := sort.Search(n, func(x int) bool {
		return query(0, 0, x, n-1) > 0
	})
	splitY := sort.Search(n, func(y int) bool {
		return query(0, 0, n-1, y) > 0
	})

	if query(0, 0, splitX, n-1) == 1 && query(splitX+1, 0, n-1, n-1) == 1 {
		ax1, ay1, ax2, ay2 := findRect(0, 0, splitX, n-1)
		bx1, by1, bx2, by2 := findRect(splitX+1, 0, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	} else {
		ax1, ay1, ax2, ay2 := findRect(0, 0, n-1, splitY)
		bx1, by1, bx2, by2 := findRect(0, splitY+1, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	}
}

package main

import (
	"fmt"
	"sort"
)

var cache = make(map[struct{ x1, y1, x2, y2 int }]int)

func query(x1, y1, x2, y2 int) int {
	if answer, ok := cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}]; ok {
		return answer
	}
	fmt.Println("?", x1+1, y1+1, x2+1, y2+1)
	var result int
	fmt.Scan(&result)
	cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}] = result
	return result
}

func findRect(x1, y1, x2, y2 int) (int, int, int, int) {
	w, h := x2-x1+1, y2-y1+1

	left := sort.Search(w, func(x int) bool {
		x += x1
		return query(x, y1, x2, y2) == 0
	}) + x1 - 1
	right := sort.Search(w, func(x int) bool {
		x += x1
		return query(x1, y1, x, y2) > 0
	}) + x1
	top := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y, x2, y2) == 0
	}) + y1 - 1
	bottom := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y1, x2, y) > 0
	}) + y1

	return left, top, right, bottom
}

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

	splitX := sort.Search(n, func(x int) bool {
		return query(0, 0, x, n-1) > 0
	})
	splitY := sort.Search(n, func(y int) bool {
		return query(0, 0, n-1, y) > 0
	})

	if query(0, 0, splitX, n-1) == 1 {
		ax1, ay1, ax2, ay2 := findRect(0, 0, splitX, n-1)
		bx1, by1, bx2, by2 := findRect(splitX+1, 0, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	} else {
		ax1, ay1, ax2, ay2 := findRect(0, 0, n-1, splitY)
		bx1, by1, bx2, by2 := findRect(0, splitY+1, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	}
}

package main

import (
	"fmt"
	"sort"
)

var cache = make(map[struct{ x1, y1, x2, y2 int }]int)

func query(x1, y1, x2, y2 int) int {
	if answer, ok := cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}]; ok {
		return answer
	}
	fmt.Println("?", x1+1, y1+1, x2+1, y2+1)
	var result int
	fmt.Scan(&result)
	cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}] = result
	return result
}

func findRect(x1, y1, x2, y2 int) (int, int, int, int) {
	w, h := x2-x1+1, y2-y1+1

	left := sort.Search(w, func(x int) bool {
		x += x1
		return query(x, y1, x2, y2) == 0
	}) + x1 - 1
	right := sort.Search(w, func(x int) bool {
		x += x1
		return query(x1, y1, x, y2) > 0
	}) + x1
	top := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y, x2, y2) == 0
	}) + y1 - 1
	bottom := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y1, x2, y) > 0
	}) + y1

	return left, top, right, bottom
}

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

	splitX := sort.Search(n, func(x int) bool {
		return query(0, 0, x, n-1) > 0
	})
	splitY := sort.Search(n, func(y int) bool {
		return query(0, 0, n-1, y) > 0
	})

	if query(0, 0, splitX, n-1) == 1 && query(0, splitX+1, n-1, n-1) == 1 {
		ax1, ay1, ax2, ay2 := findRect(0, 0, splitX, n-1)
		bx1, by1, bx2, by2 := findRect(splitX+1, 0, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	} else {
		ax1, ay1, ax2, ay2 := findRect(0, 0, n-1, splitY)
		bx1, by1, bx2, by2 := findRect(0, splitY+1, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	}
}

package main

import (
	"fmt"
	"sort"
)

func query(x1, y1, x2, y2 int) int {
	fmt.Println("?", x1+1, y1+1, x2+1, y2+1)
	var result int
	fmt.Scan(&result)
	return result
}

func findRect(x1, y1, x2, y2 int) (int, int, int, int) {
	w, h := x2-x1+1, y2-y1+1

	left := sort.Search(w, func(x int) bool {
		x += x1
		return query(x, y1, x2, y2) == 0
	}) + x1 - 1
	right := sort.Search(w, func(x int) bool {
		x += x1
		return query(x1, y1, x, y2) > 0
	}) + x1
	top := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y, x2, y2) == 0
	}) + y1 - 1
	bottom := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y1, x2, y) > 0
	}) + y1

	return left, top, right, bottom
}

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

	splitX := sort.Search(n, func(x int) bool {
		return query(0, 0, x, n-1) > 0
	})
	splitY := sort.Search(n, func(y int) bool {
		return query(0, 0, n-1, y) > 0
	})

	if query(0, 0, splitX, n-1) == 1 {
		ax1, ay1, ax2, ay2 := findRect(0, 0, splitX, n-1)
		bx1, by1, bx2, by2 := findRect(splitX+1, 0, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	} else {
		ax1, ay1, ax2, ay2 := findRect(0, 0, n-1, splitY)
		bx1, by1, bx2, by2 := findRect(0, splitY+1, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	}
}

package main

import (
	"fmt"
	"sort"
)

var count = 0
var cache = make(map[struct{ x1, y1, x2, y2 int }]int)

func query(x1, y1, x2, y2 int) int {
	count++
	if count == 200 {
		for {
		}
	}
	if answer, ok := cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}]; ok {
		return answer
	}
	fmt.Println("?", x1+1, y1+1, x2+1, y2+1)
	var result int
	fmt.Scan(&result)
	cache[struct{ x1, y1, x2, y2 int }{x1, y1, x2, y2}] = result
	return result
}

func findRect(x1, y1, x2, y2 int) (int, int, int, int) {
	w, h := x2-x1+1, y2-y1+1

	left := sort.Search(w, func(x int) bool {
		x += x1
		return query(x, y1, x2, y2) == 0
	}) + x1 - 1
	right := sort.Search(w, func(x int) bool {
		x += x1
		return query(x1, y1, x, y2) > 0
	}) + x1
	top := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y, x2, y2) == 0
	}) + y1 - 1
	bottom := sort.Search(h, func(y int) bool {
		y += y1
		return query(x1, y1, x2, y) > 0
	}) + y1

	return left, top, right, bottom
}

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

	splitX := sort.Search(n, func(x int) bool {
		return query(0, 0, x, n-1) > 0
	})
	splitY := sort.Search(n, func(y int) bool {
		return query(0, 0, n-1, y) > 0
	})

	if query(0, 0, splitX, n-1) == 1 {
		ax1, ay1, ax2, ay2 := findRect(0, 0, splitX, n-1)
		bx1, by1, bx2, by2 := findRect(splitX+1, 0, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	} else {
		ax1, ay1, ax2, ay2 := findRect(0, 0, n-1, splitY)
		bx1, by1, bx2, by2 := findRect(0, splitY+1, n-1, n-1)
		fmt.Println("!", ax1+1, ay1+1, ax2+1, ay2+1, bx1+1, by1+1, bx2+1, by2+1)
	}
}


Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet.Overall the galaxy has n planets, indexed with numbers from 1 to n. Jack is on the planet with index 1, and Apophis will land on the planet with index n. Jack can move between some pairs of planets through stargates (he can move in both directions); the transfer takes a positive, and, perhaps, for different pairs of planets unequal number of seconds. Jack begins his journey at time 0.It can be that other travellers are arriving to the planet where Jack is currently located. In this case, Jack has to wait for exactly 1 second before he can use the stargate. That is, if at time t another traveller arrives to the planet, Jack can only pass through the stargate at time t + 1, unless there are more travellers arriving at time t + 1 to the same planet.Knowing the information about travel times between the planets, and the times when Jack would not be able to use the stargate on particular planets, determine the minimum time in which he can get to the planet with index n.

The first line contains two space-separated integers: n (2 ≤ n ≤ 105), the number of planets in the galaxy, and m (0 ≤ m ≤ 105) — the number of pairs of planets between which Jack can travel using stargates. Then m lines follow, containing three integers each: the i-th line contains numbers of planets ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi), which are connected through stargates, and the integer transfer time (in seconds) ci (1 ≤ ci ≤ 104) between these planets. It is guaranteed that between any pair of planets there is at most one stargate connection. Then n lines follow: the i-th line contains an integer ki (0 ≤ ki ≤ 105) that denotes the number of moments of time when other travellers arrive to the planet with index i. Then ki distinct space-separated integers tij (0 ≤ tij < 109) follow, sorted in ascending order. An integer tij means that at time tij (in seconds) another traveller arrives to the planet i. It is guaranteed that the sum of all ki does not exceed 105.

Print a single number — the least amount of time Jack needs to get from planet 1 to planet n. If Jack can't get to planet n in any amount of time, print number -1.

NoteIn the first sample Jack has three ways to go from planet 1. If he moves to planet 4 at once, he spends 8 seconds. If he transfers to planet 3, he spends 3 seconds, but as other travellers arrive to planet 3 at time 3 and 4, he can travel to planet 4 only at time 5, thus spending 8 seconds in total. But if Jack moves to planet 2, and then — to planet 4, then he spends a total of only 2 + 5 = 7 seconds.In the second sample one can't get from planet 1 to planet 3 by moving through stargates.

package main

import (
	"bufio"
	"os"
	"fmt"
	"strconv"
	"sort"
	"container/heap"
)

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

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

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

func readFloat64() float64 {
	v, _ := strconv.ParseFloat(readString(), 64)
	return v
}

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

type Edge struct {
	From int
	To   int
	Dist int
	Cap  int
	Flow int
}

type Graph struct {
	NNode int
	NEdge int
	Edges []Edge
	Nodes [][]int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, dist, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, dist, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, dist, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

type QueueStack struct {
	data []interface{}
}

func (q *QueueStack) size() int {
	return len(q.data)
}

func (q *QueueStack) push(v interface{}) {
	q.data = append(q.data, v)
}

func (q *QueueStack) popFront() interface{} {
	v := q.data[0]
	q.data = q.data[1:]
	return v
}

func (q *QueueStack) pop() interface{} {
	last := len(q.data) - 1
	v := q.data[last]
	q.data = q.data[:last]
	return v
}

var arrival [][]int

func findNextTiming(at, earlist int) int {
	a := arrival[at]
	i := sort.Search(len(a), func(i int) bool {
		return a[i] >= earlist
	})
	for i < len(a) && a[i] == earlist {
		i++
		earlist++
	}
	return earlist
}

func Spfa(g *Graph, from, to int) int {
	n := g.NNode
	dist := make([]int, n, n)
	inQueue := make([]bool, n, n)
	dist[0] = 0
	for i := 1; i < n; i++ {
		dist[i] = -1
	}

	q := &QueueStack{}
	q.push(from)
	inQueue[from] = true
	for q.size() > 0 {
		cur := q.pop().(int)
		inQueue[cur] = false

		nextStart := findNextTiming(cur, dist[cur])
		for _, ie := range g.Nodes[cur] {
			e := g.Edges[ie]
			fromCur := nextStart + e.Dist
			if dist[e.To] == -1 || fromCur < dist[e.To] {
				dist[e.To] = fromCur
				if !inQueue[e.To] {
					q.push(e.To)
					inQueue[e.To] = true
				}
			}
		}
	}

	return dist[to]
}

type PQType struct {
	node int
	dist int
}

type PriorityQueue []PQType

func (pq PriorityQueue) Len() int {
	return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].dist < pq[j].dist
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(PQType))
}

func (pq *PriorityQueue) Pop() interface{} {
	last := len(*pq) - 1
	old := *pq
	x := old[last]
	*pq = old[:last]
	return x
}

func (pq PriorityQueue) Show() {
	for _, x := range pq {
		fmt.Printf("%v <<< ", x)
	}
	fmt.Println()
}

func Dijkstra(g *Graph, from, to int) int {
	n := g.NNode
	done := make([]bool, n, n)

	pq := make(PriorityQueue, 0)
	heap.Push(&pq, PQType{from, 0})

	ans := -1
	for pq.Len() > 0 {
		x := heap.Pop(&pq).(PQType)
		if done[x.node] {
			continue
		}
		done[x.node] = true
		if x.node ==  to {
			ans = x.dist
			//break
		}
		nextStart := findNextTiming(x.node, x.dist)
		for _, ie := range g.Nodes[x.node] {
			e := g.Edges[ie]
			if !done[e.To] {
				x = PQType{e.To, e.Dist + nextStart}
				heap.Push(&pq, x)
			}
		}
	}

	return ans
}

func main() {
	defer writer.Flush()

	n, m := readInt(), readInt()
	g := NewGraph(n, m)

	for i := 0; i < m; i++ {
		x, y, d := readInt(), readInt(), readInt()
		g.AddEdge(x - 1, y - 1, d, 0, 0)
	}

	arrival = make([][]int, n, n)
	for i := 0; i < n; i++ {
		nArrival := readInt()
		arrival[i] = make([]int, nArrival, nArrival)
		for j := 0; j < nArrival; j++ {
			arrival[i][j] = readInt()
		}
	}

	//ans := Spfa(g, 0, n - 1)
	ans := Dijkstra(g, 0, n - 1)
	fmt.Fprintf(writer, "%d\n", ans)
}

package main

import (
	"bufio"
	"os"
	"fmt"
	"strconv"
	"sort"
	"container/heap"
)

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

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

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

func readFloat64() float64 {
	v, _ := strconv.ParseFloat(readString(), 64)
	return v
}

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

type Edge struct {
	From int
	To   int
	Dist int
	Cap  int
	Flow int
}

type Graph struct {
	NNode int
	NEdge int
	Edges []Edge
	Nodes [][]int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, dist, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, dist, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, dist, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

type QueueStack struct {
	data []interface{}
}

func (q *QueueStack) size() int {
	return len(q.data)
}

func (q *QueueStack) push(v interface{}) {
	q.data = append(q.data, v)
}

func (q *QueueStack) popFront() interface{} {
	v := q.data[0]
	q.data = q.data[1:]
	return v
}

func (q *QueueStack) pop() interface{} {
	last := len(q.data) - 1
	v := q.data[last]
	q.data = q.data[:last]
	return v
}

var arrival [][]int

func findNextTiming(at, earlist int) int {
	a := arrival[at]
	i := sort.Search(len(a), func(i int) bool {
		return a[i] >= earlist
	})
	for i < len(a) && a[i] == earlist {
		i++
		earlist++
	}
	return earlist
}

func Spfa(g *Graph, from, to int) int {
	n := g.NNode
	dist := make([]int, n, n)
	inQueue := make([]bool, n, n)
	dist[0] = 0
	for i := 1; i < n; i++ {
		dist[i] = -1
	}

	q := &QueueStack{}
	q.push(from)
	inQueue[from] = true
	for q.size() > 0 {
		cur := q.pop().(int)
		inQueue[cur] = false

		nextStart := findNextTiming(cur, dist[cur])
		for _, ie := range g.Nodes[cur] {
			e := g.Edges[ie]
			fromCur := nextStart + e.Dist
			if dist[e.To] == -1 || fromCur < dist[e.To] {
				dist[e.To] = fromCur
				if !inQueue[e.To] {
					q.push(e.To)
					inQueue[e.To] = true
				}
			}
		}
	}

	return dist[to]
}

type PQType struct {
	node int
	dist int
}

type PriorityQueue []PQType

func (pq PriorityQueue) Len() int {
	return len(pq)
}

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].dist < pq[j].dist
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(PQType))
}

func (pq *PriorityQueue) Pop() interface{} {
	last := len(*pq) - 1
	old := *pq
	x := old[last]
	*pq = old[:last]
	return x
}

func (pq PriorityQueue) Show() {
	for _, x := range pq {
		fmt.Printf("%v <<< ", x)
	}
	fmt.Println()
}

func Dijkstra(g *Graph, from, to int) int {
	n := g.NNode
	done := make([]bool, n, n)

	pq := make(PriorityQueue, 0)
	heap.Push(&pq, PQType{from, 0})

	ans := -1
	for pq.Len() > 0 {
		x := heap.Pop(&pq).(PQType)
		if done[x.node] {
			continue
		}
		done[x.node] = true
		if x.node ==  to {
			ans = x.dist
			break
		}
		nextStart := findNextTiming(x.node, x.dist)
		for _, ie := range g.Nodes[x.node] {
			e := g.Edges[ie]
			if !done[e.To] {
				x = PQType{e.To, e.Dist + nextStart}
				heap.Push(&pq, x)
			}
		}
	}

	return ans
}

func main() {
	defer writer.Flush()

	n, m := readInt(), readInt()
	g := NewGraph(n, m)

	for i := 0; i < m; i++ {
		x, y, d := readInt(), readInt(), readInt()
		g.AddEdge(x - 1, y - 1, d, 0, 0)
	}

	arrival = make([][]int, n, n)
	for i := 0; i < n; i++ {
		nArrival := readInt()
		arrival[i] = make([]int, nArrival, nArrival)
		for j := 0; j < nArrival; j++ {
			arrival[i][j] = readInt()
		}
	}

	//ans := Spfa(g, 0, n - 1)
	ans := Dijkstra(g, 0, n - 1)
	fmt.Fprintf(writer, "%d\n", ans)
}

package main

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

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

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

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

func readFloat64() float64 {
	v, _ := strconv.ParseFloat(readString(), 64)
	return v
}

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

type Edge struct {
	From int
	To int
	Dist int
	Cap int
	Flow int
}

type Graph struct {
	NNode int
	NEdge int
	Edges []Edge
	Nodes [][]int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, dist, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, dist, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, dist, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

type QueueStack struct {
	data []interface{}
}

func (q *QueueStack) size() int {
	return len(q.data)
}

func (q *QueueStack) push(v interface{}) {
	q.data = append(q.data, v)
}

func (q *QueueStack) popFront() interface{} {
	v := q.data[0]
	q.data = q.data[1:]
	return v
}

func (q *QueueStack) pop() interface{} {
	last := len(q.data) - 1
	v := q.data[last]
	q.data = q.data[:last]
	return v
}

var arrival [][]int

func findNextTiming(to, earlist int) int {
	for _, a := range arrival[to] {
		if a < earlist {
			continue
		} else if a == earlist {
			earlist++
		} else {
			break
		}
	}
	return earlist
}

func Spfa(g *Graph, from, to int) int {
	n := g.NNode
	dist := make([]int, n, n)
	dist[0] = 0
	for i := 1; i < n; i++ {
		dist[i] = -1
	}

	q := &QueueStack{}
	q.push(from)
	for q.size() > 0 {
		cur := q.pop().(int)
		for _, ie := range g.Nodes[cur] {
			e := g.Edges[ie]
			earlist := dist[cur] + e.Dist
			nextTiming := findNextTiming(e.To, earlist)
			if dist[e.To] == -1 || nextTiming < dist[e.To] {
				dist[e.To] = nextTiming
				q.push(e.To)
			}
		}
	}

	return dist[to]
}

func main() {
	defer writer.Flush()

	n, m := readInt(), readInt()
	g := NewGraph(n, m)

	for i := 0; i < m; i++ {
		x, y, d := readInt(), readInt(), readInt()
		g.AddEdge(x - 1, y - 1, d, 0, 0)
	}

	arrival = make([][]int, n, n)
	for i := 0; i < n; i++ {
		nArrival := readInt()
		arrival[i] = make([]int, nArrival, nArrival)
		for j := 0; j < nArrival; j++ {
			arrival[i][j] = readInt()
		}
	}

	ans := Spfa(g, 0, n - 1)
	fmt.Fprintf(writer, "%d\n", ans)
}