Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cartesian coordinates. The sides of the city should be parallel to coordinate axes. The map contains mines with valuable resources, located at some points with integer coordinates. The sizes of mines are relatively small, i.e. they can be treated as points. The city should be built in such a way that all the mines are inside or on the border of the city square. Building a city takes large amount of money depending on the size of the city, so you have to build the city with the minimum area. Given the positions of the mines find the minimum possible area of the city.

The first line of the input contains number n — the number of mines on the map (2 ≤ n ≤ 1000). Each of the next n lines contains a pair of integers xi and yi — the coordinates of the corresponding mine ( - 109 ≤ xi, yi ≤ 109). All points are pairwise distinct.

Print the minimum area of the city that can cover all the mines with valuable resources.

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 "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 (
    "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))
}


You are given an undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. Your task is to find the number of connected components which are cycles.Here are some definitions of graph theory.An undirected graph consists of two sets: set of nodes (called vertices) and set of edges. Each edge connects a pair of vertices. All edges are bidirectional (i.e. if a vertex $$$a$$$ is connected with a vertex $$$b$$$, a vertex $$$b$$$ is also connected with a vertex $$$a$$$). An edge can't connect vertex with itself, there is at most one edge between a pair of vertices.Two vertices $$$u$$$ and $$$v$$$ belong to the same connected component if and only if there is at least one path along edges connecting $$$u$$$ and $$$v$$$.A connected component is a cycle if and only if its vertices can be reordered in such a way that:  the first vertex is connected with the second vertex by an edge,  the second vertex is connected with the third vertex by an edge,  ...  the last vertex is connected with the first vertex by an edge,  all the described edges of a cycle are distinct. A cycle doesn't contain any other edges except described above. By definition any cycle contains three or more vertices.    There are $$$6$$$ connected components, $$$2$$$ of them are cycles: $$$[7, 10, 16]$$$ and $$$[5, 11, 9, 15]$$$.

The first line contains two integer numbers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le m \le 2 \cdot 10^5$$$) — number of vertices and edges. The following $$$m$$$ lines contains edges: edge $$$i$$$ is given as a pair of vertices $$$v_i$$$, $$$u_i$$$ ($$$1 \le v_i, u_i \le n$$$, $$$u_i \ne v_i$$$). There is no multiple edges in the given graph, i.e. for each pair ($$$v_i, u_i$$$) there no other pairs ($$$v_i, u_i$$$) and ($$$u_i, v_i$$$) in the list of edges.

Print one integer — the number of connected components which are also cycles.

NoteIn the first example only component $$$[3, 4, 5]$$$ is also a cycle.The illustration above corresponds to the second example.

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

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


This is an interactive problem. The only difference between the easy and hard version is the limit on number of questions.There are $$$n$$$ players labelled from $$$1$$$ to $$$n$$$. It is guaranteed that $$$n$$$ is a multiple of $$$3$$$.Among them, there are $$$k$$$ impostors and $$$n-k$$$ crewmates. The number of impostors, $$$k$$$, is not given to you. It is guaranteed that $$$\frac{n}{3} < k < \frac{2n}{3}$$$.In each question, you can choose three distinct integers $$$a$$$, $$$b$$$, $$$c$$$ ($$$1 \le a, b, c \le n$$$) and ask: "Among the players labelled $$$a$$$, $$$b$$$ and $$$c$$$, are there more impostors or more crewmates?" You will be given the integer $$$0$$$ if there are more impostors than crewmates, and $$$1$$$ otherwise.Find the number of impostors $$$k$$$ and the indices of players that are impostors after asking at most $$$2n$$$ questions.The jury is adaptive, which means the indices of impostors may not be fixed beforehand and can depend on your questions. It is guaranteed that there is at least one set of impostors which fulfills the constraints and the answers to your questions at any time.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first and only line of each test case contains a single integer $$$n$$$ ($$$6 \le n < 10^4$$$, $$$n$$$ is a multiple of $$$3$$$) — the number of players. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^4$$$.

NoteExplanation for example interaction (note that this example only exists to demonstrate the interaction procedure and does not provide any hint for the solution):For the first test case:Question "? 1 2 3" returns $$$0$$$, so there are more impostors than crewmates among players $$$1$$$, $$$2$$$ and $$$3$$$.Question "? 3 4 5" returns $$$1$$$, so there are more crewmates than impostors among players $$$3$$$, $$$4$$$ and $$$5$$$.Outputting "! 3 4 1 2" means that one has found all the impostors, by some miracle. There are $$$k = 3$$$ impostors. The players who are impostors are players $$$4$$$, $$$1$$$ and $$$2$$$.For the second test case:Question "? 7 1 9" returns $$$1$$$, so there are more crewmates than impostors among players $$$7$$$, $$$1$$$ and $$$9$$$.Outputting "! 4 2 3 6 8" means that one has found all the impostors, by some miracle. There are $$$k = 4$$$ impostors. The players who are impostors are players $$$2$$$, $$$3$$$, $$$6$$$ and $$$8$$$.

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 (
	"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("!")
	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()
	}
}


