Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (xi, yi) and moves with a speed vi. Consider that each of n drivers will move directly to Vasiliy and with a maximum possible speed. Compute the minimum time when Vasiliy will get in any of Beru-taxi cars.

The first line of the input contains two integers a and b ( - 100 ≤ a, b ≤ 100) — coordinates of Vasiliy's home. The second line contains a single integer n (1 ≤ n ≤ 1000) — the number of available Beru-taxi cars nearby.  The i-th of the following n lines contains three integers xi, yi and vi ( - 100 ≤ xi, yi ≤ 100, 1 ≤ vi ≤ 100) — the coordinates of the i-th car and its speed. It's allowed that several cars are located at the same point. Also, cars may be located at exactly the same point where Vasiliy lives.

Print a single real value — the minimum time Vasiliy needs to get in any of the Beru-taxi cars. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.  Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

NoteIn the first sample, first taxi will get to Vasiliy in time 2, and second will do this in time 1, therefore 1 is the answer.In the second sample, cars 2 and 3 will arrive simultaneously.

package main

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

import "math"

var in *bufio.Scanner
var out *bufio.Writer

var a, b, x, y, v, res float64
var n int

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

	in.Split(bufio.ScanWords)
	defer out.Flush()

	in.Scan()
	a, _ = strconv.ParseFloat(in.Text(), 64)

	in.Scan()
	b, _ = strconv.ParseFloat(in.Text(), 64)

	in.Scan()
	n, _ = strconv.Atoi(in.Text())

	res = float64(1000000000000000.0)

	for i := 1; i <= n; i++ {
		in.Scan()
		x, _ = strconv.ParseFloat(in.Text(), 64)
		in.Scan()
		y, _ = strconv.ParseFloat(in.Text(), 64)
		in.Scan()
		v, _ = strconv.ParseFloat(in.Text(), 64)

		dx := x - a
		dy := y - b
		d := dx*dx + dy*dy

		t := math.Sqrt(d) / v
		if t < res {
			res = t
		}
	}

	out.WriteString(strconv.FormatFloat(res, 'f', -1, 64))
	out.WriteByte('\n')
}

package main

import(
    "fmt"
    "math"
)

func main(){
	var a, b float64
	var n int
	var minDist float64 = 99999999.0
	fmt.Scanf("%f %f %f\n", &a, &b)
	fmt.Scanf("%d\n", &n)
	for i:=0; i<n; i++{
		var x, y, v float64
		fmt.Scanf("%f %f %f\n", &x, &y, &v)
		minDist = math.Min(minDist, math.Sqrt((x-a)*(x-a) + (y-b)*(y-b))/v)
	}
	fmt.Println(minDist)
}

// http://codeforces.com/problemset/problem/710/A

package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var x, y, n int

	fmt.Scanln(&x, &y)
	fmt.Scanln(&n)

	times := make([]float64, n)

	for i := 0; i < n; i++ {
		var x1, y1, v1 int
		fmt.Scanln(&x1, &y1, &v1)

		times[i] = math.Sqrt(float64((x - x1)*(x - x1) + (y - y1)*(y - y1))) / float64(v1)
	}

	sort.Float64s(times)
	fmt.Println(times[0])
}

package main

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

func getLine(s *bufio.Scanner, n int) []int {
    s.Scan()
    ab := strings.Fields(s.Text())
    a := make([]int,n)
    for i:=0; i<n; i++ {
        a[i], _ = strconv.Atoi(ab[i])
    }
    return a
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    a := getLine(scanner,2)
    n := getLine(scanner,1)
    min := math.MaxFloat64
    for i := 0; i < n[0]; i++ {
        b := getLine(scanner,3)
        x1,y1,x2,y2,v := float64(a[0]), float64(a[1]), float64(b[0]), float64(b[1]), float64(b[2])
        d := math.Sqrt(math.Pow(x1-x2,2.0) + math.Pow(y1-y2,2.0))/v
        if  d < min {
            min = d
        }
    }
    fmt.Printf("%.20f",min)
}

