package main

import "fmt"

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

	var xmin, ymin, xmax, ymax int
	var x, y int

	xmin, ymin, xmax, ymax = 1000000001, 1000000001, -1000000001, -1000000001
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		if xmin > x {
			xmin = x
		}
		if xmax < x {
			xmax = x
		}
		if ymin > y {
			ymin = y
		}
		if ymax < y {
			ymax = y
		}
	}

	var s, area uint64
	s = uint64(ymax - ymin)
	if s < uint64(xmax-xmin) {
		s = uint64(xmax - xmin)
	}
	area = s * s

	fmt.Println(area)
}

package main

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

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

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

	n, x, y := int64(nextInt()), int64(0), int64(0)
	var maxX, maxY, minX, minY int64 = math.MinInt64, math.MinInt64, math.MaxInt64, math.MaxInt64

	for ; n > 0; n-- {
		x, y = int64(nextInt()), int64(nextInt())

		if x > maxX {
			maxX = x
		}

		if y > maxY {
			maxY = y
		}

		if x < minX {
			minX = x
		}

		if y < minY {
			minY = y
		}
	}

	x, y = maxX - minX, maxY - minY

	if x > y {
		n = x * x
	} else {
		n = y * y
	}

	println(n)
}

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

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

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

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

package main

import (
	"fmt"
	"math"
)

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

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

func main() {
	var n int
	var x, y, minX, minY, maxX, maxY int64
	minX, minY = math.MaxInt64, math.MaxInt64
	maxX, maxY = math.MinInt64, math.MinInt64
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		minX = min(minX, x)
		maxX = max(maxX, x)
		minY = min(minY, y)
		maxY = max(maxY, y)
	}
	z := max(maxX-minX, maxY-minY)
	fmt.Println(z * z)
}

package main

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

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

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

func ReadInt64() int64 {
    scanner.Scan()
    ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)
    return ans
}

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

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

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    n := ReadInt32()
    minx := ReadInt64()
    maxx := minx
    miny := ReadInt64()
    maxy := miny
    var a, b int64

    for i := 1; i < n; i++ {
        a = ReadInt64()
        b = ReadInt64()
        if minx > a {
            minx = a
        } else if maxx < a {
            maxx = a
        }

        if miny > b {
            miny = b
        } else if maxy < b {
            maxy = b
        }
    }
    u := abs(minx - maxx)
    v := abs(miny - maxy)
    if u < v {
        u = v
    }

    writer.WriteString(strconv.FormatInt(u*u, 10) + "\n")
}

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()
    inf := 1000000001
    minx := inf
    maxx := -inf
    miny := inf
    maxy := -inf
    for i := 0; i < n; i++ {
        x := nextInt()
        y := nextInt()
        if minx > x {minx = x}
        if maxx < x {maxx = x}
        if miny > y {miny = y}
        if maxy < y {maxy = y}
    }
    a := maxx - minx
    if a < maxy - miny {a = maxy - miny}
    var s int64
    s = int64(a) * int64(a)
    fmt.Fprintln(out, s)
}

package main

import (
	"fmt"
)

func main() {
	var l, r, u, d int64
	l = 1e9
	r = -1e9
	u = -1e9
	d = 1e9
	var n int
	var x, y int64
	fmt.Scanf("%d ", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d %d ", &x, &y)
		if x < l {
			l = x
		}
		if x > r {
			r = x
		}
		if u < y {
			u = y
		}
		if d > y {
			d = y
		}
	}
	x = r - l
	if x < u-d {
		x = u - d
	}
	fmt.Printf("%d\n", x*x)
}

package main
import "fmt"
func min(a int64,b int64)int64{
    if a<b{
        return a
    }
    return b
}

func max(a int64,b int64)int64{
    if a>b{
        return a
    }
    return b
}
func main(){
    var a,x,y int64
    mix:=int64(1e10)
    miy:=mix
    maxx,may:=-mix,-mix
    fmt.Scan(&a)
    for a>0{
        a--
        fmt.Scan(&x,&y)
        mix=min(x,mix)
        maxx=max(x,maxx)
        miy=min(y,miy)
        may=max(y,may)
    }
    fmt.Println(max(maxx-mix,may-miy)*max(maxx-mix,may-miy))
}

package main

import "fmt"

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

	var xmin, ymin, xmax, ymax int
	var x, y int

	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		if xmin > x {
			xmin = x
		}
		if xmax < x {
			xmax = x
		}
		if ymin > y {
			ymin = y
		}
		if ymax < y {
			ymax = y
		}
	}

	var s, area uint64
	s = uint64(ymax - ymin)
	if s < uint64(xmax-xmin) {
		s = uint64(xmax - xmin)
	}
	area = s * s

	fmt.Println(area)
}

package main

import "fmt"

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

	var xmin, ymin, xmax, ymax int
	var x, y int

	xmin, ymin, xmax, ymax = 100001, 100001, -100001, -100001
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		if xmin > x {
			xmin = x
		}
		if xmax < x {
			xmax = x
		}
		if ymin > y {
			ymin = y
		}
		if ymax < y {
			ymax = y
		}
	}

	var s, area uint64
	s = uint64(ymax - ymin)
	if s < uint64(xmax-xmin) {
		s = uint64(xmax - xmin)
	}
	area = s * s

	fmt.Println(area)
}

package main

import (
	"fmt"
)

func main() {
	var l, r, u, d int64
	l = 1e9
	r = -1e9
	u = -1e9
	d = 1e9
	var n int
	var x, y int64
	fmt.Scanf("%d ", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d %d ", &x, &y)
		if x < l {
			l = x
		}
		if x > r {
			r = x
		}
		if u < y {
			u = y
		}
		if d > y {
			d = y
		}
	}
	fmt.Printf("%d\n", (r-l)*(u-d))
}


package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	M := io.NextInt()

	nodes := make([]*Node, N + 1)
	for i := 1; i <= N; i++ {
		nodes[i] = &Node{}
	}

	for i := 0; i < M; i++ {
		U := io.NextInt()
		V := io.NextInt()

		nodes[U].Next = append(nodes[U].Next, nodes[V])
		nodes[V].Next = append(nodes[V].Next, nodes[U])
	}

	cnt := 0
	seen := make(map[*Node]bool)
	for i := 1; i <= N; i++ {
		if seen[nodes[i]] {
			continue
		}
		comp := make(map[*Node]bool)
		getComponent(nodes[i], comp)
		for u := range comp {
			seen[u] = true
		}
		if len(comp) <= 1 {
			continue
		}
		good := true
		for u := range comp {
			if len(u.Next) != 2 {
				good = false
				break
			}
		}
		if good {
			cnt++
		}
	}
	io.Println(cnt)
}

func getComponent(u *Node, seen map[*Node]bool) {
	if seen[u] {
		return
	}
	seen[u] = true
	for _, v := range u.Next {
		getComponent(v, seen)
	}
}

type Node struct {
	Next []*Node
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func main() {
	var n, m int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &m)

	verts := make([][]int, n+1)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		verts[a] = append(verts[a], b)
		verts[b] = append(verts[b], a)
	}

	cycles := 0
	seen := make([]bool, n+1)
	for node, edg := range verts {
		if seen[node] {
			continue
		}
		seen[node] = true

		if len(edg) != 2 {
			continue
		}

		last := node
		cur := edg[0]
		for {
			if cur == node {
				cycles++
				break
			}
			if seen[cur] {
				break
			}
			seen[cur] = true

			edg := verts[cur]
			if len(edg) != 2 {
				break
			}

			if edg[0] == last {
				cur, last = edg[1], cur
			} else {
				cur, last = edg[0], cur
			}
		}
	}

	fmt.Println(cycles)
}