You are given a matrix, consisting of $$$n$$$ rows and $$$m$$$ columns. The rows are numbered top to bottom, the columns are numbered left to right.Each cell of the matrix can be either free or locked.Let's call a path in the matrix a staircase if it:   starts and ends in the free cell;  visits only free cells;  has one of the two following structures:   the second cell is $$$1$$$ to the right from the first one, the third cell is $$$1$$$ to the bottom from the second one, the fourth cell is $$$1$$$ to the right from the third one, and so on;  the second cell is $$$1$$$ to the bottom from the first one, the third cell is $$$1$$$ to the right from the second one, the fourth cell is $$$1$$$ to the bottom from the third one, and so on.  In particular, a path, consisting of a single cell, is considered to be a staircase.Here are some examples of staircases:  Initially all the cells of the matrix are free.You have to process $$$q$$$ queries, each of them flips the state of a single cell. So, if a cell is currently free, it makes it locked, and if a cell is currently locked, it makes it free.Print the number of different staircases after each query. Two staircases are considered different if there exists such a cell that appears in one path and doesn't appear in the other path.

The first line contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000$$$; $$$1 \le q \le 10^4$$$) — the sizes of the matrix and the number of queries. Each of the next $$$q$$$ lines contains two integers $$$x$$$ and $$$y$$$ ($$$1 \le x \le n$$$; $$$1 \le y \le m$$$) — the description of each query.

Print $$$q$$$ integers — the $$$i$$$-th value should be equal to the number of different staircases after $$$i$$$ queries. Two staircases are considered different if there exists such a cell that appears in one path and doesn't appear in the other path.

package main

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

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

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

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

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

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

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

type Solver struct {
	n    int
	m    int
	grid [][]*Cell
	sum  int64
}

type Cell struct {
	free  bool
	down  int64
	right int64
}

func (c *Cell) Staircases() int64 {
	if !c.free {
		return 0
	}
	return 1 + c.down + c.right
}

func (s *Solver) init() {
	s.grid = make([][]*Cell, s.n)
	for i := range s.grid {
		s.grid[i] = make([]*Cell, s.m)
	}
	q := [][2]int{{s.n - 1, s.m - 1}}
	for len(q) > 0 {
		e := q[0]
		q = q[1:]
		if s.grid[e[0]][e[1]] != nil {
			continue
		}
		down := int64(0)
		right := int64(0)
		if e[0]+1 < s.n {
			down = 1 + s.grid[e[0]+1][e[1]].right
		}
		if e[1]+1 < s.m {
			right = 1 + s.grid[e[0]][e[1]+1].down
		}
		s.grid[e[0]][e[1]] = &Cell{
			free:  true,
			down:  down,
			right: right,
		}
		s.sum += 1 + down + right
		if e[0]-1 >= 0 {
			q = append(q, [2]int{e[0] - 1, e[1]})
		}
		if e[1]-1 >= 0 {
			q = append(q, [2]int{e[0], e[1] - 1})
		}
	}
}

func (s *Solver) String() string {
	ret := ""
	for i := range s.grid {
		for j := range s.grid[i] {
			ret += fmt.Sprintf("%v", *s.grid[i][j])
		}
		ret += "\n"
	}
	return ret
}

func (s *Solver) Solve(x, y int) int64 {
	initStaircases := s.grid[x][y].Staircases()
	if s.grid[x][y].free {
		s.grid[x][y].free = false
		s.grid[x][y].down = 0
		s.grid[x][y].right = 0
	} else {
		s.grid[x][y].free = true
		if x+1 < s.n {
			if !s.grid[x+1][y].free {
				s.grid[x][y].down = 0
			} else {
				s.grid[x][y].down = s.grid[x+1][y].right + 1
			}
		}
		if y+1 < s.m {
			if !s.grid[x][y+1].free {
				s.grid[x][y].right = 0
			} else {
				s.grid[x][y].right = s.grid[x][y+1].down + 1
			}
		}
	}
	currStaircases := s.grid[x][y].Staircases()
	s.sum += currStaircases - initStaircases
	for x >= 0 || y >= 0 {
		s.update(x, y)
		s.update(x-1, y)
		s.update(x, y-1)
		x--
		y--
	}
	return s.sum
}