package main
import (
	"fmt"
	"io"
	"os"
	"bufio"
	"strings"
	"strconv"
	"math"
)

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

	// Determine the home coordinates
	line, err := reader.ReadString('\n')
	if err != nil && err != io.EOF {
		os.Exit(3)
	}

	line = strings.TrimSpace(line)
	home := strings.Fields(line)
	a, _ := strconv.Atoi(home[0])
	b, _ := strconv.Atoi(home[1])

	// Determine the number of taxis available
	line2, err := reader.ReadString('\n')
	if err != nil && err != io.EOF {
		os.Exit(3)
	}

	line2 = strings.TrimSpace(line2)
	n, _ := strconv.Atoi(line2)

	// for each taxi, calculate distance and keep track of min arrival time
	var minimumArrivalTime float64

	for i := 0; i < n; i++ {
		taxiLine, err := reader.ReadString('\n')
		if err != nil && err != io.EOF {
			os.Exit(3)
		}

		taxiLine = strings.TrimSpace(taxiLine)
		taxiInfo := strings.Fields(taxiLine)
		x, _ := strconv.Atoi(taxiInfo[0])
		y, _ := strconv.Atoi(taxiInfo[1])
		v, _ := strconv.Atoi(taxiInfo[2])

		// calculate distance
		if (x == 0 && y == 0) {
			minimumArrivalTime = 0.0
			break
		} else {
			xDiff := math.Pow(float64(x) - float64(a), 2)
			yDiff := math.Pow(float64(y) - float64(b), 2)
			distance := math.Sqrt(xDiff + yDiff)

			// determine arrival time
			arrivalTime := distance / float64(v)

			// update minimum
			if i == 0 || (arrivalTime < minimumArrivalTime) {
				minimumArrivalTime = arrivalTime
			}
		}
	}

	fmt.Printf("%v", minimumArrivalTime)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int
	//fmt.Scanf("%d%d\n", &a, &b)
	fmt.Scan(&a, &b)
	var n int
	//fmt.Scanf("%d\n", &n)
	fmt.Scan(&n)
	m := 1000000.0
	for i:=1; i<=n ;i++{
		var xi, yi, vi int
		//fmt.Scanf("%d%d%d\n", &xi, &yi, &vi)
		fmt.Scan(&xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b float64
	fmt.Scanf("%f %f\n", &a, &b)
	var n int
	fmt.Scanf("%d\n", &n)
	m := 1000000.0
	for i:=0; i<n ; i++{
		var xi, yi, vi float64
		fmt.Scanf("%f %f %f\n", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int
	fmt.Scanf("%d%d\n", &a, &b)
	var n int
	fmt.Scanf("%d\n", &n)
	m := 1000000.0
	for ; n>0 ;n--{
		var xi, yi, vi int
		fmt.Scanf("%d%d%d\n", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var  n int
	var a, b, d float64
	d = 1000000000000.0
	fmt.Scan(&a, &b, &n)
	for i := 0; i < n; i++ {
		var x, y, v float64
		fmt.Scan(&x, &y, &v)
		d0 := math.Sqrt(math.Pow(a-x, 2) + math.Pow(b-y, 2)) / v
		if d>d0{
			d=d0
		}
	}
	fmt.Print(d)
}

package main

import "fmt"
import "math"

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

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    var n int
    fmt.Scan(&n)
    var minTime float64 = 10000000.0
    for i:=0; i<n; i++ {
        var xi, yi, speed int
        fmt.Scan(&xi, &yi, &speed)
        dx := float64(xi - x)
        dy := float64(yi - y)
        dz := math.Sqrt(dx*dx + dy*dy)
        time := dz / float64(speed)
        if time < minTime {
            minTime = time
        }
    }
    fmt.Printf("%f", minTime)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	var N int
	fmt.Scan(&N)

	mn := -1.0
	for i := 0; i < N; i++ {
		var x, y, v int
		fmt.Scan(&x, &y, &v)
		k := math.Sqrt(float64(pow(a - x, 2) + pow(b - y, 2))) / float64(v)
		if mn == -1.0 || mn > k {
			mn = k
		}
	}
	fmt.Println(mn)

}
//aのb乗をします O(log b)
func pow(a int, b int) int {
	total := 1
	tmp := a
	for b > 0 {
		if b % 2 == 1 {
			total *= tmp
		}
		b /= 2
		tmp *= tmp
	}
	return total
}

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

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := len(arr) / 2

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func solution(reader io.Reader, writer io.Writer) {
	var x, y, n int
	fmt.Fscanf(reader, "%d %d\n%d\n", &x, &y, &n)
	var r float64
	r = 1000000
	for i := 0; i < n; i++ {
		var xx, yy, vv int
		fmt.Fscanf(reader, "%d %d %d\n", &xx, &yy, &vv)
		l := math.Sqrt( float64((x - xx) * (x - xx) + (y - yy) * (y - yy)))
		l /= float64(vv)
		if l < r {
			r = l
		}
	}
	fmt.Fprintf(writer, "%0.7f\n", r)
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, result float64
	fmt.Scanf("%f %f\n", &a, &b)
	fmt.Scanf("%f\n", &n)
	var min float64
	min = 999999.0
	for ; n > 0; n-- {
		fmt.Scanf("%f %f %f\n", &x, &y, &v)
		s = math.Sqrt(math.Pow(a-x, 2) + math.Pow(b-y, 2))
		result = s / v
		if min > s/v {
			min = result
		}
	}
	fmt.Printf("%.20f\n", min)
}

package main

import(
    "fmt"
    "math"
)

func main(){
	var a, b float64
	var n int
	var minDist float64 = 99999999.0
	fmt.Scanf("%f %f %f", &a, &b)
	fmt.Scanf("%d", &n)
	for i:=0; i<n; i++{
		var x, y, v float64
		fmt.Scanf("%f %f %f", &x, &y, &v)
		minDist = math.Min(minDist, math.Sqrt((x-a)*(x-a) + (y-b)*(y-b))/v)
	}
	fmt.Println(minDist)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	var n int
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for i:=1; i<=n ;i++{
		var xi, yi, vi int
		fmt.Scanf("%d %d %d", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b float64
	fmt.Scanf("%f %f", &a, &b)
	var n float64
	fmt.Scanf("%f", &n)
	m := 1000000.0
	for ; n>0 ;n--{
		var xi, yi, vi float64
		fmt.Scanf("%f %f %f", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int
	fmt.Scanf("%d%d", &a, &b)
	var n int
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for ; n>0 ;n--{
		var xi, yi, vi int
		fmt.Scanf("%d%d%d", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int64
	fmt.Scanf("%d %d", &a, &b)
	var n int64
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for ; n>0 ;n--{
		var xi, yi, vi int64
		fmt.Scanf("%d %d %d", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b float64
	fmt.Scanf("%f %f", &a, &b)
	var n int
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for i:=0; i<n ; i++{
		m = 3000000.0
		var xi, yi, vi float64
		fmt.Scanf("%f %f %f", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b float64
	fmt.Scanf("%f %f", &a, &b)
	var n int64
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for ; n>0 ;n--{
		var xi, yi, vi float64
		fmt.Scanf("%f %f %f", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int
	fmt.Scanf("%d%d", &a, &b)
	var n int
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for i:=1; i<=n ;i++{
		var xi, yi, vi int
		fmt.Scanf("%d%d%d", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b float64
	fmt.Scanf("%f %f", &a, &b)
	var n int
	fmt.Scanf("%d", &n)
	m := 1000000.0
	for i:=0; i<n ; i++{
		var xi, yi, vi float64
		fmt.Scanf("%f %f %f", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main
import "fmt"
import "math"
func main(){
	var a, b int
	fmt.Scanf("%d%d", &a, &b)
	var n int
	fmt.Scanf("%d\n", &n)
	m := 1000000.0
	for i:=1; i<=n ;i++{
		var xi, yi, vi int
		fmt.Scanf("%d%d%d", &xi, &yi, &vi)
		m = math.Min(m, math.Sqrt(float64((xi-a)*(xi-a)+(yi-b)*(yi-b)))/float64(vi))
	}
	fmt.Println(m)
}

package main

import "fmt"
import "math"

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

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    var n int
    fmt.Scan(&n)
    var minTime float64 = 10000000.0
    for i:=0; i>n; i++ {
        var xi, yi, speed int
        fmt.Scan(&xi, &yi, &speed)
        dx := float64(xi - x)
        dy := float64(yi - y)
        dz := math.Sqrt(dx*dx + dy*dy)
        time := dz / float64(speed)
        if time < minTime {
            minTime = time
        }
    }
    fmt.Printf("%f", minTime)
}

package main

import "fmt"
import "math"

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

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    var n int
    fmt.Scan(&n)
    var minTime float64 = 10000000.0
    for i:=0; i>n; i++ {
        var xi, yi, speed int
        fmt.Scan(&xi, &yi, &speed)
        dx := float64(xi - x)
        dy := float64(yi - y)
        dz := math.Sqrt(dx*dx + dy*dy)
        time := dz / float64(speed)
        if time < minTime {
            minTime = time
        }
    }
    fmt.Print(minTime)
}

package main

import "fmt"
import "math"

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

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    var n int
    fmt.Scan(&n)
    var minTime float64 = 10000000.0
    for i:=0; i>n; i++ {
        var xi, yi, speed int
        fmt.Scan(&xi, &yi, &speed)
        dx := float64(xi - x)
        dy := float64(yi - y)
        dz := math.Sqrt(dx*dx + dy*dy)
        fmt.Println(dz, " ", speed)
        time := dz / float64(speed)
        if time < minTime {
            minTime = time
        }
    }
    fmt.Printf("%f", minTime)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, result float64
	fmt.Scanf("%f %f", &a, &b)
	fmt.Scanf("%f", &n)
	fmt.Scanf("%f %f %f", &x, &y, &v)
	var min float64
	min = 99999
	for ; n > 0; n-- {
		fmt.Scanf("%f %f %f", &x, &y, &v)
		s = math.Sqrt(math.Pow(a-x, 2) + math.Pow(b-y, 2))
		result = s / v
		if min > s/v {
			min = result
		}
	}
	fmt.Printf("%.20f\n", min)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, min float64
	fmt.Scanf("%f %f", &a, &b)
	fmt.Scanf("%d", &n)
	fmt.Scanf("%f %f %f", &x, &y, &v)
	s = math.Abs(a-x) + math.Abs(b-y)
	min = s
	for n-1 > 0 {
		s = math.Abs(a-x) + math.Abs(b-y)
		min = s
		if min > s {
			min = s
		}
		n--
	}
	fmt.Printf("%.20f\n", min)
}

//package main
//
//import "fmt"
//
//func main() {
//	var x, h, m int
//	fmt.Scanf("%d", &x)
//	fmt.Scanf("%d %d", &h, &m)
//
//	y := 0
//	for m%10 != 7 && m != 7 && h != 7 && h !=17 {
//		if m < x {
//			m += 60
//			h--
//		}
//		if h<0 {
//			h += 24
//		}
//		m -= x
//		y++
//	}
//	fmt.Println(y)
//}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, min, result float64
	fmt.Scanf("%f %f", &a, &b)
	fmt.Scanf("%f", &n)
	fmt.Scanf("%f %f %f", &x, &y, &v)
	s = math.Abs(a-x) + math.Abs(b-y)
	result = s/v
	min = result
	for n-1 > 0 {
		fmt.Scanf("%f %f %f", &x, &y, &v)
		s = math.Sqrt(math.Pow(math.Abs(a-x),2) + math.Pow(math.Abs(b-y),2))
		result = s/v
		if min > s/v {
			min = result
		}
		n--
	}
	fmt.Printf("%.20f\n", min)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, min, result float64
	fmt.Scanf("%f %f", &a, &b)
	fmt.Scanf("%f", &n)
	fmt.Scanf("%f %f %f", &x, &y, &v)
	s = math.Abs(a-x) + math.Abs(b-y)
	result = s/v
	min = result
	for n-1 > 0 {
		fmt.Scanf("%f %f %f", &x, &y, &v)
		s = math.Sqrt(math.Pow(math.Abs(a-x),2) + math.Pow(math.Abs(b-y),2))
		result = s/v
		min = result
		if min > s/v {
			min = result
		}
		n--
	}
	fmt.Printf("%.20f\n", min)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, result float64
	fmt.Scanf("%d %d", &a, &b)
	fmt.Scanf("%d", &n)
	var min float64
	min = 999999.0
	for ; n > 0; n-- {
		fmt.Scanf("%f %f %f", &x, &y, &v)
		s = math.Sqrt(math.Pow(a-x, 2) + math.Pow(b-y, 2))
		result = s / v
		if min > s/v {
			min = result
		}
	}
	fmt.Printf("%.20f\n", min)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n, x, y, v, s, result float64
	fmt.Scanf("%d %d", &a, &b)
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d %d %d", &x, &y, &v)
	var min float64
	min = 999999.0
	for ; n > 0; n-- {
		fmt.Scanf("%f %f %f", &x, &y, &v)
		s = math.Sqrt(math.Pow(a-x, 2) + math.Pow(b-y, 2))
		result = s / v
		if min > s/v {
			min = result
		}
	}
	fmt.Printf("%.20f\n", min)
}


You are given a set of $$$n$$$ segments on the axis $$$Ox$$$, each segment has integer endpoints between $$$1$$$ and $$$m$$$ inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le m$$$) — coordinates of the left and of the right endpoints. Consider all integer points between $$$1$$$ and $$$m$$$ inclusive. Your task is to print all such points that don't belong to any segment. The point $$$x$$$ belongs to the segment $$$[l; r]$$$ if and only if $$$l \le x \le r$$$.

The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the number of segments and the upper bound for coordinates. The next $$$n$$$ lines contain two integers each $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le m$$$) — the endpoints of the $$$i$$$-th segment. Segments may intersect, overlap or even coincide with each other. Note, it is possible that $$$l_i=r_i$$$, i.e. a segment can degenerate to a point.

In the first line print one integer $$$k$$$ — the number of points that don't belong to any segment. In the second line print exactly $$$k$$$ integers in any order — the points that don't belong to any segment. All points you print should be distinct. If there are no such points at all, print a single integer $$$0$$$ in the first line and either leave the second line empty or do not print it at all.

NoteIn the first example the point $$$1$$$ belongs to the second segment, the point $$$2$$$ belongs to the first and the second segments and the point $$$5$$$ belongs to the third segment. The points $$$3$$$ and $$$4$$$ do not belong to any segment.In the second example all the points from $$$1$$$ to $$$7$$$ belong to the first segment.

package main

import (
	. "fmt"
)

func main() {
	var n, m, l, r int
	Scan(&n, &m)

	marks := make([]bool, m+1)
	for n > 0 {
		n--

		Scan(&l, &r)
		for i := l; i <= r; i++ {
			marks[i] = true
		}
	}

	cnt := 0
	for i := 1; i <= m; i++ {
		if !marks[i] {
			cnt++
		}
	}
	Println(cnt)
	for i := 1; i <= m; i++ {
		if !marks[i] {
			Printf("%d ", i)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	// fmt.Scanf("%d %d", &n, &m)
	a := make([]int, m+1)
	for i := n; i > 0; i-- {
		var s, e int
		// fmt.Scanf("%d %d", &s, &e)
		fmt.Scan(&s)
		fmt.Scan(&e)
		for j := s; j <= e; j++ {
			a[j] = 1
		}
	}
	ans := make([]int, 0)
	for i := 1; i <= m; i++ {
		if a[i] != 1 {
			ans = append(ans, i)
		}
	}
	fmt.Println(len(ans))
	for _, k := range ans {
		fmt.Printf("%d ", k)
	}
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n, m := ScanInt(), ScanInt()
	ma := make([]bool, m+1)

	for i := 0; i < n; i++ {
		l, r := ScanInt(), ScanInt()
		for j := l; j <= r; j++ {
			ma[j] = true
		}
	}

	k := 0
	ans := []int{}
	for i := 1; i <= m; i++ {
	    if !ma[i] {
	    	k++
			ans = append(ans, i)
		}
	}
	P(k)
	P(SArr(ans))
	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := MX_INT, MN_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
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 sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var a [105][2]int
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i][0], &a[i][1])
	}

	ret := make([]int, 0)
	for i := 1; i <= m; i++ {
		ok := true
		for j := 0; j < n; j++ {
			if a[j][0] <= i && i <= a[j][1] {
				ok = false
			}
		}

		if ok {
			ret = append(ret, i)
		}
	}

	fmt.Println(len(ret))
	for _, v := range ret {
		fmt.Printf("%v ", v)
	}

}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n := ScanInt()
	m := ScanInt()
	count := m
	array := make([]int, m+1)
	for i := 0; i < n; i++ {
		l := ScanInt()
		r := ScanInt()
		for j := l; j <= r; j++ {
			array[j] = 1
		}
	}

	outputArray := []int{}
	for i := 1; i <= m; i++ {
		count -= array[i]
		if 0 == array[i] {
			outputArray = append(outputArray, i)
		}
	}
	fmt.Println(count)
	fmt.Print(SArr(outputArray))

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; 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 ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Mn(args ...int64) int64 {
	minVal := MX_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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n := ScanInt()
	m := ScanInt()
	count := 0
	array := make([]bool, m+1)
	for i := 0; i < n; i++ {
		l := ScanInt()
		r := ScanInt()
		for j := l; j <= r; j++ {
			array[j] = true
		}
	}
	//fmt.Println(array)
	outputArray := []int{}
	for i := 1; i <= m; i++ {
		if !array[i]{
			count++
			outputArray = append(outputArray, i)
		}
		//count -= array[i]
		//if 0 == array[i] {
		//
		//}
	}
	fmt.Println(count)
	fmt.Print(SArr(outputArray))

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; 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 ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Mn(args ...int64) int64 {
	minVal := MX_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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n, m := ScanInt(), ScanInt()
	count := 0
	array := make([]bool, m+1)
	var outputArray []int
	for i := 0; i < n; i++ {
		l, r := ScanInt(), ScanInt()
		for j := l; j <= r; j++ {
			array[j] = true
		}
	}

	for i := 1; i <= m; i++ {
		if !array[i]{
			count++
			outputArray = append(outputArray, i)
		}
		//count -= array[i]
		//if 0 == array[i] {
		//
		//}
	}
	fmt.Println(count)
	fmt.Print(SArr(outputArray))

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; 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 ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Mn(args ...int64) int64 {
	minVal := MX_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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n, m := ScanInt(), ScanInt()
	count := m
	array := make([]int, m+1)
	for i := 0; i < n; i++ {
		l, r := ScanInt(), ScanInt()
		for j := l; j <= r; j++ {
			array[j] = 1
		}
	}

	for i := 1; i <= m; i++ {
		count -= array[i]
	}
	fmt.Println(count)

	for i := 1; i <= m; i++ {
		if 0 == array[i] {
			fmt.Print(i," ")
		}
	}

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; 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 ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Mn(args ...int64) int64 {
	minVal := MX_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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main(){
	n := ScanInt()
	m := ScanInt()
	count := m
	array := make([]int, m+1)
	for i := 0; i< n; i++{
		l := ScanInt()
		r := ScanInt()
		for j:= l; j<=r; j++{
			array[j] = 1
		}
	}

	for i := 1; i<= m; i++{
		count -= array[i]
	}
	fmt.Println(count)

	for i := 1; i<= m; i++{
		if 0==array[i]{
			fmt.Print(i," ")
		}
	}

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; 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 ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Mn(args ...int64) int64 {
	minVal := MX_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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n := ScanInt()
	m := ScanInt()
	count := 0
	array := make([]bool, m+1)
	for n > 0 {
		n--
		l := ScanInt()
		r := ScanInt()
		for j := l; j <= r; j++ {
			array[j] = true
		}
	}
	//fmt.Println(array)
	outputArray := []int{}
	for i := 1; i <= m; i++ {
		if !array[i]{
			count++
			outputArray = append(outputArray, i)
		}
		//count -= array[i]
		//if 0 == array[i] {
		//
		//}
	}
	fmt.Println(count)
	fmt.Print(SArr(outputArray))

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e8))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; 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 ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Mn(args ...int64) int64 {
	minVal := MX_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 S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}

package main

import (
	 "fmt"
)

func main() {
	var a, b int;
 	fmt.Scanf("%d%d", &a, &b)

 	var x = make([]bool, b + 1)
 	for i:=0; i<a; i ++ {
 		  var l, r int;
 		  fmt.Scan(&l)
 		  fmt.Scan(&r)
 		  for j:=l; j<=r; j ++ {
 		  		x[j] = true;
 		  }
 	}

 	var f = make([]int, 0)
 	var ct int
 	for i:=1; i<=b; i ++ {

 		  if(!x[i]) {
 		  	   ct ++;
 		  	   f = append(f, i);
 		  }
 	}
 	fmt.Println(ct)
 	for x := range f {
 		  fmt.Printf("%d ", f[x])
 	}
}

package main

import "fmt"

func main() {
	var n, m, l, r, count int
	fmt.Scan(&n, &m)
	var seg []int = make([]int, m+2)
	for i := 0; i < n; i++ {
		fmt.Scan(&l, &r)
		seg[l] += 1
		seg[r+1] -= 1
	}
	for i := 1; i <= m; i++ {
		seg[i] += seg[i-1]
		if seg[i] == 0 {
			count++
		}
	}
	fmt.Printf("%d\n", count)
	for i := 1; i <= m; i++ {
		if seg[i] == 0 {
			fmt.Printf("%d ", i)
		}
	}
}

package main

import (
    "fmt"
)

func main() {
    var n, k int
    fmt.Scanf("%d%d", &n, &k)
    v := make([]int, k+1)
    for i:=0; i<n; i++ {
        var x, y int
        fmt.Scan(&x)
        fmt.Scan(&y)
        for j:=x; j<=y; j++ {
            v[j] = 1;
        }
    }

    ans := make([]int, 0)
    cnt := 0
    for i:=1; i<=k; i++ {
        if v[i] == 0 {
            cnt++
            ans = append(ans, i)
        }
    }

    fmt.Println(cnt)
    for _, x := range ans {
        fmt.Printf("%d ", x)
    }
}

package main

import "fmt"

var n, m int
var coordinates [128]int

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		var start, end int
		fmt.Scanf("%d %d\n", &start, &end)
		for j := start; j <= end; j++ {
			coordinates[j] = 1
		}
	}
	var res int
	for i := 1; i <= m; i++ {
		if coordinates[i] == 0 {
			res++
		}
	}
	fmt.Printf("%d\n", res)
	for i := 1; i <= m; i++ {
		if coordinates[i] == 0 {
			fmt.Printf("%d ", i)
		}
	}
}

package main

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

type point struct {
	pos   int
	start bool
}

type ByOrder []point

func (a ByOrder) Len() int      { return len(a) }
func (a ByOrder) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByOrder) Less(i, j int) bool {
	if a[i].pos == a[j].pos {
		return a[i].start
	}

	return a[i].pos < a[j].pos
}

type pair struct {
	s, e int
}

func main() {
	var (
		n, m int
	)

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

	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())

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

	points := make([]point, n*2)
	for i := 0; i < n*2; i += 2 {
		scanner.Scan()
		points[i].pos, _ = strconv.Atoi(scanner.Text())
		points[i].start = true

		scanner.Scan()
		points[i+1].pos, _ = strconv.Atoi(scanner.Text())
	}

	sort.Sort(ByOrder(points))

	prev := 1
	var pairs []pair

	depth := 0
	for _, p := range points {
		if p.start {
			if depth == 0 {
				pairs = append(pairs, pair{prev, p.pos - 1})
			}

			depth++
		} else {
			depth--

			if depth == 0 {
				prev = p.pos + 1
			}
		}
	}

	pairs = append(pairs, pair{prev, m})

	// fmt.Println(points)
	// fmt.Println(pairs)

	var res []int
	for _, p := range pairs {
		for i := p.s; i <= p.e; i++ {
			res = append(res, i)
		}
	}

	fmt.Println(len(res))
	for _, v := range res {
		fmt.Print(v, " ")
	}
}

package main

import (
  "fmt"
  "strconv"
  )

func main(){
  var n,m int

  fmt.Scan(&n,&m)
  mt := make([]int,m)
for i:=0;i<n;i++{
    var l,r int
    fmt.Scan(&l,&r)
    for j :=l-1;j<r;j++{
      mt[j] =1
      }
    }
  var r string
  var k int
  for i,t := range mt {
    if t == 0 {
      k++
      r += strconv.Itoa(i+1) + "\n"
      }
    }

    fmt.Println(k,"\n",r)
}

package main

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

func main() {
	var n, m, l, r int
	var flag [100]bool
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &m)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &l, &r)
		for j := l - 1; j < r; j++ {
			flag[j] = true
		}
	}
	count := 0
	for i := 0; i < m; i++ {
		if !flag[i] {
			count++
		}
	}
	fmt.Println(count)
	for i := 0; i < m; i++ {
		if !flag[i] {
			fmt.Printf("%d ", i+1)
		}
	}
	fmt.Println()
}

package main

import "fmt"

func main() {
	var n,m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	a:=make([]int,m+2)
	for i:=0;i<n;i++ {
		var l,r int
		fmt.Scan(&l)
		fmt.Scan(&r)
		for j:=l;j<=r;j++ {
			a[j]=1
		}
	}
	kol:=m
	for i:=1;i<=m;i++ {
		kol-=a[i]
	}
	fmt.Println(kol)
	for i:=1;i<=m;i++ {
		if 0==a[i] {
			fmt.Printf("%d ",i)
		}
	}
}

// A. Points in Segments
/*
You are given a set of 𝑛 segments on the axis 𝑂𝑥, each segment has integer endpoints between 1 and 𝑚 inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers 𝑙𝑖 and 𝑟𝑖 (1≤𝑙𝑖≤𝑟𝑖≤𝑚) — coordinates of the left and of the right endpoints.

Consider all integer points between 1 and 𝑚 inclusive. Your task is to print all such points that don't belong to any segment. The point 𝑥 belongs to the segment [𝑙;𝑟] if and only if 𝑙≤𝑥≤𝑟.

Input
The first line of the input contains two integers 𝑛 and 𝑚 (1≤𝑛,𝑚≤100) — the number of segments and the upper bound for coordinates.

The next 𝑛 lines contain two integers each 𝑙𝑖 and 𝑟𝑖 (1≤𝑙𝑖≤𝑟𝑖≤𝑚) — the endpoints of the 𝑖-th segment. Segments may intersect, overlap or even coincide with each other. Note, it is possible that 𝑙𝑖=𝑟𝑖, i.e. a segment can degenerate to a point.

Output
In the first line print one integer 𝑘 — the number of points that don't belong to any segment.

In the second line print exactly 𝑘 integers in any order — the points that don't belong to any segment. All points you print should be distinct.

If there are no such points at all, print a single integer 0 in the first line and either leave the second line empty or do not print it at all.

Examples
Input
3 5
2 2
1 2
5 5

Output
2
3 4

Input
1 7
1 7

Output
0

Note
In the first example the point 1 belongs to the second segment, the point 2 belongs to the first and the second segments and the point 5 belongs to the third segment. The points 3 and 4 do not belong to any segment.

In the second example all the points from 1 to 7 belong to the first segment.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	i1 := strings.Split(strings.TrimSpace(input1), " ")
	n, _ := strconv.Atoi(i1[0])
	m, _ := strconv.Atoi(i1[1])

	ans := map[int]int{}
	for i := 1; i <= m; i++ {
		ans[i]++
	}

	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		i2 := strings.Split(strings.TrimSpace(input2), " ")
		li, _ := strconv.Atoi(i2[0])
		ri, _ := strconv.Atoi(i2[1])

		for i := li; i <= ri; i++ {
			ans[i] = 0
		}
	}

	t1 := 0
	t2 := ""
	for k, v := range ans {
		if v != 0 {
			t2 += fmt.Sprintf("%v ", k)
			t1++
		}
	}
	fmt.Printf("%v\n%v", t1, t2)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	f := make([]int, m+1)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		for j := a; j <= b; j++ {
			f[j] = 1
		}
	}
	ans := 0
	ansList := []int{}
	for i := 1; i <= m; i++ {
		if f[i] == 0 {
			ans++
			ansList = append(ansList, i)
		}
	}
	//fmt.Println(ans, cnt)
	fmt.Fprintf(out, "%d\n", ans)
	if ans > 0 {
		fmt.Fprintf(out, "%d", ansList[0])
		for i := 1; i < len(ansList); i++ {
			fmt.Fprintf(out, " %d", ansList[i])
		}
		fmt.Fprintf(out, "\n")
	}
	return
}

package main

import "fmt"

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

	dic := map[int]struct{}{}

	for range make([]struct{}, n) {
		var l, r int
		fmt.Scan(&l, &r)

		for i := l; i <= r; i++ {
			dic[i] = struct{}{}
		}
	}

	fmt.Println(m - len(dic))
	flg := false
	for i := 1; i <= m; i++ {
		if flg {
			fmt.Print(" ")
		}
		if _, in := dic[i]; !in {
			fmt.Print(i)
			flg = true
		}
	}
	fmt.Println()
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var a, b int
	var asg [101]bool
  var flag bool =true
  ar := [] int {}
  var count int
	fmt.Scanf("%d %d \n", &n, &m)

for i := 1; i <= n; i++ {
		fmt.Scanf("%d %d \n", &a, &b)
		for j := a; j <= b; j++ {
			if asg[j] == false {
				asg[j] = true
			}
		}
	}
for i := 1; i <=m; i++{
  if asg[i] == false {
    flag =false
    count++
    ar =append(ar,i)
  }
}

	if flag == true {
    fmt.Print(0)
  }else {
    fmt.Println(count)
    val := len(ar)
    for i:=0 ; i< val ; i++  {
      fmt.Print(ar[i], " ")
    }
  }
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	b := make([]bool, m)
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Fscan(in, &l, &r)
		for j := l - 1; j <= r - 1; j++ {
			b[j] = true
		}
	}

	cnt := 0
	for i := 0; i < m; i++ {
		if !b[i] { cnt++ }
	}

	fmt.Fprintln(out, cnt)
	for i := 0; i < m; i++ {
		if !b[i] {
			fmt.Fprint(out, i + 1, " ")
		}
	}

}

// Task: A. Points in Segments
// Link: http://codeforces.com/contest/1015/problem/A
// Lang: go

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanln(&n, &m)
	ma := make(map[int]bool)
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Scanln(&l, &r)
		for j := l; j <= r; j++ {
			ma[j] = true
		}
	}

	ans := make([]int, 0)
	for i := 1; i <= m; i++ {
		if !ma[i] {
			ans = append(ans, i)
		}
	}

	fmt.Println(len(ans))
	for _, x := range ans {
		fmt.Printf("%d ", x)
	}
}

package main

import "fmt"

func main() {
	n, m := 0, 0
	count := 0
	fmt.Scanf("%d %d\n", &n, &m)
	f := initf(m)
	for i := 0; i < n; i++ {
		l, r := 0, 0
		fmt.Scanf("%d %d\n", &l, &r)
		for j := l; j <= r; j++ {
			if !f[j] {
				count++
			}
			f[j] = true

		}
	}
	fmt.Println(m - count)
	if count != m {
		flag := false
		for i := 1; i <= m; i++ {
			if !f[i] {
				if flag {
					fmt.Print(" ", i)
				} else {
					fmt.Print(i)
					flag = true
				}
			}
		}
	}
}
func initf(len int) []bool {
	f := make([]bool, len+1)
	for i := 0; i < len+1; i++ {
		f[i] = false
	}
	return f
}

package main

import "fmt"

func main() {
	n, m := 0, 0
	count := 0
	fmt.Scanf("%d %d", &n, &m)
	f := initf(m)
	for i := 0; i < n; i++ {
		l, r := 0, 0
		fmt.Scanf("%d %d", &l, &r)
		for j := l; j <= r; j++ {
			f[j] = true
			count++
		}
	}
	fmt.Println(m - count)
	if count != m {
		flag := false
		for i := 1; i <= m; i++ {
			if !f[i] {
				if flag {
					fmt.Print(" ", i)
				} else {
					fmt.Print(i)
					flag = true
				}
			}
		}
	}
}
func initf(len int) []bool {
	f := make([]bool, len+1)
	for i := 0; i < len+1; i++ {
		f[i] = false
	}
	return f
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	a := make([]int, m+1)
	for i := n; i > 0; i-- {
		var s, e int
		fmt.Scanf("%d %d", &s, &e)
		for j := s; j <= e; j++ {
			a[j] = 1
		}
	}
	ans := make([]int, 0)
	for i := 1; i <= m; i++ {
		if a[i] != 1 {
			ans = append(ans, i)
		}
	}
	fmt.Println(len(ans))
	for _, k := range ans {
		fmt.Printf("%d ", k)
	}
}

package main

import "fmt"

var n, m int
var coordinates [128]int

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		var start, end int
		fmt.Scanf("%d %d", &start, &end)
		for j := start; j <= end; j++ {
			coordinates[j] = 1
		}
	}
	var res int
	for j := 1; j <= m; j++ {
		if coordinates[j] == 0 {
			res++
		}
	}
	fmt.Printf("%d\n", res)
	for i := 1; i <= m; i++ {
		if coordinates[i] == 0 {
			fmt.Printf("%d ", i)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var a, b int
	var asg [101]bool
  var flag bool =true
  ar := [] int {}
  var count int
	fmt.Scanf("%d %d", &n, &m)

for i := 1; i <= n; i++ {
		fmt.Scanf("%d %d", &a, &b)
		for j := a; j <= b; j++ {
			if asg[j] == false {
				asg[j] = true
			}
		}
	}
for i := 1; i <=m; i++{
  if asg[i] == false {
    flag =false
    count++
    ar =append(ar,i)
  }
}

	if flag == true {
    fmt.Print(0)
  }else {
    fmt.Println(count)
    val := len(ar)
    for i:=0 ; i< val ; i++  {
      fmt.Print(ar[i], " ")
    }
  }
}

package main

import "fmt"

func main() {
	n, m := 0, 0
	fmt.Scanf("%d %d", &n, &m)
	f := initf(m)
	for i := 0; i < n; i++ {
		l, r := 0, 0
		fmt.Scanf("%d %d", &l, &r)
		for j := l; j <= r; j++ {
			f[j] = true
		}
	}
	res := processf(f)
	fmt.Println(len(res))
	for i := 0; i < len(res); i++ {
		fmt.Print(res[i], " ")
	}
	if len(res) != 0 {
		fmt.Println()
	}
}
func processf(f []bool) []int {
	var res []int
	for i := 1; i <= len(f)-1; i++ {
		if f[i] == false {
			res = append(res, i)
		}
	}
	return res
}
func initf(len int) []bool {
	f := make([]bool, len+1)
	for i := 0; i < len+1; i++ {
		f[i] = false
	}
	return f
}

package main

import "fmt"

func main() {
	n, m := 0, 0
	fmt.Scanf("%d %d", &n, &m)
	f := initf(m)
	for i := 0; i < n; i++ {
		l,r := 0,0
		fmt.Scanf("%d %d",&l,&r)
		for j:=l;j<=r;j++{
			f[j] = true
		}
	}
	res := processf(f)
	fmt.Println(len(res))
	for i:=0;i<len(res);i++{
		fmt.Print(res[i]," ")
	}
	fmt.Println()
}
func processf(f []bool) []int {
	var res []int
	for i:=1;i<=len(f)-1;i++{
		if f[i]==false{
			res = append(res, i)
		}
	}
	return res
}
func initf(len int) []bool{
	f := make([]bool,len+1)
	for i:=0;i<len+1;i++{
		f[i] = false
	}
	return f
}

package main

import "fmt"

func main() {
	n, m := 0, 0
	fmt.Scanf("%d %d", &n, &m)
	f := initf(m)
	for i := 0; i < n; i++ {
		l, r := 0, 0
		fmt.Scanf("%d %d", &l, &r)
		for j := l; j <= r; j++ {
			f[j] = true
		}
	}
	res := processf(f)
	fmt.Println(len(res))
	for i := 0; i < len(res)-1; i++ {
		fmt.Print(res[i], " ")
	}
	if len(res) != 0 {
		fmt.Println(res[len(res)-1])
	}
}
func processf(f []bool) []int {
	var res []int
	for i := 1; i <= len(f)-1; i++ {
		if f[i] == false {
			res = append(res, i)
		}
	}
	return res
}
func initf(len int) []bool {
	f := make([]bool, len+1)
	for i := 0; i < len+1; i++ {
		f[i] = false
	}
	return f
}

package main

import "fmt"

func main() {
	n, m := 0, 0
	count := 0
	fmt.Scanf("%d %d", &n, &m)
	f := initf(m)
	for i := 0; i < n; i++ {
		l, r := 0, 0
		fmt.Scanf("%d %d", &l, &r)
		for j := l; j <= r; j++ {
			if !f[j] {
				count++
			}
			f[j] = true

		}
	}
	fmt.Println(m - count)
	if count != m {
		flag := false
		for i := 1; i <= m; i++ {
			if !f[i] {
				if flag {
					fmt.Print(" ", i)
				} else {
					fmt.Print(i)
					flag = true
				}
			}
		}
	}
}
func initf(len int) []bool {
	f := make([]bool, len+1)
	for i := 0; i < len+1; i++ {
		f[i] = false
	}
	return f
}


A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap.Overall the shop sells n clothing items, and exactly m pairs of clothing items match. Each item has its price, represented by an integer number of rubles. Gerald wants to buy three clothing items so that they matched each other. Besides, he wants to spend as little money as possible. Find the least possible sum he can spend.

The first input file line contains integers n and m — the total number of clothing items in the shop and the total number of matching pairs of clothing items (). Next line contains n integers ai (1 ≤ ai ≤ 106) — the prices of the clothing items in rubles. Next m lines each contain a pair of space-separated integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi). Each such pair of numbers means that the ui-th and the vi-th clothing items match each other. It is guaranteed that in each pair ui and vi are distinct and all the unordered pairs (ui, vi) are different.

Print the only number — the least possible sum in rubles that Gerald will have to pay in the shop. If the shop has no three clothing items that would match each other, print "-1" (without the quotes).

NoteIn the first test there only are three pieces of clothing and they all match each other. Thus, there is only one way — to buy the 3 pieces of clothing; in this case he spends 6 roubles.The second test only has three pieces of clothing as well, yet Gerald can't buy them because the first piece of clothing does not match the third one. Thus, there are no three matching pieces of clothing. The answer is -1.In the third example there are 4 pieces of clothing, but Gerald can't buy any 3 of them simultaneously. The answer is -1.

package main

import "fmt"

const (
	N = 105
	V = 1000000
)

func main() {
	var n, m int
	var arr [N][N]bool
	var p [N]int
	fmt.Scan(&n, &m)
	for i := 1; i <= n; i++ {
		fmt.Scan(&p[i])
	}
	for i := 0; i < m; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		arr[x][y] = true
		arr[y][x] = true
	}
	var ans = V * N
	for i := 1; i <= n; i++ {
		for j := i + 1; j <= n; j++ {
			for k := j + 1; k <= n; k++ {
				if arr[i][j] && arr[j][k] && arr[i][k] {
					if ans > p[i]+p[j]+p[k] {
						ans = p[i] + p[j] + p[k]
					}
				}
			}
		}
	}
	if ans >= N*V {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Lord Omkar would like to have a tree with $$$n$$$ nodes ($$$3 \le n \le 10^5$$$) and has asked his disciples to construct the tree. However, Lord Omkar has created $$$m$$$ ($$$\mathbf{1 \le m < n}$$$) restrictions to ensure that the tree will be as heavenly as possible. A tree with $$$n$$$ nodes is an connected undirected graph with $$$n$$$ nodes and $$$n-1$$$ edges. Note that for any two nodes, there is exactly one simple path between them, where a simple path is a path between two nodes that does not contain any node more than once.Here is an example of a tree:   A restriction consists of $$$3$$$ pairwise distinct integers, $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a,b,c \le n$$$). It signifies that node $$$b$$$ cannot lie on the simple path between node $$$a$$$ and node $$$c$$$. Can you help Lord Omkar and become his most trusted disciple? You will need to find heavenly trees for multiple sets of restrictions. It can be shown that a heavenly tree will always exist for any set of restrictions under the given constraints.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^4$$$). Description of the test cases follows. The first line of each test case contains two integers, $$$n$$$ and $$$m$$$ ($$$3 \leq n \leq 10^5$$$, $$$\mathbf{1 \leq m < n}$$$), representing the size of the tree and the number of restrictions. The $$$i$$$-th of the next $$$m$$$ lines contains three integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$ ($$$1 \le a_i, b_i, c_i \le n$$$, $$$a$$$, $$$b$$$, $$$c$$$ are distinct), signifying that node $$$b_i$$$ cannot lie on the simple path between nodes $$$a_i$$$ and $$$c_i$$$.  It is guaranteed that the sum of $$$n$$$ across all test cases will not exceed $$$10^5$$$.

For each test case, output $$$n-1$$$ lines representing the $$$n-1$$$ edges in the tree. On each line, output two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le n$$$, $$$u \neq v$$$) signifying that there is an edge between nodes $$$u$$$ and $$$v$$$. Given edges have to form a tree that satisfies Omkar's restrictions.

NoteThe output of the first sample case corresponds to the following tree:    For the first restriction, the simple path between $$$1$$$ and $$$3$$$ is $$$1, 3$$$, which doesn't contain $$$2$$$. The simple path between $$$3$$$ and $$$5$$$ is $$$3, 5$$$, which doesn't contain $$$4$$$. The simple path between $$$5$$$ and $$$7$$$ is $$$5, 3, 1, 2, 7$$$, which doesn't contain $$$6$$$. The simple path between $$$6$$$ and $$$4$$$ is $$$6, 7, 2, 1, 3, 4$$$, which doesn't contain $$$5$$$. Thus, this tree meets all of the restrictions.The output of the second sample case corresponds to the following tree:

package main

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

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

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

	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

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

			x[b-1] = true
		}

		idx := 0
		for i := range x {
			if !x[i] {
				idx = i
				break
			}
		}

		for i := 0; i < n; i++ {
			if i == idx {
				continue
			}

			fmt.Fprintf(out, "%d %d\n", idx+1, i+1)
		}
	}
}

package main

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

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		var n, m int
		fmt.Fscan(r, &n, &m)
		v := make([]int, n+1)
		for i := 0; i < m ; i++ {
			var a, b, c int
			fmt.Fscan(r, &a, &b, &c)
			v[b] = 1
		}
		for i:= 1; i <= n; i++ {
			if v[i] == 0 {
				for j:=1 ; j <= n; j++ {
					if i != j {
						fmt.Fprintln(w, i, " ", j)
					}
				}
				break
			}
		}
	}
}

package main

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

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

	var t int
	var n, m int
	var a, b, c int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m)
		f := make([]bool, n+1)
		for i := 0; i < m; i++ {
			Fscan(in, &a, &b, &c)
			f[b] = true
		}
		root := 0
		for i := 1; i <= n; i++ {
			if !f[i] {
				root = i
				break
			}
		}
		for i := 1; i <= n; i++ {
			if i != root {
				Fprintf(out, "%d %d\n", i, root)
			}
		}
	}
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
)
const N = 1e5+5;
var vis [N]int;
func main()  {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)

	for ;t>0;t-- {
		var n int
		var m int
		fmt.Fscan(in,&n,&m)
		for i:=1;i<=n;i++ {
			vis[i]=0;
		}
		for ;m>0;m-- {
			var(
				a int
				b int
				c int
			)
			fmt.Fscan(in,&a,&b,&c)
			vis[b]=1
		}
		for i:=1;i<=n;i++ {
			if vis[i]==0 {
				for j:=1;j<=n;j++{
					if j==i {
						continue
					}
					fmt.Fprintln(out,i," ",j)
				}
				break
			}
		}
	}
}

package main

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

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

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

	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

		z := make([]int, n+1)
		for i := 2; i <= n; i++ {
			z[i] = 1
		}

		for i := 0; i < m; i++ {
			var a, b, c int
			fmt.Fscan(in, &a, &b, &c)

			if z[a] == b && z[b] == c {
				z[b], z[a] = a, c
			} else if z[a] == b {
				z[c] = a
			}
		}

		for i := 2; i <= n; i++ {
			fmt.Fprintf(out, "%d %d\n", z[i], i)
		}
	}
}

package main

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

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

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

	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

		z := make([]int, n+1)
		for i := 2; i <= n; i++ {
			z[i] = 1
		}

		for i := 0; i < m; i++ {
			var a, b, c int
			fmt.Fscan(in, &a, &b, &c)

			if z[a] == b {
				z[a] = c
			}
		}

		for i := 2; i <= n; i++ {
			fmt.Fprintf(out, "%d %d\n", z[i], i)
		}
	}
}

package main

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

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

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

	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

		z := make([]int, n+1)
		for i := 2; i <= n; i++ {
			z[i] = 1
		}

		for i := 0; i < m; i++ {
			var a, b, c int
			fmt.Fscan(in, &a, &b, &c)

			if z[c] == b {
				z[c] = a
			}
		}

		for i := 2; i <= n; i++ {
			fmt.Fprintf(out, "%d %d\n", z[i], i)
		}
	}
}

package main

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

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		var n, m int
		fmt.Fscan(r, &n, &m)
		v := make([]int, n+1)
		for i := 0; i < m ; i++ {
			var a, b, c int
			fmt.Fscan(r, &a, &b, &c)
			v[b] = 1
		}
		for i:= 1; i <= n; i++ {
			if v[i] == 0 {
				for j:=1 ; j < n; j++ {
					if i != j {
						fmt.Fprintln(w, i, " ", j)
					}
				}
				break
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
const N = 1e5+5;
var vis [N]int;
func main()  {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	fmt.Fprintln(out,N)

	for ;t>0;t-- {
		var n int
		var m int
		fmt.Fscan(in,&n,&m)
		for i:=1;i<=n;i++ {
			vis[i]=0;
		}
		for ;m>0;m-- {
			var(
				a int
				b int
				c int
			)
			fmt.Fscan(in,&a,&b,&c)
			vis[b]=1
		}
		for i:=1;i<=n;i++ {
			if vis[i]==0 {
				for j:=1;j<=n;j++{
					if j==i {
						continue
					}
					fmt.Fprintln(out,i," ",j)
				}
				break
			}
		}
	}
}

package main

import(
	"bufio"
	."fmt"
	"io"
	"os"
)
const N = 1e5+5;
var vis [N]int;
func solve(_r io.Reader,_w io.Writer)  {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t int
	Fscan(in,&t)
	Fprintln(out,N)

	for ;t>0;t-- {
		var n int
		var m int
		Fscan(in,&n,&m)
		for i:=1;i<=n;i++ {
			vis[i]=0;
		}
		for ;m>0;m-- {
			var(
				a int
				b int
				c int
			)
			Fscan(in,&a,&b,&c)
			vis[b]=1
		}
		for i:=1;i<=n;i++ {
			if vis[i]==0 {
				for j:=1;j<=n;j++{
					if j==i {
						continue
					}
					Fprintln(out,i," ",j)
				}
				break
			}
		}
	}
}
func main()  {
	solve(os.Stdin,os.Stdout)
}


This is an easier version of the problem. In this version, $$$n \le 2000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a sequence of $$$\frac{n}{2}$$$ snaps. In one snap, you can remove any two points $$$a$$$ and $$$b$$$ that have not been removed yet and form a perfectly balanced pair. A pair of points $$$a$$$ and $$$b$$$ is perfectly balanced if no other point $$$c$$$ (that has not been removed yet) lies within the axis-aligned minimum bounding box of points $$$a$$$ and $$$b$$$.Formally, point $$$c$$$ lies within the axis-aligned minimum bounding box of points $$$a$$$ and $$$b$$$ if and only if $$$\min(x_a, x_b) \le x_c \le \max(x_a, x_b)$$$, $$$\min(y_a, y_b) \le y_c \le \max(y_a, y_b)$$$, and $$$\min(z_a, z_b) \le z_c \le \max(z_a, z_b)$$$. Note that the bounding box might be degenerate. Find a way to remove all points in $$$\frac{n}{2}$$$ snaps.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 2000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points coincide.

Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many solutions, output any of them.

NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after point $$$3$$$ is removed.

package main

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

type point struct {
	x, y, z int64
}

func (p point) dis(p1 point) int64 {
	p.x -= p1.x
	p.y -= p1.y
	p.z -= p1.z
	return p.x*p.x + p.y*p.y + p.z*p.z
}

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

	var n int
	Fscan(in, &n)
	ps := make([]point, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y, &ps[i].z)
	}

	check := make([]bool, n)
	for i, p := range ps {
		if check[i] {
			continue
		}
		minD := int64(1e18)
		ansj := -1
		for j := i + 1; j < n; j++ {
			if check[j] {
				continue
			}
			if newD := p.dis(ps[j]); newD < minD {
				ansj = j
				minD = newD
			}
		}
		if ansj == -1 {
			continue
		}
		check[i] = true
		check[ansj] = true
		Fprintln(out, i+1, ansj+1)
	}
}

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


Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.She starts with 0 money on her account.In the evening of i-th day a transaction ai occurs. If ai > 0, then ai bourles are deposited to Luba's account. If ai < 0, then ai bourles are withdrawn. And if ai = 0, then the amount of money on Luba's account is checked.In the morning of any of n days Luba can go to the bank and deposit any positive integer amount of burles to her account. But there is a limitation: the amount of money on the account can never exceed d.It can happen that the amount of money goes greater than d by some transaction in the evening. In this case answer will be «-1».Luba must not exceed this limit, and also she wants that every day her account is checked (the days when ai = 0) the amount of money on her account is non-negative. It takes a lot of time to go to the bank, so Luba wants to know the minimum number of days she needs to deposit some money to her account (if it is possible to meet all the requirements). Help her!

The first line contains two integers n, d (1 ≤ n ≤ 105, 1 ≤ d ≤ 109) —the number of days and the money limitation. The second line contains n integer numbers a1, a2, ... an ( - 104 ≤ ai ≤ 104), where ai represents the transaction in i-th day.

Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money.

package main

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

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 toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

var a,sum,mx [100005]int
var ans,n,d int

func main() {
	fmt.Scanf("%d%d",&n,&d)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i:=1;i<=n;i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		//fmt.Println(a[i])
		sum[i] = sum[i-1] + a[i]
	}
	mx[n] = sum[n]
	for i:=n - 1;i>=1;i-- {
		mx[i] = max(mx[i+1], sum[i])
	}
	a[n+1] = 1;
	added := 0
	for i:=1;i<=n;i++ {
		if (added + sum[i] > d) {
			//fmt.Println(i);
			fmt.Println(-1)
			os.Exit(0)
		}
		if a[i] == 0 {
			continue
		}
		if a[i + 1] == 0 {
			left := -sum[i] - added
			//fmt.Println(d,added,sum[i],mx[i+1])
			right := min(d - added - sum[i], d - added - mx[i+1])
			//fmt.Println(left,right, mx[i+1])
			if left > right {
				//fmt.Println(">> ",i)
				fmt.Println(-1)
				os.Exit(0)
			}
			if left > 0 {
				added += right
				ans++
			}
		}
	}
	fmt.Println(ans)
}

package main

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

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 toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

var a,sum,mx [100005]int
var ans,n,d int

func main() {
	fmt.Scanf("%d%d",&n,&d)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i:=1;i<=n;i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		//fmt.Println(a[i])
		sum[i] = sum[i-1] + a[i]
	}
	for i:=n;i>=1;i-- {
		mx[i] = max(mx[i+1], sum[i])
	}
	a[n+1] = 1;
	added := 0
	for i:=1;i<=n;i++ {
		if (added + sum[i] > d) {
			fmt.Println(-1)
			os.Exit(0)
		}
		if a[i] == 0 {
			continue
		}
		if a[i + 1] == 0 {
			left := -sum[i] - added
			right := min(d - added - sum[i], d - added - mx[i+1])
			//fmt.Println(left,right)
			if left > right {
				fmt.Println(-1)
				os.Exit(0)
			}
			if left > 0 {
				added += right
				ans++
			}
		}
	}
	fmt.Println(ans)
}

package main

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

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 toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

var a,sum [100005]int
var ans,n,d int

func main() {
	fmt.Scanf("%d%d",&n,&d)
	for i:=1;i<=n;i++ {
		fmt.Scanf("%d",&a[i])
		sum[i] = sum[i-1] + a[i]
	}
	a[n+1] = 1;
	added := 0
	for i:=1;i<=n;i++ {
		if (added + sum[i] > d) {
			fmt.Println(-1)
			os.Exit(0)
		}
		if a[i] == 0 {
			continue
		}
		if a[i + 1] == 0 {
			left := -sum[i] - added
			right := d - added - sum[i]
			//fmt.Println(left,right)
			if left > right {
				fmt.Println(-1)
				os.Exit(0)
			}
			added += max(0,left)
			if max(0,left) > 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

package main

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

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 toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

var a,sum [100005]int
var ans,n,d int

func main() {
	fmt.Scanf("%d%d",&n,&d)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i:=1;i<=n;i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		//fmt.Println(a[i])
		sum[i] = sum[i-1] + a[i]
	}
	a[n+1] = 1;
	added := 0
	for i:=1;i<=n;i++ {
		if (added + sum[i] > d) {
			fmt.Println(-1)
			os.Exit(0)
		}
		if a[i] == 0 {
			continue
		}
		if a[i + 1] == 0 {
			left := -sum[i] - added
			right := d - added - sum[i]
			//fmt.Println(left,right)
			if left > right {
				fmt.Println(-1)
				os.Exit(0)
			}
			added += max(0,left)
			if max(0,left) > 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Victor has a 24-hour clock that shows the time in the format "HH:MM" (00 $$$\le$$$ HH $$$\le$$$ 23, 00 $$$\le$$$ MM $$$\le$$$ 59). He looks at the clock every $$$x$$$ minutes, and the clock is currently showing time $$$s$$$. How many different palindromes will Victor see in total after looking at the clock every $$$x$$$ minutes, the first time being at time $$$s$$$?For example, if the clock starts out as 03:12 and Victor looks at the clock every $$$360$$$ minutes (i.e. every $$$6$$$ hours), then he will see the times 03:12, 09:12, 15:12, 21:12, 03:12, and the times will continue to repeat. Here the time 21:12 is the only palindrome he will ever see, so the answer is $$$1$$$.A palindrome is a string that reads the same backward as forward. For example, the times 12:21, 05:50, 11:11 are palindromes but 13:13, 22:10, 02:22 are not.

The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of each test case follows. The only line of each test case contains a string $$$s$$$ of length $$$5$$$ with the format "HH:MM" where "HH" is from "00" to "23" and "MM" is from "00" to "59" (both "HH" and "MM" have exactly two digits) and an integer $$$x$$$ ($$$1 \leq x \leq 1440$$$) — the number of minutes Victor takes to look again at the clock.

For each test case, output a single integer — the number of different palindromes Victor will see if he looks at the clock every $$$x$$$ minutes starting from time $$$s$$$.

NoteThe first test case is explained in the statement.

package main

import (
	"fmt"
)
const true, false = 1, 0

func solve() {
	var hh, mm, s int
	_, err := fmt.Scanf("%d:%d %d\n", &hh, &mm, &s)
	if err != nil {
		return
	}
	preh := hh
	prem := mm
	cnt := 0
	if check(hh, mm) == 1 {
		cnt = cnt + 1
	}
	hh, mm = add(hh, mm, s)
	for hh != preh || mm != prem {
		if check(hh, mm) == 1 {
			cnt = cnt + 1
		}
		hh, mm = add(hh, mm, s)
	}
	fmt.Println(cnt)
}

func add(hh int, mm int, s int) (int, int) {
	mm = mm + s
	more := mm / 60
	mm = mm % 60
	hh = hh + more
	hh = hh % 24
	return hh, mm
}

func check(hh int, mm int) int {
	a := hh / 10
	b := hh % 10
	c := mm / 10
	d := mm % 10
	if a == d && b == c {
		return 1
	}
	return 0
}

func main() {
	var t int
	// 读取数据
	_, err := fmt.Scanln(&t)
	if err != nil {
		return
	}
	for t > 0 {
		solve()
		t--
	}
	// fmt.Println(t)
}

package main

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

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

	var T int
	fmt.Fscanf(in, "%d\n", &T)
	for t := 0; t < T; t++ {
		var h, m, x int
		fmt.Fscanf(in, "%d:%d %d\n", &h, &m, &x)

		ch, cm := h, m
		var tot int
		for {
			d := (ch * 60) + cm + x
			ch = (d / 60) % 24
			cm = d % 60
			if ch/10 == cm%10 && ch%10 == cm/10 {
				tot++
			}
			if ch == h && cm == m {
				break
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

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

	var T int
	fmt.Fscanf(in, "%d\n", &T)
	for t := 0; t < T; t++ {
		var h, m, x int
		fmt.Fscanf(in, "%d:%d %d\n", &h, &m, &x)

		add := func(h, m, x int) (int, int) {
			d := (h * 60) + m + x
			return (d / 60) % 24, d % 60
		}

		ch, cm := h, m
		g := make(map[string]bool)
		var tot int
		for {
			s := fmt.Sprintf("%.2d:%.2d", ch, cm)
			if g[s] {
				break
			}
			g[s] = true
			if s[0] == s[4] && s[1] == s[3] {
				tot++
			}

			ch, cm = add(ch, cm, x)
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

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

func solve() string {
	var time string
	var h, m, ii, hi, mi int
	fmt.Fscan(in, &time)
	fmt.Fscan(in, &ii)
	var tmp int64
	tmp, _ = strconv.ParseInt(strings.Split(time, ":")[0], 10, 32)
	h = int(tmp)

	tmp, _ = strconv.ParseInt(strings.Split(time, ":")[1], 10, 32)
	m = int(tmp)

	hi = ii / 60
	mi = ii % 60

	var res int
	var sh, sm = h, m
	for true {
		m += mi

		if m > 59 {
			h++
			m %= 60
		}
		h += hi
		if h > 23 {
			h %= 24
		}

		if h/10 == m%10 && h%10 == m/10 {
			res++
		}

		if sh == h && sm == m {
			break
		}
	}

	return strconv.FormatInt(int64(res), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

import "fmt"

func Reverse(s string) string {
    r := []rune(s)
    for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
        r[i], r[j] = r[j], r[i]
    }
    return string(r)
}

type Pair[T, U any] struct {
    First  T
    Second U
}

func main() {
    t := 0;
    fmt.Scanf("%d\n", &t);

    for i := 0; i < t; i++ {
        h, m, x := 0, 0, 0;
        fmt.Scanf("%d:%d %d\n", &h, &m, &x);

        orig := h * 60 + m;

        r := 0;
        for ;; {
            s := fmt.Sprintf("%02d:%02d", h, m);
            if s == Reverse(s) {
                // fmt.Printf("%s %d\n", s, x);
                r++;
            }

            m += x;
            h += m / 60;
            h %= 24;
            m %= 60;
            if orig == h * 60 + m {
                break
            }
        }

        fmt.Printf("%d\n", r);
    }
}

package main

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

func main() {
	palindromesTime := [...]int{0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412}
	in := bufio.NewReader(os.Stdin)
	var t, m, s, d int
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d:%d %d\n", &m, &s, &d)
		ans, currentTime := 0, m*60+s
		timeMap := make(map[int]bool, 128)
		for j := 0; j < 1500; j++ {
			timeMap[currentTime] = true
			currentTime = (currentTime + d) % 1440
		}
		for _, val := range palindromesTime {
			_, ok := timeMap[val]
			if ok {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

package main

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

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

func change(s string) int {
	hour, _ := strconv.Atoi(s[:2])
	minute, _ := strconv.Atoi(s[3:])
	return hour*60+minute
}
func check(i int) bool {
	hour := strconv.Itoa(i / 60)
	minute := strconv.Itoa(i % 60)
	if len(hour) == 1 {
		hour = "0"+hour
	}
	if len(minute) == 1 {
		minute = "0" + minute
	}
	return hour[0] == minute[1] && hour[1] == minute[0]
}

func slove() {
	var s string
	var n int
	fmt.Fscan(r, &s, &n)
	m := change(s)
	cnt := make(map[int]int)
	an := 0
	for  {
		if _,ok := cnt[m] ;ok {
			fmt.Fprintln(w,an)
			return
		}
		cnt[m] = 0
		if check(m) {
			// fmt.Fprintln(w,an)
			an++
			// cnt[m]++
		}
		m = m + n
		m %= 1440

	}

}
func main() {
	defer w.Flush()
	var T int
	fmt.Fscan(r,&T)
	for i := 0; i < T; i++ {
		slove()
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var a string
		var b int
		fmt.Fscan(r, &a, &b)
		w1 := do(a, b)
		fmt.Fprintln(w, w1)
	}
}

var z = map[int]struct{}{}

func inv(i int) int {
	return (i%10)*10 + i/10
}

func init() {
	for _, v := range [16]int{0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23} {
		z[v*60+inv(v)] = struct{}{}
	}
}

func do(a string, b int) int {
	i := strings.Index(a, ":")
	h, _ := strconv.Atoi(a[:i])
	m, _ := strconv.Atoi(a[i+1:])
	t := h*60 + m
	j := t
	c := 0
	for {
		if _, ok := z[j]; ok {
			c++
		}
		j = (j + b) % (24 * 60)
		if j == t {
			break
		}
	}
	return c
}

package main

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

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

	palindromeFlags := make([]bool, 1450)

	for h := 0; h < 24; h++ {
		for m := 0; m < 60; m++ {
			d := calculateMinutes(h, m)
			if isPalindrome(timeToString(h, m)) {
				palindromeFlags[d] = true
			}
		}
	}

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var x int
		var startTime string
		Fscan(in, &startTime, &x)

		cnt := 0
		curTime := stringToMinutes(startTime)
		visit := make([]bool, 1450)
		for !visit[curTime] {
			if palindromeFlags[curTime] {
				cnt++
			}
			visit[curTime] = true
			curTime = (curTime + x) % 1440
		}

		Fprintln(out, cnt)

	}
}

func calculateMinutes(h, m int) int {
	return h*60 + m
}

func isPalindrome(s string) bool {
	ss := []rune(s)

	l := 0
	r := len(s) - 1

	for l <= r {
		if ss[l] != ss[r] {
			return false
		}
		l++
		r--
	}
	return true
}

func timeToString(h, m int) string {
	t := ""
	if h < 10 {
		t = Sprintf("0%d", h)
	} else {
		t = Sprintf("%d", h)
	}

	if m < 10 {
		t = Sprintf("%s:0%d", t, m)
	} else {
		t = Sprintf("%s:%d", t, m)
	}
	return t
}

func stringToMinutes(ss string) int {
	parts := strings.Split(ss, ":")
	h, _ := strconv.Atoi(parts[0])
	m, _ := strconv.Atoi(parts[1])

	return h*60 + m
}

package main

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

/*
1
00:00 1

*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var h, m, x int
	scanf("%d:%d %d\n", &h, &m, &x)

	ch, cm := h, m

	type pair struct {
		h, m int
	}

	pals := make(map[pair]bool)
	if isPal(h, m) {
		pals[pair{h, m}] = true
	}

	cm += x

	for i := 0; i < 5000; i++ {
		ch += cm / 60
		cm = cm % 60

		ch = ch % 24

		if isPal(ch, cm) {
			pals[pair{ch, cm}] = true
		}

		cm += x
	}

	fmt.Fprintln(writer, len(pals))
}

func isPal(h, m int) bool {
	s := fmt.Sprintf("%02d%02d", h, m)

	for i := 0; i < len(s); i++ {
		if s[i] != s[len(s)-1-i] {
			return false
		}
	}

	return true
}

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

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

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

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

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

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

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

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

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

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

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

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

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

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

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

func change(s string) int {
	hour, _ := strconv.Atoi(s[:2])
	minute, _ := strconv.Atoi(s[3:])
	return hour*60+minute
}

func reverse(i int) string {
	hour := strconv.Itoa(i / 60)
	minute := strconv.Itoa(i % 60)
	if len(hour) == 1 {
		hour = "0"+hour
	}
	if len(minute) == 1 {
		minute = "0" + minute
	}
	return hour + ":" + minute
}

func check(i int) bool {
	hour := strconv.Itoa(i / 60)
	minute := strconv.Itoa(i % 60)
	if len(hour) == 1 {
		hour = "0"+hour
	}
	if len(minute) == 1 {
		minute = "0" + minute
	}
	return hour[0] == minute[1] && hour[1] == minute[0]
}

func slove() {
	var s string
	var interval int
	fmt.Fscan(r, &s, &interval)
	time := change(s)
	cnt := make(map[int]int)
	ans := 0
	for {
		if _, ok := cnt[time]; ok {
			fmt.Fprintln(w, ans)
			return
		}
		cnt[time] = 0
		if check(time) {
			ans++
		}
		time = time + interval
		time %= 1440
	}
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"runtime/debug"
)

/* begin of MyIO */
const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false
	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO

func ri() int {
	return myio.ReadInt()
}

func ri64() int64 {
	return myio.ReadInt64()
}

func ria(_n int) []int {
	a := make([]int, _n)
	for i := range a {
		a[i] = ri()
	}
	return a
}

/* End of MyIO */

var m map[int]bool

func sol() {
	b := myio.ReadBytes()
	// fmt.Println(b)
	i := ri()
	// fmt.Println(i)
	s := (int(b[0]-'0')*10+int(b[1]-'0'))*60 + (int(b[3]-'0')*10 + int(b[4]-'0'))
	c := 0
	t := s
	for {
		if _, ok := m[t]; ok {
			c += 1
		}
		t = (t + i) % 1440
		if t == s {
			break
		}
	}
	myio.Println(c)
}

func pre() {
	m = make(map[int]bool)
	for i := 0; i < 24; i++ {
		a := i / 10
		b := i % 10
		c := a + b*10
		if c < 60 {
			d := i*60 + c
			m[d] = true
		}
	}
}

func main() {
	debug.SetGCPercent(-1)
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()

	var t = 1
	t = ri()
	pre()
	for ; t > 0; t-- {
		// fmt.Println("t=", t)
		sol()
	}
}

package main

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

// https://space.bilibili.com/206214/dynamic
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var s string
		var x ,h,m int
		Fscan(in, &s,&x)
		Sscanf(s, "%d:%d",&h,&m)
		t := h*60+m
		vis := map[int]bool{}
		ans := 0
		for !vis[t] {
			vis[t]=true
			s := Sprintf("%02d:%02d",t/60,t%60)
			for i, n := 0, len(s); i < n/2; i++ {
				v, w := s[i], s[n-1-i]
				if v!=w {
					goto o
				}
			}
			ans++
			o:
			t+=x
			if t >= 24*60 {
				t-=24*60
			}
		}
		Fprintln(out, ans)
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

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

}

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

package main

import (
	"bufio"
	"fmt"
	"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...) }

const true, false = 1, 0

func solve() {
	var hh, mm, s int
	_, err := fmt.Scanf("%d:%d %d", &hh, &mm, &s)
	if err != nil {
		return
	}
	preh := hh
	prem := mm
	cnt := 0
	if check(hh, mm) == 1 {
		cnt = cnt + 1
	}
	hh, mm = add(hh, mm, s)
	for hh != preh || mm != prem {
		if check(hh, mm) == 1 {
			cnt = cnt + 1
		}
		hh, mm = add(hh, mm, s)
	}
	fmt.Println(cnt)
}

func add(hh int, mm int, s int) (int, int) {
	mm = mm + s
	more := mm / 60
	mm = mm % 60
	hh = hh + more
	hh = hh % 24
	return hh, mm
}

func check(hh int, mm int) int {
	a := hh / 10
	b := hh % 10
	c := mm / 10
	d := mm % 10
	if a == d && b == c {
		return 1
	}
	return 0
}

func main() {
	defer writer.Flush()
	var t int
	// 读取数据
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for t > 0 {
		solve()
		t--
	}
	// fmt.Println(t)
}

package main

import "fmt"

const true, false = 1, 0

func solve() {
	var hh, mm, s int
	_, err := fmt.Scanf("%d:%d %d", &hh, &mm, &s)
	if err != nil {
		return
	}
	preh := hh
	prem := mm
	cnt := 0
	if check(hh, mm) == 1 {
		cnt = cnt + 1
	}
	hh, mm = add(hh, mm, s)
	for hh != preh || mm != prem {
		if check(hh, mm) == 1 {
			cnt = cnt + 1
		}
		hh, mm = add(hh, mm, s)
	}
	fmt.Println(cnt)
}

func add(hh int, mm int, s int) (int, int) {
	mm = mm + s
	more := mm / 60
	mm = mm % 60
	hh = hh + more
	hh = hh % 24
	return hh, mm
}

func check(hh int, mm int) int {
	a := hh / 10
	b := hh % 10
	c := mm / 10
	d := mm % 10
	if a == d && b == c {
		return 1
	}
	return 0
}

func main() {
	var t int
	// 读取数据
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for t > 0 {
		solve()
		t--
	}
	// fmt.Println(t)
}

package main

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

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

func solve() string {
	var time string
	var h, m, ii int
	fmt.Fscan(in, &time)
	fmt.Fscan(in, &ii)
	var tmp int64
	tmp, _ = strconv.ParseInt(strings.Split(time, ":")[0], 10, 32)
	h = int(tmp)

	tmp, _ = strconv.ParseInt(strings.Split(time, ":")[1], 10, 32)
	m = int(tmp)

	var res int
	var sh, sm = h, m
	for true {
		m += ii
		if m > 59 {
			m %= 60
			h += 1
			h += ii / 60
			if h > 23 {
				h %= 24
			}
		}
		if h/10 == m%10 && h%10 == m/10 {
			res++
		}
		if sh == h && sm == m {
			break
		}
	}

	return strconv.FormatInt(int64(res), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}