func clear(verts [][]int, node int) {

}

package main

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

var n, m int
var g [][]int
var q []int
var p1 int
var u []byte
var cnt int

func dfs(v int) {
	q[p1] = v
	p1++
	u[v] = 1
	for _, next := range g[v] {
		if u[next] == 0 {
			dfs(next)
		}
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	g = make([][]int, n)
	u = make([]byte, n)
	q = make([]int, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		g[t1] = append(g[t1], t2)
		g[t2] = append(g[t2], t1)
	}
	for i := 0; i < n; i++ {
		if u[i] == 0 {
			p1 = 0
			dfs(i)
			f := 1
			for j := 0; j < p1; j++ {
				if len(g[q[j]]) != 2 {
					f = 0
					break
				}
			}
			cnt += f
		}
	}
	fmt.Println(cnt)
}

package main

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

// Print number of connected components that are also cycles in an
// undirected graph

func e() int {
	var n, m int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &m)

	graph := make([][]int, n+1)
	degrees := make([]int, n+1)
	comp := []int{}
	for i := 0; i < len(graph); i++ {
		graph[i] = []int{}
	}

	for i := 0; i < m; i++ {
		var v, u int
		fmt.Fscanf(in, "%d %d\n", &v, &u)

		graph[v] = append(graph[v], u)
		graph[u] = append(graph[u], v)
		degrees[v]++
		degrees[u]++
	}

	var dfs func(i int)
	visited := make([]bool, len(graph))
	dfs = func(i int) {
		visited[i] = true
		for j := 0; j < len(graph[i]); j++ {
			if !visited[graph[i][j]] {
				comp = append(comp, graph[i][j])
				dfs(graph[i][j])
			}
		}
	}

	var count int
	for i := 1; i < len(graph); i++ {
		if !visited[i] {
			comp = nil
			comp = append(comp, i)

			dfs(i)
			hasCycle := true
			for i := 0; i < len(comp); i++ {
				if degrees[comp[i]] != 2 {
					hasCycle = false
				}
			}
			if hasCycle {
				count++
			}
		}
	}
	return count
}

func main() {
	fmt.Println(e())
}

package main

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

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

var edge [][]int
var vis []bool

func dfs(cur, from, rt int) int {
	vis[cur] = true
	if len(edge[cur]) != 2 {
		return 0
	}
	if cur == rt {
		if vis[edge[cur][0]] {
			return 0
		}
		return dfs(edge[cur][0], cur, rt)
	}
	for _, i := range edge[cur] {
		if i == rt && from != rt {
			return 1
		}
		if vis[i] {
			continue
		}
		return dfs(i, cur, rt)
	}
	return 0
}

func main() {
	defer out.Flush()

	var n, m, u, v int
	fmt.Fscan(in, &n, &m)
	edge = make([][]int, n+1)
	vis = make([]bool, n+1)
	for i := 1; i <= n; i++ {
		edge[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &u, &v)
		edge[u] = append(edge[u], v)
		edge[v] = append(edge[v], u)
	}
	ans := 0
	for i := 1; i <= n; i++ {
		if !vis[i] {
			ans += dfs(i, -1, i)
		}
	}
	fmt.Fprintln(out, ans)
}

package main

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

func solve() {
	n := readInt()
	m := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		u := readInt() - 1
		v := readInt() - 1
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}
	vis := make([]bool, n)
	cnt := 0
	for i := 0; i < n; i++ {
		if !vis[i] && dfs(g, vis, i) {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func dfs(g [][]int, vis []bool, u int) bool {
	vis[u] = true
	ans := len(g[u]) == 2
	for _, v := range g[u] {
		if !vis[v] && !dfs(g, vis, v) {
			ans = false
		}
	}
	return ans
}

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

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

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

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(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; 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
}

package main

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

func solve() {
	n := readInt()
	m := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		u := readInt() - 1
		v := readInt() - 1
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}
	vis := make([]bool, n)
	ans := 0
	for i := 0; i < n; i++ {
		if !vis[i] {
			ok := true
			values := dfs(g, vis, i, nil)
			for _, u := range values {
				if len(g[u]) != 2 {
					ok = false
					break
				}
			}
			if ok {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

func dfs(g [][]int, vis []bool, u int, values []int) []int {
	vis[u] = true
	values = append(values, u)
	for _, v := range g[u] {
		if !vis[v] {
			values = dfs(g, vis, v, values)
		}
	}
	return values
}

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

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

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

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(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; 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
}

package main

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

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

	var n, m, v, w, ans int
	Fscan(in, &n, &m)
	deg := make([]int, n)
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
		deg[v]++
		deg[w]++
	}

	vis := make([]bool, n)
	var comp []int
	var f func(int)
	f = func(v int) {
		vis[v] = true
		comp = append(comp, v)
		for _, w := range g[v] {
			if !vis[w] {
				f(w)
			}
		}
	}
	for i := 0; i < n; i++ {
		if !vis[i] {
			comp = []int{}
			f(i)
			ans++
			for _, v := range comp {
				if deg[v] != 2 {
					ans--
					break
				}
			}
		}
	}
	Fprint(out, ans)
}

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

package main

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

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

	var n, m, v, w, ans, c int
	Fscan(in, &n, &m)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	var f func(int)
	f = func(v int) {
		vis[v] = true
		if len(g[v]) != 2 {
			c = 0
		}
		for _, w := range g[v] {
			if !vis[w] {
				f(w)
			}
		}
	}
	for i := 1; i <= n; i++ {
		if !vis[i] {
			c = 1
			f(i)
			ans += c
		}
	}
	Fprint(out, ans)
}

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

package main

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

var n, m int
var g [][]int
var u []byte
var cnt int

func dfs(p, v1, v2 int) int {
	u[v1] = 1
	if len(g[v1]) != 2 {
		return 0
	}
	next := g[v1][0]
	if next == p {
		next = g[v1][1]
	}
	if next == v2 {
		u[v2] = 1
		if len(g[next]) == 2 {
			return 1
		}
		return 0
	}
	return dfs(v1, next, v2)
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	g = make([][]int, n)
	u = make([]byte, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		g[t1] = append(g[t1], t2)
		g[t2] = append(g[t2], t1)
	}
	for i := 0; i < n; i++ {
		if u[i] == 0 && len(g[i]) == 2 {
			u[i] = 1
			cnt += dfs(-1, g[i][1], g[i][0])
		}
	}
	fmt.Println(cnt)
}

package main

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

var n, m int
var g [][]int
var u []byte
var cnt int

func dfs(p, v1, v2 int) int {
	u[v1] = 1
	if len(g[v1]) != 2 {
		return 0
	}
	next := g[v1][0]
	if next == p {
		next = g[v1][1]
	}
	if u[next] == 1 {
		return 0
	}
	if next == v2 {
		u[v2] = 1
		return 1
	}
	return dfs(v1, next, v2)
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	g = make([][]int, n)
	u = make([]byte, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		g[t1] = append(g[t1], t2)
		g[t2] = append(g[t2], t1)
	}
	for i := 0; i < n; i++ {
		if u[i] == 0 && len(g[i]) == 2 {
			u[i] = 1
			cnt += dfs(-1, g[i][1], g[i][0])
		}
	}
	fmt.Println(cnt)
}

package main

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

var n, m int
var g [][]int
var u []int
var d []int
var cnt int

func dfs(v1, v2 int) int {
	u[v1] = 1
	if len(g[v1]) != 2 {
		return 0
	}
	if g[v1][0] == v2 {
		u[v2] = 1
		return 1
	}
	return dfs(g[v1][0], v2)
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	g = make([][]int, n)
	u = make([]int, n)
	d = make([]int, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		g[t1] = append(g[t1], t2)
		g[t2] = append(g[t2], t1)
	}
	for i := 0; i < n; i++ {
		if u[i] == 0 && len(g[i]) == 2 {
			u[i] = 1
			cnt += dfs(g[i][1], g[i][0])
		}
	}
	fmt.Println(cnt)
}

package main

import "fmt"

// Print number of connected components that are also cycles in an
// undirected graph

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

	graph := make([][]int, n+1)
	degrees := make([]int, n+1)
	comp := []int{}
	for i := 0; i < len(graph); i++ {
		graph[i] = []int{}
	}

	for i := 0; i < m; i++ {
		var v, u int
		fmt.Scanf("%d %d", &v, &u)

		graph[v] = append(graph[v], u)
		graph[u] = append(graph[u], v)
		degrees[v]++
		degrees[u]++
	}

	var dfs func(i int)
	visited := make([]bool, len(graph))
	dfs = func(i int) {
		visited[i] = true
		for j := 0; j < len(graph[i]); j++ {
			if !visited[graph[i][j]] {
				comp = append(comp, graph[i][j])
				dfs(graph[i][j])
			}
		}
	}

	var count int
	for i := 1; i < len(graph); i++ {
		if !visited[i] {
			comp = []int{}
			comp = append(comp, i)

			dfs(i)
			hasCycle := true
			for i := 0; i < len(comp); i++ {
				if degrees[comp[i]] != 2 {
					hasCycle = false
				}
			}
			if hasCycle {
				count++
			}
		}
	}
	return count
}

func main() {
	fmt.Println(e())
}

package main

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

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

	var n, m, v, w int
	Fscan(in, &n, &m)
	initFa(n)
	type edge struct{ v, w int }
	edges := make([]edge, m)
	for i := range edges {
		Fscan(in, &v, &w)
		v--
		w--
		edges[i] = edge{v, w}
		merge(v, w)
	}
	edgeCnts := make([]int, n)
	for _, e := range edges {
		edgeCnts[find(e.v)]++
	}
	ans := 0
	for i, sz := range size {
		if sz == edgeCnts[i] {
			ans++
		}
	}
	Fprint(out, ans)
}