func (s *Solver) update(x, y int) {
	if x < 0 || y < 0 || x >= s.n || y >= s.m || !s.grid[x][y].free {
		return
	}
	initStaircases := s.grid[x][y].Staircases()
	if x+1 < s.n {
		if !s.grid[x+1][y].free {
			s.grid[x][y].down = 0
		} else {
			s.grid[x][y].down = s.grid[x+1][y].right + 1
		}
	}
	if y+1 < s.m {
		if !s.grid[x][y+1].free {
			s.grid[x][y].right = 0
		} else {
			s.grid[x][y].right = s.grid[x][y+1].down + 1
		}
	}
	currStaircases := s.grid[x][y].Staircases()
	s.sum += currStaircases - initStaircases
}

func main() {
	defer writer.Flush()
	n := _int()
	m := _int()
	s := &Solver{n: n, m: m}
	s.init()
	for q := _int(); q > 0; q-- {
		x := _int() - 1
		y := _int() - 1
		printf("%d\n", s.Solve(x, y))
	}
}


Consider the set of all nonnegative integers: $$${0, 1, 2, \dots}$$$. Given two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^4$$$). We paint all the numbers in increasing number first we paint $$$0$$$, then we paint $$$1$$$, then $$$2$$$ and so on.Each number is painted white or black. We paint a number $$$i$$$ according to the following rules:    if $$$i = 0$$$, it is colored white;   if $$$i \ge a$$$ and $$$i - a$$$ is colored white, $$$i$$$ is also colored white;   if $$$i \ge b$$$ and $$$i - b$$$ is colored white, $$$i$$$ is also colored white;   if $$$i$$$ is still not colored white, it is colored black. In this way, each nonnegative integer gets one of two colors.For example, if $$$a=3$$$, $$$b=5$$$, then the colors of the numbers (in the order from $$$0$$$) are: white ($$$0$$$), black ($$$1$$$), black ($$$2$$$), white ($$$3$$$), black ($$$4$$$), white ($$$5$$$), white ($$$6$$$), black ($$$7$$$), white ($$$8$$$), white ($$$9$$$), ...Note that:    It is possible that there are infinitely many nonnegative integers colored black. For example, if $$$a = 10$$$ and $$$b = 10$$$, then only $$$0, 10, 20, 30$$$ and any other nonnegative integers that end in $$$0$$$ when written in base 10 are white. The other integers are colored black.   It is also possible that there are only finitely many nonnegative integers colored black. For example, when $$$a = 1$$$ and $$$b = 10$$$, then there is no nonnegative integer colored black at all. Your task is to determine whether or not the number of nonnegative integers colored black is infinite.If there are infinitely many nonnegative integers colored black, simply print a line containing "Infinite" (without the quotes). Otherwise, print "Finite" (without the quotes).

The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then $$$t$$$ lines follow, each line contains two space-separated integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^4$$$).

For each test case, print one line containing either "Infinite" or "Finite" (without the quotes). Output is case-insensitive (i.e. "infinite", "inFiNite" or "finiTE" are all valid answers).

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"
	"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 (
	"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 "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")
		}
	}
}


PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of $$$6$$$ slices, medium ones consist of $$$8$$$ slices, and large pizzas consist of $$$10$$$ slices each. Baking them takes $$$15$$$, $$$20$$$ and $$$25$$$ minutes, respectively.Petya's birthday is today, and $$$n$$$ of his friends will come, so he decided to make an order from his favorite pizzeria. Petya wants to order so much pizza that each of his friends gets at least one slice of pizza. The cooking time of the order is the total baking time of all the pizzas in the order.Your task is to determine the minimum number of minutes that is needed to make pizzas containing at least $$$n$$$ slices in total. For example:   if $$$12$$$ friends come to Petya's birthday, he has to order pizzas containing at least $$$12$$$ slices in total. He can order two small pizzas, containing exactly $$$12$$$ slices, and the time to bake them is $$$30$$$ minutes;  if $$$15$$$ friends come to Petya's birthday, he has to order pizzas containing at least $$$15$$$ slices in total. He can order a small pizza and a large pizza, containing $$$16$$$ slices, and the time to bake them is $$$40$$$ minutes;  if $$$300$$$ friends come to Petya's birthday, he has to order pizzas containing at least $$$300$$$ slices in total. He can order $$$15$$$ small pizzas, $$$10$$$ medium pizzas and $$$13$$$ large pizzas, in total they contain $$$15 \cdot 6 + 10 \cdot 8 + 13 \cdot 10 = 300$$$ slices, and the total time to bake them is $$$15 \cdot 15 + 10 \cdot 20 + 13 \cdot 25 = 750$$$ minutes;  if only one friend comes to Petya's birthday, he can order a small pizza, and the time to bake it is $$$15$$$ minutes.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. Each testcase consists of a single line that contains a single integer $$$n$$$ ($$$1 \le n \le 10^{16}$$$) — the number of Petya's friends.

For each testcase, print one integer — the minimum number of minutes that is needed to bake pizzas containing at least $$$n$$$ slices in total.

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

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)

		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
}