func main() {
	CF977E(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 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 n int
	scan(&n)

	var (
		rs     = make([][2]int, 0, n/3-2)
		s0, s1 = -1, -1
	)
	for x := 1; x <= n; x += 3 {
		r := request(x, x+1, x+2)
		if r == 0 && s0 == -1 {
			s0 = x
			continue
		}
		if r == 1 && s1 == -1 {
			s1 = x
			continue
		}
		rs = append(rs, [2]int{x, r})
	}

	var (
		a0, b0, c0   = s0, s0 + 1, s0 + 2
		a1, b1, c1   = s1, s1 + 1, s1 + 2
		tmpval       = make([][2]int, 0, 4)
		meet0, meet1 = false, false
	)
	for _, x := range [...]int{b0, c0, b1, c1} {
		r := request(a0, a1, x)
		tmpval = append(tmpval, [2]int{x, r})
		meet0 = meet0 || r == 0
		meet1 = meet1 || r == 1
	}
	var (
		val   = make([]int, n+1)
		valof = [2]int{-1, -1}
	)
	if meet0 && meet1 {
		for _, i := range tmpval {
			x, r := i[0], i[1]
			val[x] = r
			if r == 0 {
				valof[0] = x
			}
			if r == 1 {
				valof[1] = x
			}
		}
		val[a0] = request(valof[0], valof[1], a0)
		val[a1] = request(valof[0], valof[1], a1)
	} else if meet0 {
		valof[0], valof[1] = a1, b1
		val[a0] = 0
		val[b0] = request(valof[0], valof[1], b0)
		val[c0] = request(valof[0], valof[1], c0)
		val[a1] = 0
		val[b1] = 1
		val[c1] = 1
	} else {
		valof[0], valof[1] = b0, a0
		val[a0] = 1
		val[b0] = 0
		val[c0] = 0
		val[a1] = 1
		val[b1] = request(valof[0], valof[1], b1)
		val[c1] = request(valof[0], valof[1], c1)
	}
	// no case for (!meet0 && !meet1)

	for _, i := range rs {
		a, r := i[0], i[1]
		b, c := a+1, a+2
		ab, bc := request(valof[r^1], a, b), request(valof[r^1], b, c)
		if ab == r^1 && bc == r^1 {
			val[a] = r
			val[b] = r ^ 1
			val[c] = r
		} else if ab == r^1 {
			val[a] = r ^ 1
			val[b] = r
			val[c] = r
		} else if bc == r^1 {
			val[a] = r
			val[b] = r
			val[c] = r ^ 1
		} else {
			val[a] = r
			val[b] = r
			val[c] = r
		}
	}

	var k int
	for i := 1; i <= n; i++ {
		if val[i] == 0 {
			k++
		}
	}

	printf("! %v ", k)
	for i := 1; i <= n; i++ {
		if val[i] == 0 {
			printf("%v ", i)
		}
	}
	printf("\n")
	writer.Flush()
}

func request(a, b, c int) (x int) {
	printf("? %v %v %v\n", a, b, c)
	writer.Flush()
	scan(&x)
	return
}

package main

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

// github.com/EndlessCheng/codeforces-go
type (
	initData struct{ n int }
	request  struct{ i, j, k int }
	response struct{ v int }
	answer   struct{ ans []int }
)

type interaction interface {
	readInitData() initData
	query(request) response
	printAnswer(answer)
}

type io struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (io io) readInitData() (d initData) {
	Fscan(io.in, &d.n)
	return
}

func (io io) query(req request) (resp response) {
	Fprintln(io.out, "?", req.i, req.j, req.k)
	io.out.Flush()
	Fscan(io.in, &resp.v)
	if resp.v < 0 {
		panic(-1)
	}
	return
}

func (io io) printAnswer(a answer) {
	Fprint(io.out, "! ", len(a.ans))
	for _, v := range a.ans {
		Fprint(io.out, " ", v)
	}
	Fprintln(io.out)
	io.out.Flush()
}

func doInteraction(it interaction) {
	q := func(i, j, k int) (good bool) { return it.query(request{i, j, k}).v == 1 }
	dt := it.readInitData()
	n := dt.n
	ans := []int{}
	defer func() { it.printAnswer(answer{ans}) }()

	if n == 6 {
		// 特判？
	}

	var good, bad [3]int
	for i := 1; ; i += 3 {
		if q(i, i+1, i+2) {
			good = [3]int{i, i + 1, i + 2}
		} else {
			bad = [3]int{i, i + 1, i + 2}
		}
		if good[0] > 0 && bad[0] > 0 {
			break
		}
	}

	var badman, goodman int
	for _, id := range good {
		if q(bad[0], bad[1], id) {
			goodman = id
			badman = bad[2]
			break
		}
	}

	if goodman == 0 {
		badman = bad[0]
		if q(good[0], good[1], badman) {
			goodman = good[0]
		} else if q(good[0], good[2], badman) {
			goodman = good[0]
		} else {
			goodman = good[1]
		}
	}
	ans = append(ans, badman)

	for i := 1; i <= n; i++ {
		if i != goodman && i != badman {
			if !q(goodman, badman, i) {
				ans = append(ans, i)
			}
		}
	}

}

// TODO: check output format before submit
func run() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	T := 1
	Fscan(in, &T)
	for ; T > 0; T-- {
		doInteraction(io{in, out})
	}
}

func main() { run() }

package main

import (
	"fmt"
	"os"
)

var n int
var ans []int

func ask(a, b, c int) int {
	fmt.Printf("? %d %d %d\n", a, b, c)
	var r int
	fmt.Scan(&r)
	if r == -1 {
		os.Exit(0)
	}
	return r
}

func setAnswer(i, v int) {
	ans[i] = v
}

func solveDifferentTrios(i, j, ansi int) (int, int) {
	var fixedi = i
	if ask(i, i+1, j) == ansi && ask(i, i+1, j+1) == ansi {
		setAnswer(i, ansi)
		setAnswer(i+1, ansi)
	} else if ask(i, i+2, j) == ansi && ask(i, i+2, j+1) == ansi {
		setAnswer(i, ansi)
		setAnswer(i+2, ansi)
	} else {
		setAnswer(i, ansi^1)
		fixedi = i + 1
		setAnswer(i+1, ansi)
		setAnswer(i+2, ansi)
	}

	var fixedj = j
	if ask(fixedi, j, j+1) != ansi {
		setAnswer(j, ansi^1)
		setAnswer(j+1, ansi^1)
	} else if ask(fixedi, j, j+2) != ansi {
		setAnswer(j, ansi^1)
		setAnswer(j+2, ansi^1)
	} else {
		setAnswer(j, ansi)
		fixedj = j + 1
		setAnswer(j+1, ansi^1)
		setAnswer(j+2, ansi^1)
	}

	for _, k := range []int{i, i + 1, i + 2, j, j + 1, j + 2} {
		if ans[k] == -1 {
			ans[k] = ask(fixedi, fixedj, k)
		}
	}

	if ansi == 0 {
		return fixedi, fixedj
	}
	return fixedj, fixedi
}

func printAnswer() {
	fmt.Printf("!")
	var count0 = 0
	for i := 1; i <= n; i++ {
		if ans[i] == 0 {
			count0 += 1
		}
	}

	fmt.Printf(" %d", count0)
	for i := 1; i <= n; i++ {
		if ans[i] == 0 {
			fmt.Printf(" %d", i)
		}
	}
	fmt.Println()
}

func solveCase() {
	fmt.Scan(&n)
	ans = make([]int, n+1)
	for i := 1; i <= n; i++ {
		ans[i] = -1
	}
	var ans123 = ask(1, 2, 3)
	var differentTrioStart = 4
	for ask(differentTrioStart, differentTrioStart+1, differentTrioStart+2) == ans123 {
		differentTrioStart += 3
	}

	idx0, idx1 := solveDifferentTrios(1, differentTrioStart, ans123)

	for i := differentTrioStart + 3; i <= n; i++ {
		ans[i] = ask(idx0, idx1, i)
	}

	var idx = idx0
	if ans123 == 0 {
		idx = idx1
	}

	for i := 4; i < differentTrioStart; i += 3 {
		if ask(i, i+1, idx) == ans123 {
			ans[i] = ans123
			ans[i+1] = ans123
			ans[i+2] = ask(idx0, idx1, i+2)
		} else {
			ans[i] = ask(idx0, idx1, i)
			ans[i+1] = ans[i] ^ 1
			ans[i+2] = ans123
		}
	}
	printAnswer()
}

func main() {
	var ntc int
	fmt.Scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

package main

import (
	"fmt"
	"os"
)

var n int
var ans []int

func ask(a, b, c int) int {
	fmt.Printf("%d %d %d\n", a, b, c)
	var r int
	fmt.Scan(&r)
	if r == -1 {
		os.Exit(0)
	}
	return r
}

func setAnswer(i, v int) {
	ans[i] = v
}

func solveDifferentTrios(i, j, ansi int) (int, int) {
	var fixedi = i
	if ask(i, i+1, j) == ansi && ask(i, i+1, j+1) == ansi {
		setAnswer(i, ansi)
		setAnswer(i+1, ansi)
	} else if ask(i, i+2, j) == ansi && ask(i, i+2, j+1) == ansi {
		setAnswer(i, ansi)
		setAnswer(i+2, ansi)
	} else {
		setAnswer(i, ansi^1)
		fixedi = i + 1
		setAnswer(i+1, ansi)
		setAnswer(i+2, ansi)
	}

	var fixedj = j
	if ask(fixedi, j, j+1) != ansi {
		setAnswer(j, ansi^1)
		setAnswer(j+1, ansi^1)
	} else if ask(fixedi, j, j+2) != ansi {
		setAnswer(j, ansi^1)
		setAnswer(j+2, ansi^1)
	} else {
		setAnswer(j, ansi)
		fixedj = j + 1
		setAnswer(j+1, ansi^1)
		setAnswer(j+2, ansi^1)
	}

	for _, k := range []int{i, i + 1, i + 2, j, j + 1, j + 2} {
		if ans[k] == -1 {
			ans[k] = ask(fixedi, fixedj, k)
		}
	}

	if ansi == 0 {
		return fixedi, fixedj
	}
	return fixedj, fixedi
}

func printAnswer() {
	fmt.Printf("!")
	for i := 1; i <= n; i++ {
		fmt.Printf(" %d", ans[i])
	}
	fmt.Println()
}

func solveCase() {
	fmt.Scan(&n)
	ans = make([]int, n+1)
	for i := 1; i <= n; i++ {
		ans[i] = -1
	}
	var ans123 = ask(1, 2, 3)
	var differentTrioStart = 4
	for ask(differentTrioStart, differentTrioStart+1, differentTrioStart+2) == ans123 {
		differentTrioStart += 3
	}

	idx0, idx1 := solveDifferentTrios(1, differentTrioStart, ans123)

	for i := differentTrioStart + 3; i <= n; i++ {
		ans[i] = ask(idx0, idx1, i)
	}

	var idx = idx0
	if ans123 == 0 {
		idx = idx1
	}

	for i := 1; i < differentTrioStart; i += 3 {
		if ask(i, i+1, idx) == ans123 {
			ans[i] = ans123
			ans[i+1] = ans123
			ans[i+2] = ask(idx0, idx1, i+2)
		} else {
			ans[i] = ask(idx0, idx1, i)
			ans[i+1] = ans[i] ^ 1
			ans[i+2] = ans123
		}
	}
	printAnswer()
}

func main() {
	var ntc int
	fmt.Scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}


package main

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

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 solve(reader io.Reader, writer io.Writer) {
	calcGCD := func(a, b int) int {
		for b > 0 {
			a, b = b, a%b
		}
		return a
	}

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

	var n int
	for Fscan(in, &n);n>0;n-- {
		var a,b int
		Fscan(in, &a, &b)
		if calcGCD(a,b) == 1 {
			Fprintln(out, "Finite")
		} else {
			Fprintln(out, "Infinite")
		}
	}

}

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

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// 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 int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	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 int) int {
	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
}

// 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])
		// 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)
}

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		a, b := ReadInt2()

		if Gcd(a, b) == 1 {
			fmt.Println("Finite")
		} else {
			fmt.Println("Infinite")
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

import "fmt"

func euklid(a, b int) int {
	for a != 0 && b != 0 {
		if a > b {
			a = a % b
		} else {
			b = b % a
		}
	}
	return a + b
}
func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scanf("%d %d\n", &a, &b)
		if euklid(a, b) == 1 {
			fmt.Println("Finite")
		} else {
			fmt.Println("Infinite")
		}
	}
}

package main

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

type point struct {
	x, y int
}

var ans int64

const (
	mod = int(1e9 + 7)
)

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	tt := 1
	fmt.Fscanf(in, "%d\n", &tt)
	for ii := 0; ii < tt; ii++ {
		a, b := 0, 0
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if gcd(a, b) == 1 {
			fmt.Fprintf(out, "Finite\n")
		} else {
			fmt.Fprintf(out, "Infinite\n")
		}
	}
	return
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func cal(c1, c2, c3 int) {
	a := []int{c1, c2, c3}
	sort.Ints(a)
	tmp := int64(try(c1, c2, c3, 0))
	tmp %= int64(mod)
	for i := 1; i <= c1; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c2; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c3; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	ans += tmp
	ans %= int64(mod)
}

func try(a, b, c int, last int) int64 {
	if a == 0 && b == 0 && c == 0 {
		return 1
	}
	if a < 0 || b < 0 || c < 0 {
		return 0
	}
	if last == 0 {
		return try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 1 {
		return try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 2 {
		return try(a-1, b, c, 1) + try(a, b, c-1, 3)
	}
	return try(a-1, b, c, 1) + try(a, b-1, c, 2)
}

package main

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

const (
	MAX_INT int64 = math.MaxInt64
	MIN_INT int64 = math.MinInt64
)

func main() {
	for t := ScanInt64(); t > 0; t-- {
		a, b := ScanInt64(), ScanInt64()

		if GCD(a, b) == 1 {
			out <- "FINITE"
		} else {
			out <- "INFINITE"
		}
	}

	close(out)
	outWg.Wait()
}

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

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

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

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

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

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

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

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

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxVal := MIN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Min(args ...int64) int64 {
	minVal := MAX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func iToS(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

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

var (
	scanner *bufio.Scanner
)

func ScanInt() int {
	if scanner.Scan() {
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}
	return 0
}

func Gcd(a, b int) int {
	if b%a == 0 {
		return a
	}
	return Gcd(b%a, a)
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	t := ScanInt()
	for ; t > 0; t-- {
		a := ScanInt()
		b := ScanInt()
		if Gcd(a, b) != 1 {
			fmt.Println("Infinite")
		} else {
			fmt.Println("Finite")
		}
	}
}

package main

import (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		a, b := readInt(), readInt()
		g := gcd(a, b)
		if g == 1 {
			print("Finite")
		} else {
			print("Infinite")
		}
	}
}

func gcd(a, b int) int {
	if a > b {
		a, b = b, a
	}
	if a == 1 {
		return int(1)
	}
	if a == 0 {
		return b
	}
	return gcd(a, b%a)
}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

const (
	MAX_INT int64 = math.MaxInt64
	MIN_INT int64 = math.MinInt64
)

func main() {
	for t := ScanInt64(); t > 0; t-- {
		a, b := ScanInt64(), ScanInt64()

		if GCDVAlue(a, b) == 1{
			fmt.Println("FINITE")
		}else{
			fmt.Println("INFINITE")
		}
	}
}

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

var in *bufio.Scanner

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
}

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

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

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxVal := MIN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Min(args ...int64) int64 {
	minVal := MAX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func s(val interface{}) string {
	return fmt.Sprintf("%v", val)
}

func GCDVAlue(a, b int64) int64{
	if b == 0{
		return a
	}
	return GCDVAlue(b, a%b)
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		for a != 0 && b != 0 {
			if a > b {
				a = a % b
			} else {
				b = b % a
			}
		}
		if a == 1 || b == 1 {
			fmt.Println("Finite")
		} else {
			fmt.Println("Infinite")
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	// "math"
	"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 solve() {
	var n int64
	scan(&n)
	if n & 1 != 0 {
		n += 1
		}
		// 15x + 20y + 25z = 2.5*(6x + 8y + 10z)
		// which all even slides can be represented in sum of 6,8,10
	if n <= 6{
		printf("%d\n", 15)
	} else {
		printf("%d\n", n/2*5)
	}
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

	var T, n int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		if n < 6 {
			Fprintln(out, 15)
		} else {
			Fprintln(out, n/6*15+(n%6+1)/2*5)
		}
	}
}

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

package main

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

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

	var T, n int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		if n < 6 {
			Fprintln(out, 15)
		} else {
			if n&1 == 0 {
				Fprintln(out, n/2*5)
			} else {
				ans := n / 6 * 15
				if n %= 6; 0 < n && n <= 2 {
					ans += 5
				} else if n <= 4 {
					ans += 10
				} else {
					ans += 15
				}
				Fprintln(out, ans)
			}
		}
	}
}

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

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		fmt.Println(solve(n))
	}
}

func solve(n int64) int64 {
	//6, 8, 10
	//15, 20, 25

	//25 + 25 + 15
	//20 + 20 + 20
	//15 + 15 + 15 + 15

	dp := make([]int64, 1001)
	dp[0] = 0
	dp[1] = 15

	for j:= 2; j <= 1000; j++ {
		var a, b, c, d int64
		if j >= 6 {
			a = dp[j - 6] + 15
		} else {
			a = 1e9
		}
		if j >= 8 {
			b = dp[j - 8] + 20
		} else {
			b = 1e9
		}
		if j >= 10 {
			c = dp[j - 10] + 25
		} else {
			c = 1e9
		}
		if j < 6 {
			d = 15
		} else {
			d = 1e9
		}

		dp[j] = min(d, min(a, min(b, c)))
	}

	var ans int64

	if n >= 10 {

		if n <= 1000 {
			return dp[n]
		}

		d := n/10
		ans += (d - 9) * 25

		diff := n - (d - 9) * 10

		ans += dp[diff]

	} else {
		if n <= 6 {
			ans += 15
		} else if n == 7 || n == 8  {
			ans += 20

		} else {
			ans += 25
		}
	}

	return ans

}

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

//Problem: https://codeforces.com/contest/1555/problem/A

package main

import "fmt"

func main() {
   var t int
   var n int64
   fmt.Scan(&t)
   for i := 0; i < t; i++ {
       fmt.Scan(&n)
       if (n <= 6) {
           fmt.Println(15)
       } else {
           fmt.Println((n+1) / 2 * 5)
       }
   }
}

package main

import "fmt"

func main(){

	var t int
	fmt.Scanf("%d\n", &t)

	for t>0{

		var n int64
		fmt.Scanf("%d\n", &n)

		var s = n/6
		var rem = n%6
		var m int64=0
		var l int64=0

		if(n<=6){
			s=1
		}else if(rem>=1 && rem<=2){
			if(s>0){s--}
			m++
		}else if(rem>=3 && rem<=4){
			if(s>0){s--}
			l++
		}else if(rem==5){
			s++
		}

		var time int64=(s*15)+(m*20)+(l*25)

		fmt.Printf("%d\n", time)

		t--
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

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

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

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

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

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		if n <= 6 {
			fmt.Println(15)
		} else {
			if n%2 == 0 {
				fmt.Println(int64(5 * n / 2))
			} else {
				fmt.Println(int64(5 * (n + 1) / 2))
			}
		}
	}

}

package main

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

/*
2
9
21
---
25
55
*/

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

	bld := strings.Builder{}

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

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

		n = max(n, 6)

		if n%2 != 0 {
			n++
		}

		ans := n / 2 * 5

		fmt.Fprintln(&bld, ans)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//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 {
	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"
)

func Max(arg ...int64) int64 {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, int64(0)
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		fmt.Fprintln(w, Max(int64(6), n+1)/2*5)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

func Solve(n uint64) uint64 {
	// 6 pieces - 15
	// 8 pieces - 20
	// 10 pieces - 25
	return max(6, n+1) / 2 * 5
}

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

	defer out.Flush()

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

	for ; t > 0; t-- {
		var n uint64
		fmt.Fscan(in, &n)
		fmt.Fprintln(out, Solve(n))
	}
}

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

// 1555A. PizzaForces
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int64
		fmt.Fscan(reader, &n)
		if n < 6 {
			fmt.Println(15)
		} else {
			if n%2 == 1 {
				n++
			}
			fmt.Println(5 * n / 2)
		}
	}
}

package main

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

/*
2
9
21
---
25
55
*/

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

	bld := strings.Builder{}

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

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

		const smallSize = 6
		const mediumSize = 8
		const largeSize = 10

		largeCnt := n / (3 * largeSize) * 3
		rem := n % (3 * largeSize)

		mediumCnt := int64(0)
		smallCnt := int64(0)

		switch rem {
		case 29:
			largeCnt += 3
		case 27, 28:
			largeCnt += 2
			mediumCnt++
		case 25, 26:
			largeCnt++
			mediumCnt += 2
		case 23, 24:
			largeCnt++
			mediumCnt++
			smallCnt++
		case 21, 22:
			largeCnt++
			smallCnt += 2
		case 19, 20:
			largeCnt += 2
		case 17, 18:
			largeCnt++
			mediumCnt++
		case 15, 16:
			mediumCnt += 2
		case 13, 14:
			mediumCnt++
			smallCnt++
		case 11, 12:
			smallCnt += 2
		case 10:
			largeCnt++
		case 9:
			largeCnt++
		case 7, 8:
			mediumCnt++
		case 1, 2, 3, 4, 5, 6:
			smallCnt++
		}

		const smallTime = 15
		const mediumTime = 20
		const largeTime = 25

		fmt.Fprintln(&bld, smallCnt*smallTime+mediumCnt*mediumTime+largeCnt*largeTime)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//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 {
	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

/*
2
9
21
---
25
55
*/

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

	bld := strings.Builder{}

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

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

		const smallSize = 6
		const mediumSize = 8
		const largeSize = 10

		largeCnt := n / (3 * largeSize) * 3
		rem := n % (2 * largeSize)

		mediumCnt := int64(0)
		smallCnt := int64(0)

		switch rem {
		case 29:
			largeCnt += 3
		case 27, 28:
			largeCnt += 2
			mediumCnt++
		case 25, 26:
			largeCnt++
			mediumCnt += 2
		case 23, 24:
			largeCnt++
			mediumCnt++
			smallCnt++
		case 21, 22:
			largeCnt++
			smallCnt += 2
		case 19, 20:
			largeCnt += 2
		case 17, 18:
			largeCnt++
			mediumCnt++
		case 15, 16:
			mediumCnt += 2
		case 13, 14:
			mediumCnt++
			smallCnt++
		case 11, 12:
			smallCnt += 2
		case 10:
			largeCnt++
		case 9:
			largeCnt++
		case 7, 8:
			mediumCnt++
		case 1, 2, 3, 4, 5, 6:
			smallCnt++
		}

		const smallTime = 15
		const mediumTime = 20
		const largeTime = 25

		fmt.Fprintln(&bld, smallCnt*smallTime+mediumCnt*mediumTime+largeCnt*largeTime)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//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 {
	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

/*
1
9
---

*/

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

	bld := strings.Builder{}

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

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

		const smallSize = 6
		const mediumSize = 8
		const largeSize = 10

		largeCnt := n / (2 * largeSize) * 2
		rem := n % (2 * largeSize)

		mediumCnt := int64(0)
		smallCnt := int64(0)

		switch rem {
		case 19:
			largeCnt += 2
		case 17, 18:
			largeCnt++
			mediumCnt++
		case 15, 16:
			mediumCnt += 2
		case 13, 14:
			mediumCnt++
			smallCnt++
		case 11, 12:
			smallCnt += 2
		case 10:
			largeCnt++
		case 9:
			largeCnt++
		case 7, 8:
			mediumCnt++
		case 1, 2, 3, 4, 5, 6:
			smallCnt++
		}

		const smallTime = 15
		const mediumTime = 20
		const largeTime = 25

		fmt.Fprintln(&bld, smallCnt*smallTime+mediumCnt*mediumTime+largeCnt*largeTime)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//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 {
	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

/*

 */

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

	bld := strings.Builder{}

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

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

		const smallSize = 6
		const mediumSize = 8
		const largeSize = 10

		largeCnt := n / (2 * largeSize) * 2
		rem := n % (2 * largeSize)

		mediumCnt := int64(0)
		smallCnt := int64(0)

		switch rem {
		case 19:
			largeCnt += 2
		case 17, 18:
			largeCnt++
			mediumCnt++
		case 15, 16:
			mediumCnt += 2
		case 13, 14:
			mediumCnt++
			smallCnt++
		case 11, 12:
			smallCnt += 2
		case 10:
			largeCnt++
		case 9:
			smallCnt += 2
		case 7, 8:
			mediumCnt++
		case 1, 2, 3, 4, 5, 6:
			smallCnt++
		}

		const smallTime = 15
		const mediumTime = 20
		const largeTime = 25

		fmt.Fprintln(&bld, smallCnt*smallTime+mediumCnt*mediumTime+largeCnt*largeTime)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//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 {
	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"
	"io"
	"os"
)

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

func Solve(n int) int {
	// 6 pieces - 15
	// 8 pieces - 20
	// 10 pieces - 25
	return max(6, n+1) / 2 * 5
}

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

	defer out.Flush()

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

	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		fmt.Fprintln(out, Solve(n))
	}
}

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

package main

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

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

func Solve(n int) int {
	// 6 pieces - 15
	// 8 pieces - 20
	// 10 pieces - 25
	return int(max(6, n+1)) / 2 * 5
}

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

	defer out.Flush()

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

	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		fmt.Fprintln(out, Solve(n))
	}
}

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

// 1555A. PizzaForces
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		if n < 6 {
			fmt.Println(15)
		} else {
			if n%2 == 1 {
				n++
			}
			fmt.Println(5 * n / 2)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"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 solve() {
	var n int64
	scan(&n)
	if n & 1 != 0 {
		n += 1
		}
		// 15x + 20y + 25z = 2.5*(6x + 8y + 10z)
		// which all even slides can be represented in sum of 6,8,10
	printf("%d\n",int64(math.Max(6,float64(n))*2.5))
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		fmt.Println(solve(n))
	}
}

func solve(n int64) int64 {
	//6, 8, 10
	//15, 20, 25

	//25 + 25 + 15
	//20 + 20 + 20
	//15 + 15 + 15 + 15

	dp := make([]int64, 1001)
	dp[0] = 0
	dp[1] = 15

	for j:= 2; j <= 1000; j++ {
		var a, b, c, d int64
		if j >= 6 {
			a = dp[j - 6] + 15
		} else {
			a = 1e9
		}
		if j >= 8 {
			b = dp[j - 8] + 20
		} else {
			b = 1e9
		}
		if j >= 10 {
			c = dp[j - 10] + 25
		} else {
			c = 1e9
		}
		if j < 6 {
			d = 15
		} else {
			d = 1e9
		}

		dp[j] = min(d, min(a, min(b, c)))
	}

	var ans int64

	if n >= 10 {

		if n <= 1000 {
			return dp[n]
		}

		d := n/10
		ans += (d - 9) * 25

		diff := n - (d - 9) * 10

		ans += dp[diff]

	} else {
		if n <= 6 {
			ans += 15
		} else if n == 7 || n == 8  {
			ans += 20

		} else {
			ans += 30
		}
	}

	return ans

}

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


package main

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

// 需要考虑到所有的input都要考虑进去
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	casesstr := scanner.Text()
	cases, _ := strconv.Atoi(casesstr)
	results := make([]bool, cases)
	for i := 0; i < cases; i++ {
		scanner.Scan()
		arrstr := scanner.Text()
		arr := strings.Split(arrstr, " ")
		customers, _ := strconv.ParseInt(arr[0], 10, 64)
		currentT, _ := strconv.ParseInt(arr[1], 10, 64)
		currentTime := int64(0)
		rangel, ranger := currentT, currentT
		flag := true
		for j := int64(0); j < customers; j++ {
			scanner.Scan()
			text := scanner.Text()
			arr = strings.Split(text, " ")
			ctime, _ := strconv.ParseInt(arr[0], 10, 64)
			clowerT, _ := strconv.ParseInt(arr[1], 10, 64)
			chigherT, _ := strconv.ParseInt(arr[2], 10, 64)
			rangel -= ctime - currentTime
			ranger += ctime - currentTime
			currentTime = ctime
			// fmt.Println(arr, rangel, ranger)
			if ranger < clowerT || rangel > chigherT {
				flag = false
			}
			if rangel < clowerT {
				rangel = clowerT
			}
			if ranger > chigherT {
				ranger = chigherT
			}
		}
		results[i] = flag
	}
	for i:=0;i<len(results)-1;i++ {
		if results[i] {
			fmt.Println("yes")
		}else {
			fmt.Println("no")
		}
	}
	if results[len(results)-1] {
		fmt.Print("yes")
	}else {
		fmt.Print("no")
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}
	type pair struct{ t, down, up int64 }

	solve := func() (ans bool) {
		var n, initT, t, down, up int64
		Fscan(in, &n, &initT)
		a := make([]pair, n)
		b := make([]pair, 0, n)
		for i := range a {
			Fscan(in, &t, &down, &up)
			a[i] = pair{t, down, up}
			if i == 0 || t > a[i-1].t {
				b = append(b, a[i])
			} else {
				b[len(b)-1].down = max(b[len(b)-1].down, down)
				b[len(b)-1].up = min(b[len(b)-1].up, up)
			}
		}

		down, up = initT, initT
		for i, p := range b {
			if p.down > p.up {
				return false
			}
			if i == 0 {
				down -= p.t
				up += p.t
			} else {
				down -= p.t - b[i-1].t
				up += p.t - b[i-1].t
			}
			if down > p.up || up < p.down {
				return false
			}
			down = max(down, p.down)
			up = min(up, p.up)
		}
		return true
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"} [solve()])
	}
}

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

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}

	type pair struct{ t, down, up int64 }
	solve := func() (ans bool) {
		var n, initT int64
		Fscan(in, &n, &initT)
		a := make([]pair, n)
		b := make([]pair, 0, n)
		//b = append(b, pair{0,initT,initT})
		for i := range a {
			Fscan(in, &a[i].t, &a[i].down, &a[i].up)
		}
		for i, p := range a {
			if i == 0 || p.t > a[i-1].t {
				b = append(b, p)
			} else {
				b[len(b)-1].down = max(b[len(b)-1].down, p.down)
				b[len(b)-1].up = min(b[len(b)-1].up, p.up)
			}
		}

		down, up := initT, initT
		for i, p := range b {
			if p.down > p.up {
				return false
			}

			if i == 0 {
				down -= p.t
				up += p.t
			} else {
				down -= p.t-b[i-1].t
				up += p.t-b[i-1].t
			}
			if down <= p.up && up >= p.down {
				down = max(down, p.down)
				up = min(up, p.up)
			} else {
				return false
			}
		}

		return true
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"} [solve()])
	}
}

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

package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
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 }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	tests := scanInt()
	for q := 0; q < tests; q++ {
		n := scanInt()
		m := scanInt()
		pre := 0
		templ := m
		temph := m
		f := true
		for i := 0; i < n; i++ {
			t := scanInt()
			l := scanInt()
			h := scanInt()

			d := t - pre
			maxh := temph+d
			minl := templ-d

			temph = min(h,maxh)
			templ = max(l,minl)

			if temph <templ {
				f = false
			}

			pre = t
		}
		if f {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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 n, t, tm, l, h, m int64

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

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

		scanf("%d %d\n", &n, &m)

		mn, mx, last, td := m, m, int64(0), int64(0)

		flag := true

		for j := 0; j < int(n); j++ {
			scanf("%d %d %d\n", &tm, &l, &h)

			if !flag {
				continue
			}

			td = tm - last

			mn = mn - td
			mx = mx + td

			if mx < l || mn > h {
				printf("NO\n")
				flag = false

			}

			if l > mn {
				mn = l
			}
			if h < mx {
				mx = h
			}

			last = tm
		}
		if flag {
			printf("YES\n")
		}

	}

}

package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
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 }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	tests := scanInt()
	L: for q := 0; q < tests; q++ {
		n := scanInt()
		m := scanInt()
		pre := 0
		templ := m
		temph := m
		for i := 0; i < n; i++ {
			t := scanInt()
			l := scanInt()
			h := scanInt()

			d := t - pre
			maxh := temph+d
			minl := templ-d

			temph = min(h,maxh)
			templ = max(l,minl)

			if temph <templ {
				fmt.Println("NO")
				continue L
			}

			pre = t
		}
		fmt.Println("YES")
	}
}

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 n, t, tm, l, h, m int

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

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

		scanf("%d %d\n", &n, &m)

		mn, mx, last, td := m, m, 0, 0

		flag := true

		for j := 0; j < n; j++ {
			scanf("%d %d %d\n", &tm, &l, &h)

			td = tm - last

			mn = mn - td
			mx = mx + td

			if mx < l || mn > h {
				printf("NO\n")
				flag = false
				break
			}

			if l > mn {
				mn = l
			}
			if h < mx {
				mx = h
			}

			last = tm
		}
		if flag {
			printf("YES\n")
		}

	}

}

package main

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

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

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

func main() {
	defer writer.Flush()

	var n, t, tm, l, h, m int64

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

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

		scanf("%d %d\n", &n, &m)

		mn, mx, last, td := m, m, int64(0), int64(0)

		flag := true

		for j := 0; j < int(n); j++ {
			scanf("%d %d %d\n", &tm, &l, &h)

			td = tm - last

			mn = mn - td
			mx = mx + td

			if mx < l || mn > h {
				printf("NO\n")
				flag = false
				break
			}

			if l > mn {
				mn = l
			}
			if h < mx {
				mx = h
			}

			last = tm
		}
		if flag {
			printf("YES\n")
		}

	}

}

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}

	type pair struct{ t, down, up int64 }
	solve := func() (ans bool) {
		var n, initT int64
		Fscan(in, &n, &initT)
		a := make([]pair, n)
		b := make([]pair, 0, n)
		//b = append(b, pair{0,initT,initT})
		for i := range a {
			Fscan(in, &a[i].t, &a[i].down, &a[i].up)
		}
		for i, p := range a {
			if i == 0 || p.t > a[i-1].t {
				b = append(b, p)
			} else {
				b[len(b)-1].down = max(b[len(b)-1].down, p.down)
				b[len(b)-1].up = min(b[len(b)-1].up, p.up)
			}
		}

		down, up := initT, initT
		for i, p := range b {
			if i == 0 {
				down -= p.t
				up += p.t
			} else {
				down -= p.t-b[i-1].t
				up += p.t-b[i-1].t
			}
			if down <= p.up && up >= p.down {
				down = max(down, p.down)
				up = min(up, p.up)
			} else {
				return false
			}
		}

		return true
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"} [solve()])
	}
}

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

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	casesstr := scanner.Text()
	cases, _ := strconv.Atoi(casesstr)
	for i := 0; i < cases; i++ {
		scanner.Scan()
		arrstr := scanner.Text()
		arr := strings.Split(arrstr, " ")
		customers, _ := strconv.ParseInt(arr[0], 10, 64)
		currentT, _ := strconv.ParseInt(arr[1], 10, 64)
		currentTime := int64(0)
		rangel, ranger := currentT, currentT
		flag := true
		for i := int64(0); i < customers; i++ {
			scanner.Scan()
			text := scanner.Text()
			arr = strings.Split(text, " ")
			ctime, _ := strconv.ParseInt(arr[0], 10, 64)
			clowerT, _ := strconv.ParseInt(arr[1], 10, 64)
			chigherT, _ := strconv.ParseInt(arr[2], 10, 64)
			rangel -= ctime - currentTime
			ranger += ctime - currentTime
			currentTime = ctime
			// fmt.Println(arr, rangel, ranger)
			if ranger < clowerT || rangel > chigherT {
				flag = false
				break
			}
			if rangel < clowerT {
				rangel = clowerT
			}
			if ranger > chigherT {
				ranger = chigherT
			}
		}
		if flag {
			fmt.Println("yes")
		}else {
			fmt.Print("no")
		}
	}
}


package main

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

func main() {
	n := getInt()
	k := getInt()
	a := getNint(n)
	b := getNint(n)

	ispossible := func(c int64) bool {
		k := k
		for i := 0; i < n; i++ {
			q := int64(a[i])*c - int64(b[i])
			if q > int64(k) {
				return false
			}
			if q > 0 {
				k -= int(q)
			}
		}
		return true
	}

	fmt.Println(bin_search_max64(ispossible, 0, 2000000001))
}

// largest argument, for which f(arg) is true
// logic function should be non-increasing
func bin_search_max64(f func(int64) bool, lo, up int64) int64 {
	var mid, step int64
	const eps = 1
	lo--
	cnt := up - lo
	for cnt >= eps {
		step = cnt / 2
		mid = up - step
		if !f(mid) {
			up = mid - eps
			cnt -= step + eps
		} else {
			cnt = step
		}
	}
	return up
}

type Input struct {
	*bufio.Scanner
}

var globalInput = wrapStdin()

func wrapStdin() Input {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Input{Scanner: sc}
}
func getInt() int {
	globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x
}
func getIntOk() (int, bool) {
	ok := globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x, ok
}
func getNint(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = getInt()
	}
	return v
}
func getVint(v []int) bool {
	var ok bool
	for i := 0; i < len(v); i++ {
		v[i], ok = getIntOk()
	}
	return ok
}
func getWord() string {
	globalInput.Scan()
	return globalInput.Text()
}
func getWordOk() (string, bool) {
	ok := globalInput.Scan()
	return globalInput.Text(), ok
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func minStr(a, b string) string {
	if a < b {
		return a
	}
	return b
}
func maxStr(a, b string) string {
	if a < b {
		return b
	}
	return a
}
func remin(a *int, b int) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax(a *int, b int) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func remin64(a *int64, b int64) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax64(a *int64, b int64) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func reminStr(a *string, b string) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remaxStr(a *string, b string) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

type (
	FLess    func(i, j int) bool
	FSwap    func(i, j int)
	wrapSort struct {
		Length int
		FLess
		FSwap
	}
)

func (w *wrapSort) Len() int           { return w.Length }
func (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }
func (w *wrapSort) Swap(i, j int)      { w.FSwap(i, j) }
func wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {
	sort.Sort(&wrapSort{length, fless, fswap})
}

package main

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

var N, K int

func CheckBake(cookie int64, magic int64, A []int, B []int) bool {
	for i := 0; i < N; i++ {
		need := cookie * int64(A[i])
		rest := int64(B[i]) - need
		if rest < 0 {
			magic += int64(rest)
		}
		if magic < 0 {
			return false
		}
	}
	return true
}

func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()
	K = fsc.NextInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = fsc.NextInt()
	}
	for i := 0; i < N; i++ {
		B[i] = fsc.NextInt()
	}
	left := int64(0)
	right := int64(10000000)
	for right-left > 1 {
		med := (right + left) / 2
		flag := CheckBake(med, int64(K), A, B)

		if flag { //bake
			left = med
		} else {
			right = med
		}
	}
	fmt.Println(left)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

// Using binary search to validate the "answers" within lg(n) times.
package main

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

func main() {
	n, k, scanner := 0, 0, bufio.NewScanner(os.Stdin)
	fmt.Scan(&n, &k)
	scanner.Split(bufio.ScanWords)
	a, b := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		b[i], _ = strconv.Atoi(scanner.Text())
	}

	answer, l, r := -1, 0, 2000
	for l <= r {
		mid, match, newK := (l+r)/2, false, k
		for i := 0; i < len(a); i++ {
			extra := a[i]*mid - b[i]
			if extra > newK {
				break
			} else if extra > 0 {
				newK -= extra
			}
			if i == (len(a) - 1) {
				match = true
			}
		}
		if match {
			l = mid + 1
			answer = mid
		} else {
			r = mid - 1
		}
	}

	fmt.Println(answer)
}

package main

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

var N, K int

func CheckBake(cookie int, magic int, A []int, B []int) bool {
	for i := 0; i < N; i++ {
		need := cookie * A[i]
		rest := B[i] - need
		if rest < 0 {
			magic += rest
		}
		if magic < 0 {
			return false
		}
	}
	return true
}

func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()
	K = fsc.NextInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = fsc.NextInt()
	}
	for i := 0; i < N; i++ {
		B[i] = fsc.NextInt()
	}
	left := 0
	right := 1009
	for right-left > 1 {
		med := (right + left) / 2
		flag := CheckBake(med, K, A, B)

		if flag { //bake
			left = med
		} else {
			right = med
		}
	}
	fmt.Println(left)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var N, K int

func CheckBake(cookie int, magic int, A []int, B []int) bool {
	for i := 0; i < N; i++ {
		need := cookie * A[i]
		rest := B[i] - need
		if rest < 0 {
			magic += rest
		}
		if magic < 0 {
			return false
		}
	}
	return true
}

func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()
	K = fsc.NextInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = fsc.NextInt()
	}
	for i := 0; i < N; i++ {
		B[i] = fsc.NextInt()
	}
	left := 0
	right := 1145141919
	for right-left > 1 {
		med := (right + left) / 2
		flag := CheckBake(med, K, A, B)

		if flag { //bake
			left = med
		} else {
			right = med
		}
	}
	fmt.Println(left)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}