Vlad, like everyone else, loves to sleep very much.Every day Vlad has to do $$$n$$$ things, each at a certain time. For each of these things, he has an alarm clock set, the $$$i$$$-th of them is triggered on $$$h_i$$$ hours $$$m_i$$$ minutes every day ($$$0 \le h_i < 24, 0 \le m_i < 60$$$). Vlad uses the $$$24$$$-hour time format, so after $$$h=12, m=59$$$ comes $$$h=13, m=0$$$ and after $$$h=23, m=59$$$ comes $$$h=0, m=0$$$.This time Vlad went to bed at $$$H$$$ hours $$$M$$$ minutes ($$$0 \le H < 24, 0 \le M < 60$$$) and asks you to answer: how much he will be able to sleep until the next alarm clock.If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length $$$0$$$.

The first line of input data contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the test. The first line of the case contains three integers $$$n$$$, $$$H$$$ and $$$M$$$ ($$$1 \le n \le 10, 0 \le H < 24, 0 \le M < 60$$$) — the number of alarms and the time Vlad went to bed. The following $$$n$$$ lines contain two numbers each $$$h_i$$$ and $$$m_i$$$ ($$$0 \le h_i < 24, 0 \le m_i < 60$$$) — the time of the $$$i$$$ alarm. It is acceptable that two or more alarms will trigger at the same time. Numbers describing time do not contain leading zeros.

Output $$$t$$$ lines, each containing the answer to the corresponding test case. As an answer, output two numbers  — the number of hours and minutes that Vlad will sleep, respectively. If any alarm clock rings at the time when he went to bed, the answer will be 0 0.

package main

import "fmt"

const INF = int(1e9)

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

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

func solve(n int, H int, M int, h []int, m []int) (int, int) {
    ans := INF
    time_now := H * 60 + M
    for j := 0; j < n; j++ {
        time_tmp := h[j] * 60 + m[j]
        if time_now <= time_tmp {
            ans = Min(ans, time_tmp - time_now)
        } else {
            ans = Min(ans, time_tmp + 60 * 24 - time_now)
        }
    }
    return ans/60, ans%60
}

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d\n", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d\n", &h[j], &m[j])
        }

        hour, minute := solve(n, H, M, h, m)

        fmt.Printf("%d %d\n", hour, minute)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d\n", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d\n", &h[j], &m[j])
        }

        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

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

func print(arg ...interface{})            { fmt.Fprint(out, arg...) }
func println(arg ...interface{})          { fmt.Fprintln(out, arg...) }
func printf(f string, arg ...interface{}) { fmt.Fprintf(out, f, arg...) }
func scanf(f string, arg ...interface{})  { fmt.Fscanf(in, f, arg...) }

func readLn() string {
	ln, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}

	return strings.Trim(ln, " \n\r")
}

func readInt() int {
	i, err := strconv.Atoi(readLn())
	if err != nil {
		panic(err)
	}

	return i
}

func readInts() []int {
	ln := readLn()
	arr := strings.Split(ln, " ")
	var ints []int
	for _, s := range arr {
		v, err := strconv.Atoi(s)
		if err != nil {
			continue
		}
		ints = append(ints, v)
	}

	return ints
}

func main() {
	defer out.Flush()

	n := readInt()
	var result []string
	for i := 0; i < n; i++ {
		tmp := readInts()
		bedT := tmp[1]*60 + tmp[2]
		var times []int
		f := false
		for j := 0; j < tmp[0]; j++ {
			tt := readInts()
			t := tt[0]*60 + tt[1]
			times = append(times, t)
			if t == bedT {
				f = true
			}
		}

		if f {
			result = append(result, "0 0")
		} else {
			sort.Ints(times)
			if times[len(times)-1] < bedT {
				d := 1440 - bedT
				result = append(result, fmt.Sprintf("%d %d", (times[0]+d)/60, (times[0]+d)%60))
			} else {
				for i := 0; i < len(times); i++ {
					if times[i] > bedT {
						result = append(result, fmt.Sprintf("%d %d", (times[i]-bedT)/60, (times[i]-bedT)%60))
						break
					}
				}
			}
		}
	}
	for _, s := range result {
		println(s)
	}
}

package main

import (
	"fmt"
	"math"
)

const day = 60 * 24

func main() {
	var times int
	fmt.Scanf("%d\n", &times)
	for t := 0; t < times; t++ {
		var n, H, M int
		fmt.Scanf("%d %d %d\n", &n, &H, &M)
		datum := H*60 + M
		result := math.MaxInt32
		for i := 0; i < n; i++ {
			var hour, minute int
			fmt.Scanf("%d %d\n", &hour, &minute)
			current := hour*60 + minute - datum
			if current < 0 {
				current += day
			}
			if current < result {
				result = current
			}
		}
		fmt.Println(result/60, result%60)
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n, h, m int
	scan(&n, &h, &m)
	sleep := h*60 + m
	ans := 24 * 60
	for i := 0; i < n; i++ {
		scan(&h, &m)
		t := h*60 + m - sleep
		if t < 0 {
			t += 24 * 60
		}
		if t < ans {
			ans = t
		}
	}

	printf("%d %d\n", ans/60, ans%60)
}

func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

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

type Timez struct {
	h, m int
}

func (t *Timez) Differ(t2 Timez) int { // t2 - t
	h1 := t.h*60 + t.m
	h2 := t2.h*60 + t2.m
	d := h2 - h1
	if d < 0 {
		d += 60 * 24
	}
	return d
}
func solve() {
	var n int
	var sleep Timez
	scan(&n, &sleep.h, &sleep.m)
	a := make([]Timez, n)
	for i := 0; i < n; i++ {
		scan(&a[i].h, &a[i].m)
	}
	ans := 24 * 60
	for i := 0; i < n; i++ {
		d := sleep.Differ(a[i])
		if d < ans {
			ans = d
		}
	}
	printf("%d %d\n", ans/60, ans%60)
}

func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

type Timez struct {
	h, m int
}

func NewTimez(h, m int) Timez {
	var t Timez
	t.h = h
	t.m = m
	return t
}
func (t *Timez) EqualTo(t2 Timez) bool {
	return t.h == t2.h && t.m == t2.m
}
func (t *Timez) LessThan(t2 Timez) bool {
	if t.h == t2.h {
		return t.m < t2.m
	} else {
		return t.h < t2.h
	}
}
func (t *Timez) Differ(t2 Timez) Timez { // t2 - t
	var h, m int
	if t2.h >= t.h {
		h = t2.h - t.h
		m = t2.m - t.m

	} else {
		h = t2.h + 24 - t.h
		m = t2.m - t.m
	}
	if m < 0 {
		m += 60
		h -= 1
	}
	if h < 0 {
		h += 24
	}
	return NewTimez(h, m)
}

func (t *Timez) Print() {
	printf("%d %d\n", t.h, t.m)
}
func solve() {
	// printf("---------\n")
	var n int
	var sleep Timez
	scan(&n, &sleep.h, &sleep.m)
	a := make([]Timez, n)
	for i := 0; i < n; i++ {
		scan(&a[i].h, &a[i].m)

	}
	sort.Slice(a, func(i, j int) bool {
		return a[i].LessThan(a[j])
	})
	ans := NewTimez(24, 0)
	for i := 0; i < n; i++ {
		if sleep.EqualTo(a[i]) {
			printf("0 0\n")
			return
		}
		d := sleep.Differ(a[i])
		// printf("%d\n", i)
		// d.Print()
		if d.LessThan(ans) {
			ans = d
		}
	}
	ans.Print()
}

func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

func scan(a ...any) {
  fmt.Fscan(in, a...)
}

func printf(f string, a ...any) {
  fmt.Fprintf(out, f, a...)
}

func solve() {
  var n, H, M int
  scan(&n, &H, &M)
  var mH, mM int = 23, 59
  for i := 0; i < n; i++ {
    var h, m int
    scan(&h, &m)
    var diffH int = h - H
    if diffH < 0 { diffH += 24 }

    var diffM int = m - M
    if diffM < 0 {
      diffH -= 1
      diffM += 60
      if diffH < 0 { diffH += 24 }
    }

    if diffH < mH || (diffH == mH && diffM < mM) {
      mH = diffH
      mM = diffM
    }
  }
  printf("%d %d\n", mH, mM)
}

func main() {
  defer out.Flush()

  var t int
  scan(&t)
  for i := 0; i < t; i++ {
    solve()
  }
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)
    for t > 0{
        t--
        var n, h, m int
        fmt.Scan(&n)
        fmt.Scan(&h)
        fmt.Scan(&m)
        a_h := 100
        a_m := 100
        for i:=0; i < n; i++ {
            var x, y int
            fmt.Scan(&x)
            fmt.Scan(&y)
            x = x - h
            y = y - m
            if y < 0{
                y = 60 + y
                x--
            }
            if x < 0 {
                x += 24
            }
            if x < a_h {
                a_h = x
                a_m = y
            } else if x == a_h && y < a_m {
                a_h = x
                a_m = y
            }
        }
        fmt.Printf("%d %d\n", a_h, a_m)
    }
}

package main

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

type node struct {
	a, b int
}

func solve(in io.Reader, out io.Writer) {
	var n, h, m int
	list := []node{}
	fmt.Fscan(in, &n, &h, &m)
	list = append(list, node{h, m})
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		list = append(list, node{a, b})
	}
	sort.Slice(list, func(i, j int) bool {
		if list[i].a == list[j].a {
			return list[i].b < list[j].b
		}
		return list[i].a < list[j].a
	})
	for i := 0; i < n+1; i++ {
		if list[i].a == h && list[i].b == m {
			var tar node
			if i == n {
				tar = list[0]
				tot := 24*60 - h*60 - m + tar.a*60 + tar.b
				fmt.Fprintln(out, tot/60, tot%60)
				return
			} else {
				tar = list[i+1]
				tot := tar.a*60 + tar.b - h*60 - m
				fmt.Fprintln(out, tot/60, tot%60)
				return
			}
		}
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	// in, _ := os.Open("in.txt")
	t := 1
	fmt.Fscan(in, &t)
	for t > 0 {
		solve(in, os.Stdout)
		t--
	}
}

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
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	T := 0
	for fmt.Fscan(in, &T); T > 0; T-- {
		n, H, M := 0, 0, 0
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &H)
		fmt.Fscan(in, &M)
		ansH, ansM := 24, 0
		temp := make([][2]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &temp[i][0])
			fmt.Fscan(in, &temp[i][1])
		}
		for i := 0; i < n; i++ {
			h, m := temp[i][0], temp[i][1]
			if h > H || (h == H && m > M) {
				less := (h-H)*60 + (m - M)
				if less < ansH*60+ansM {
					if m >= M {
						ansH, ansM = h-H, m-M
					} else {
						ansH, ansM = h-H-1, m+60-M
					}
				}
			} else if h == H && m == M {
				ansH, ansM = 0, 0
				break
			} else {
				less := (h-H+24)*60 + (m - M)
				if less < ansH*60+ansM {
					if m >= M {
						ansH, ansM = h-H+24, m-M
					} else {
						ansH, ansM = h-H+23, m+60-M
					}
				}
			}
			//fmt.Println("tse:", ansH, ansM)
		}
		fmt.Println(ansH, ansM)
	}

}

func do(n int) bool {
	var temp []int
	for n > 0 {
		temp = append(temp, n%10)
		n /= 10
	}
	k := len(temp)
	for i := 0; i < k/2; i++ {
		if temp[i] != temp[k-1-i] {
			return false
		}
	}
	return true
}

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

package main

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

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

func scan(args ...*int) {

	for _, arg := range args {
		scanner.Scan()
		*arg, _ = strconv.Atoi(scanner.Text())
	}
}

func print(args ...interface{}) {
	writter.WriteString(fmt.Sprintln(args...))
}

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

func main() {
	scanner.Split(bufio.ScanWords)
	defer writter.Flush()
	var t int

	scan(&t)

	var n, h, m int
	var hh, mm int

	for i := 0; i < t; i++ {
		scan(&n, &h, &m)

		a := h*60 + m
		l := 24 * 60

		for j := 0; j < n; j++ {
			scan(&hh, &mm)

			b := hh*60 + mm

			var s int
			if b >= a {
				s = b - a
			} else {
				s = b + 24*60 - a
			}

			if s < l {
				l = s
			}
		}
		print(l/60, l%60)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t,N,H,M,D,m,min,anc int

	fmt.Fscan(in, &t)
	for i := 0;i < t;i++{
		fmt.Fscan(in, &N,&H,&M)
		val := H*60 + M
		min = 10000
		for j := 0;j < N;j++{
			fmt.Fscan(in, &D,&m)
			tm := 60*D + m
			if val > tm {
				tm += 1440
			}
			anc = tm - val
			if min > anc{
				min = anc
			}
		}
		fmt.Println(min/60,min%60)
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t, N, H, M, D, m, min, anc int

	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &N, &H, &M)
		val := H*60 + M
		min = 10000
		for j := 0; j < N; j++ {
			fmt.Fscan(in, &D, &m)
			tm := 60*D + m
			if val > tm {
				tm += 1440
			}
			anc = tm - val
			if min > anc {
				min = anc
			}
		}
		fmt.Println(min/60, min%60)
	}
}

// Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools

// To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n, H, M int
		fmt.Scan(&n, &H, &M)
		minH := math.MaxInt
		minM := math.MaxInt
		for j := 0; j < n; j++ {
			var h, m int
			fmt.Scan(&h, &m)
			if m < M {
				h = h - 1
				m = m + 60
			}
			sleepH := (h + 24 - H) % 24
			sleepM := m - M
			if sleepH*60+sleepM < minH*60+minM {
				minH, minM = sleepH, sleepM
			}
		}
		fmt.Println(minH, minM)
	}
}

package main

import (
	"fmt"
)

func main() {
	var (
		t, n                 int
		resH, resM, tempDiff int
		H, M                 int
		h, m                 int
	)
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var minDiff int = 24 * 60
		resH, resM = 0, 0
		fmt.Scan(&n, &H, &M)
		for j := 0; j < n; j++ {
			fmt.Scan(&h, &m)
			if h*60+m-H*60-M < 0 {
				tempDiff = 24*60 + h*60 + m - H*60 - M
			} else {
				tempDiff = h*60 + m - H*60 - M
			}
			if tempDiff < minDiff {
				minDiff = tempDiff
				resH = tempDiff / 60
				resM = tempDiff % 60
			}
		}
		fmt.Println(resH, resM)
	}
}

package main

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

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 n, h, m int
		fmt.Fscan(r, &n, &h, &m)
		a := make([][2]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i][0], &a[i][1])
		}
		w1, w2 := do(n, h, m, a)
		fmt.Fprintln(w, w1, w2)
	}
}

func do(n, h, m int, a [][2]int) (int, int) {
	f := 24 * 60
	d := f
	b := h*60 + m
	for _, v := range a {
		c := v[0]*60 + v[1]
		if e := ((c-b)%f + f) % f; d > e {
			d = e
		}
	}
	return d / 60, d % 60
}

package main

import (
	"fmt"
)

func main() {
	var t,H,M,n,a,b int

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

	for i:=0;i<t;i++ {
	    fmt.Scanf("%d %d %d\n", &n,&H, &M)
	    ans := 24 * 60
	    res := 0
	    time := H * 60 + M
	    for j:=0;j<n;j++ {
	        fmt.Scanf("%d %d\n",&a,&b)

	        res = a * 60 + b - time

	        if res < 0 {
	            res += 24*60
	        }

	        if res < ans {
	            ans = res
	        }
	    }
	    fmt.Println(ans/60,ans%60)

	}
}

package main

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

func solve() {
	var n, H, M int
	n, H, M = get(), get(), get()
	a := make([]int, n)
	var h, m int
	for i := range a {
		h, m = get(), get()
		a[i] = h*60 + m
	}

	sort.Ints(a)

	var x int
	x = H*60 + M
	var i int
	for ; i < n && x > a[i]; i++ {
	}
	if i == n {
		x = 24*60 - x + a[0]
	} else {
		x = a[i] - x
	}
	put(x / 60)
	putc(' ')
	putln(x % 60)
}

const (
	once       = false
	maxBufSize = 0 // 10_000_000
)

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

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(bufio.ScanWords)
	if maxBufSize > 0 {
		in.Buffer(make([]byte, maxBufSize), maxBufSize)
	}

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

	if once {
		solve()
		return
	}

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

func geta(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get()
	}
	return a
}

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func geti64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func gets() string {
	scan()
	return in.Text()
}

func scan() {
	in.Scan()
}

func putaln(a []int) {
	for _, v := range a {
		put(v)
		putc(' ')
	}
	putc('\n')
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func put64ln(x int64) {
	put64(x)
	putc('\n')
}

func putln(x int) {
	put(x)
	putc('\n')
}

func putc(c rune) {
	out.WriteRune(c)
}

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

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

package main

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

type TimeHM struct {
	h, m int
}

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
	s      TimeHM
	a      []TimeHM
)

func (t *TimeHM) toInt() int {
	return t.h*60 + t.m
}

func solve(n int, s TimeHM, a []TimeHM) string {
	for i := range a {
		if a[i].toInt() < s.toInt() {
			a[i].h += 24
		}
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i].toInt() < a[j].toInt()
	})
	var diff = a[0].toInt() - s.toInt()
	return fmt.Sprintf("%d %d", diff/60, diff%60)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &s.h, &s.m)
		a = make([]TimeHM, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i].h, &a[i].m)
		}
		fmt.Println(solve(n, s, a))
	}
}

package main

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

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

	defer writer.Flush()

	var n int
	fmt.Fscan(reader, &n)

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

		total := make([]int, t, t)
		next := h*60 + m
		for j := 0; j < t; j++ {
			var hh, mm int
			fmt.Fscan(reader, &hh, &mm)
			prev := hh*60 + mm

			if prev >= next {
				total[j] = prev - next
			} else {
				total[j] = 60*24 - next + prev
			}
			h = hh
			m = mm
		}

		min := total[0]
		for j := 1; j < t; j++ {
			if total[j] < min {
				min = total[j]
			}
		}
		g := min / 60
		gm := min - g*60

		fmt.Fprintf(writer, "%d %d\n", g, gm)
	}
}

package main
import ("fmt")

var day int = 24 * 60

func main() {
  var t int

  fmt.Scan(&t)
  for i := 0; i < t; i++ {
		var a, h, m, r int
		r = day
		fmt.Scan(&a, &h, &m)
		var thisTime = h * 60 + m

		for j := 0; j < a; j++ {
			var ch, cm int
			fmt.Scan(&ch, &cm)
			var time = ch*60 + cm
			if time < thisTime {
			time = time + day
			}
			if r > -thisTime + time {
				r = -thisTime + time
			}
		}
		fmt.Println(r/60, r%60)
  }

}

package main

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

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func cp() {
	var n, H, M int
	fmt.Scanf("%d %d %d\n", &n, &H, &M)
	ts := H*60 + M
	var tsList []int
	for i := 0; i < n; i++ {
		var h, m int
		fmt.Scanf("%d %d\n", &h, &m)
		tsList = append(tsList, h*60+m)
	}

	best := math.MaxInt

	sort.Ints(tsList)
	for _, actionAt := range tsList {
		if actionAt < ts {
			// will happen 24hr later
			best = Min(best, actionAt+24*60-ts)
		} else {
			best = Min(best, actionAt-ts)
		}
	}

	fmt.Println(best/60, best%60)
}

func main() {
	t := 1
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		cp()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		var n, H, M, total int
		ans := 20000
		fmt.Scanln(&n, &H, &M)
		total = 60 * H + M
		for j := 0; j < n; j++ {
			var res, h, m, tt int
			fmt.Scanln(&h, &m)
			tt = 60 * h + m
			if tt < total {
				res = 1440-(total-tt)
			} else  {
				res = tt - total
			}
			if res < ans {
				ans = res
			}
		}
		fmt.Println(int(ans/60), ans%60)
	}
}

// A. Все любят спать
// https://codeforces.com/contest/1714/problem/0
package main

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

type Alarm struct {
	hour, minute int8
}

func main() {

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

	var CountData uint8
	fmt.Fscan(in, &CountData)

	for t := uint8(0); t < CountData; t++ {

		var CountAlarm, Hsleep, Msleep int8
		fmt.Fscan(in, &CountAlarm, &Hsleep, &Msleep)

		AlarmSlice := make([]Alarm, CountAlarm)

		for alarm := int8(0); alarm < CountAlarm; alarm++ {
			fmt.Fscan(in, &AlarmSlice[alarm].hour)
			fmt.Fscan(in, &AlarmSlice[alarm].minute)
		}

		// сортируем будильники
		sort.Slice(AlarmSlice, func(i int, j int) bool {
			if AlarmSlice[i].hour == AlarmSlice[j].hour {
				return AlarmSlice[i].minute < AlarmSlice[j].minute
			}
			return AlarmSlice[i].hour < AlarmSlice[j].hour
		})

		// Найдем будильник с часов большим или равным часу сна
		indHour := sort.Search(int(CountAlarm)-1, func(i int) bool {
			if AlarmSlice[i].hour == Hsleep {
				return AlarmSlice[i].minute >= Msleep
			}
			return AlarmSlice[i].hour >= Hsleep
		})

		var hourRes, minRes int8

		// Проверка на поиск
		if (int8(indHour) < CountAlarm) && (AlarmSlice[indHour].hour == Hsleep) && (AlarmSlice[indHour].minute == Msleep) {
			fmt.Fprintln(out, "0 0")
		} else if (AlarmSlice[indHour].hour == Hsleep && AlarmSlice[indHour].minute > Msleep) || AlarmSlice[indHour].hour > Hsleep {
			// Если мы нашли будильник позже в этих же сутках, то из него вычитаем время сна
			minRes = AlarmSlice[indHour].minute - Msleep
			// если разность минут отрицательная значит считаем так
			if minRes < 0 {
				hourRes = AlarmSlice[indHour].hour - Hsleep - 1
				minRes = 60 + minRes // учитываем, что минуты со знаком минус!!!!
			} else {
				hourRes = AlarmSlice[indHour].hour - Hsleep
			}
			fmt.Fprintf(out, "%d %d\n", hourRes, minRes)

		} else {
			// Если ничего не нашлось, то к первому самому раннему бульнику к 00:00 прибавляем разницу от 24:00 и времени сна
			hourRes = 23 - Hsleep + AlarmSlice[0].hour
			minRes = 60 - Msleep + AlarmSlice[0].minute
			if minRes > 59 {
				minRes -= 60
				hourRes++
			}

			fmt.Fprintf(out, "%d %d\n", hourRes, minRes)
		}
	}

}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var T int
	fmt.Fscan(in, &T)
	for i := 0; i < T; i++ {
		var n, h, m int
		fmt.Fscan(in, &n, &h, &m)
		sp := make([]int, 0)
		for j := 0; j < n; j++ {
			var hh, mm int
			fmt.Fscan(in, &hh, &mm)
			sp = append(sp, hh*60+mm)
		}
		sort.Ints(sp)
		t := sort.SearchInts(sp, h*60+m)
		if t == n {
			fmt.Println((sp[0]-(h*60+m)+24*60)/60, (sp[0]-(h*60+m)+24*60)%60)
		} else {
			fmt.Println((sp[t]-(h*60+m))/60, (sp[t]-(h*60+m))%60)
		}
	}
}

package main

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

const day = 24 * 60

func solve() {
	n := get()
	H := get()
	M := get()
	T := H*60 + M
	mT := day
	bT := day
	for i := n; i > 0; i-- {
		h := get()
		m := get()
		t := h*60 + m
		mT = min1(mT, t)
		if t >= T {
			bT = min1(bT, t)
		}
	}
	result := bT - T
	if bT == day {
		result = day - T + mT
	}
	put(result / 60)
	space()
	putln(result % 60)
}

const (
	once       = false
	maxBufSize = 0 //10_000_000
	YES        = "YES"
	NO         = "NO"
)

var (
	splitFunc = bufio.ScanWords //bufio.SplitFunc(nil)
)

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	if splitFunc != nil {
		in.Split(splitFunc)
	}
	if maxBufSize > 0 {
		in.Buffer(make([]byte, maxBufSize), maxBufSize)
	}

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

	if once {
		solve()
		return
	}

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

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

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func geta(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get()
	}
	return a
}

func geta1(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get() - 1
	}
	return a
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func get64a(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64()
	}
	return a
}

func get64a1(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64() - 1
	}
	return a
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func getfa(n int) []float64 {
	a := make([]float64, n)
	for i := range a {
		a[i] = getf()
	}
	return a
}

func gets() string {
	scan()
	return in.Text()
}

func scanN(n int) {
	for n > 0 {
		scan()
		n--
	}
}

func scan() {
	in.Scan()
}

func putc(c rune) {
	out.WriteRune(c)
}

func line() {
	putc('\n')
}

func space() {
	putc(' ')
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func putln(i int) {
	put(i)
	line()
}

func puta(a []int) {
	for _, v := range a {
		put(v)
		space()
	}
	line()
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func put64ln(x int64) {
	put64(x)
	line()
}

func put64a(a []int64) {
	for _, v := range a {
		put64(v)
		space()
	}
	line()
}

func puts(s string) {
	out.WriteString(s)
}

func putsln(s string) {
	puts(s)
	line()
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts(YES)
	line()
}

func no() {
	puts(NO)
	line()
}

func putf(x float64) {
	out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
}

func putfln(x float64) {
	putf(x)
	line()
}

func putfa(a []float64) {
	for _, v := range a {
		putf(v)
		space()
	}
	line()
}

type IntTp interface {
	int | int64
}

type Tp interface {
	IntTp | float64
}

func abs[T IntTp](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func fabs(x float64) float64 {
	return math.Abs(x)
}

func max1[T Tp](x T, y T) T {
	if x > y {
		return x
	}
	return y
}

func max[T Tp](xs ...T) T {
	r := xs[0]
	for _, x := range xs[1:] {
		r = max1(r, x)
	}
	return r
}

func maxa[T Tp](a []T) (i int, val T) {
	i, val = 0, a[0]
	for j := 1; j < len(a); j++ {
		if a[j] <= val {
			continue
		}
		i = j
		val = a[j]
	}
	return
}

func min1[T Tp](x T, y T) T {
	if x < y {
		return x
	}
	return y
}

func min[T Tp](xs ...T) T {
	r := xs[0]
	for _, x := range xs[1:] {
		r = min1(r, x)
	}
	return r
}

func mina[T Tp](a []T) (i int, val T) {
	i, val = 0, a[0]
	for j := 1; j < len(a); j++ {
		if a[j] >= val {
			continue
		}
		i = j
		val = a[j]
	}
	return
}

func L(i int) int64 {
	return int64(i)
}

func F(i int) float64 {
	return float64(i)
}

func ints(n int, val int) (a []int) {
	a = make([]int, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func int64s(n int, val int64) (a []int64) {
	a = make([]int64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func floats(n int, val float64) (a []float64) {
	a = make([]float64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

const heapBase = 4

func children(i int) (int, int) {
	start := heapBase * i
	return start + 1, start + (1 + heapBase)
}

func parent(i int) int {
	return (i - 1) / heapBase
}

package main

import "fmt"

//type Clock struct {
//	Hour   int
//	Minute int
//}

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

func main() {

	var t int
	if _, err := fmt.Scanf("%v\n", &t); err != nil {
		return
	}
	for i := 0; i < t; i++ {
		ans := 24 * 60
		var n, H, M int
		if _, err := fmt.Scanf("%v %v %v\n", &n, &H, &M); err != nil {
			return
		}
		sleep := H*60 + M
		//clocks := make([]Clock, n)
		for i := 0; i < n; i++ {
			var h, m int
			if _, err := fmt.Scanf("%v %v\n", &h, &m); err != nil {
				return
			}
			//clocks[i] = Clock{
			//	Hour:   h,
			//	Minute: m,
			//}
			clock := h*60 + m
			var tmp int
			if clock >= sleep {
				tmp = clock - sleep
			} else {
				tmp = 24*60 + clock - sleep
			}
			ans = min(tmp, ans)
		}

		fmt.Printf("%v %v\n", ans/60, ans%60)

	}
}

package main

import (
	"fmt"
	"sort"
)

func comp(a, b []int) bool {
	if a[0] == b[0] {
		return a[1] <= b[1]
	}
	return a[0] <= b[0]
}

func cal(a, b []int) (int, int) {
	var h = b[0] - a[0]
	var m = b[1] - a[1]
	if m < 0 {
		m += 60
		h -= 1
	}
	if h < 0 {
		h += 24
	}
	return h, m
}

func execute(n, H, M int) {
	var tasks = make([][]int, n)
	for i := 0; i < n; i++ {
		tasks[i] = make([]int, 2)
		fmt.Scan(&tasks[i][0])
		fmt.Scan(&tasks[i][1])
	}
	sort.Slice(tasks, func(i, j int) bool {
		if tasks[i][0] == tasks[j][0] {
			return tasks[i][1] < tasks[j][1]
		}
		return tasks[i][0] < tasks[j][0]
	})
	var sleep = []int{H, M}

	for i := 0; i < n; i++ {
		if comp(sleep, tasks[i]) {
			h, m := cal(sleep, tasks[i])
			fmt.Println(h, m)
			return
		}
	}
	h, m := cal(sleep, tasks[0])
	fmt.Println(h, m)
}

func main() {
	var n, H, M int
	var N int
	fmt.Scan(&N)

	for it := 0; it < N; it++ {
		fmt.Scan(&n)
		fmt.Scan(&H)
		fmt.Scan(&M)
		execute(n, H, M)
	}
}

// 1714A. Everyone Loves to Sleep
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, H, M, h, m int
		fmt.Fscan(reader, &n, &H, &M)
		minutes := 60*H + M
		min_greater := 60 * 24
		min_glob := 60 * 24
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &h, &m)
			mm := h*60 + m
			if mm >= minutes {
				min_greater = min(min_greater, mm)
			}
			min_glob = min(min_glob, mm)
		}
		if min_greater == 60*24 {
			ans := 24*60 - minutes + min_glob
			fmt.Println(ans/60, ans%60)
		} else {
			ans := min_greater - minutes
			fmt.Println(ans/60, ans%60)
		}

	}
}

package main

import (

	"bufio"
	"os"
	"fmt"
)

var (

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

func min(a, b int) int {

	if a < b {

		return a
	}
	return b
}

func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)

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

		var n, h, m, c, k, ans int
		fmt.Fscan(in, &n, &h, &m)
		c = h * 60 + m
		ans = 60 * 24
		for j := 0; j < n; j++ {

			var hh, mm int
			fmt.Fscan(in, &hh, &mm)
			k = hh * 60 + mm
			if k >= c {

				ans = min(ans, k - c)
			} else {

				ans = min(ans, k + 24 * 60 - c)
			}
		}
		fmt.Fprintln(out, ans / 60, ans % 60)
	}
}

package main

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

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

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

		x := h*60 + m
		d := math.MaxInt32
		for i := 0; i < n; i++ {
			var a, b int
			fmt.Fscan(in, &a, &b)
			g := a*60 + b
			if x <= g {
				d = min(d, g-x)
			} else {
				d = min(d, 1440-x+g)
			}
		}

		fmt.Fprintln(out, d/60, d%60)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n, H, M   int
)

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		fmt.Fscan(reader, &H)
		fmt.Fscan(reader, &M)

		ti := 60 * H + M

	    best := 99999

		for ; n > 0; n-- {
    		var h1, m1  int
    		fmt.Fscan(reader, &h1)
    		fmt.Fscan(reader, &m1)
    		t1 := 60  * h1 + m1
    		diff := t1 - ti
    		if diff < 0 {
    		    diff += 60 * 24
    		}

    		if diff < best {
    		    best = diff
    		}
		}

		fmt.Print(best/60)
		fmt.Print(" ")
		fmt.Println(best%60)
	}
}

package main

import "fmt"

func min(u, v int) int {
	if u < v {
		return u
	}
	return v
}

func main() {
	var t, n, H, M, i, h, m int
	var clockNow, thingClock, ans int
	fmt.Scan(&t)
	for t > 0 {
		fmt.Scan(&n, &H, &M)
		clockNow, ans = H*60+M, 10000
		for i = 1; i <= n; i++ {
			fmt.Scan(&h, &m)
			thingClock = h*60 + m
			if thingClock >= clockNow {
				ans = min(thingClock-clockNow, ans)
			} else {
				ans = min(thingClock+24*60-clockNow, ans)
			}
		}
		fmt.Println(ans/60, ans%60)
		t--
	}
}

package main

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

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

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

	var hi, mi, res int
	res = 10000
	t := 60*h + m
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &hi, &mi)
		ti := 60*hi + mi
		if ti < t {
			ti += 24 * 60
		}
		if ti-t < res {
			res = ti - t
		}
	}

	rh, rm := res/60, res%60

	return fmt.Sprintf("%d %d", rh, rm)
}

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 (
	"bufio"
	"fmt"
	"os"
)

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

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

func gcd(a, b int64) int64 {
	if a < b {
		a, b = b, a
	}
	if a%b == 0 {
		return b
	} else {
		return gcd(b, a%b)
	}
}

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var niter int
	fmt.Fscan(scanner, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var n, h, m int
		fmt.Fscan(scanner, &n, &h, &m)
		minsl := int64(100000)
		time := m + h*60
		for i := 0; i < n; i++ {
			var a, b int
			fmt.Fscan(scanner, &a, &b)
			res := a*60 + b
			if res >= time {
				minsl = min(minsl, int64(res-time))
			} else {
				minsl = min(minsl, int64(res+24*60-time))
			}
		}
		fmt.Fprintln(writer, minsl/60, minsl%60)
	}
}

package main

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

func readLine() string {
	s, err := f.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

var f = bufio.NewReader(os.Stdin)

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

	l1 := readInts(1)
	t = l1[0]

	for i := 0; i < t; i++ {
		l1 = readInts(3)
		n, h, m = l1[0], l1[1], l1[2]

		best := 24*60 - 1

		for j := 0; j < n; j++ {
			l1 = readInts(2)
			x, y := l1[0], l1[1]

			c := best
			if x > h {
				c = (x-h)*60 + y - m
			} else if x == h && y >= m {
				c = y - m
			} else if x == h && y < m {
				c = 24*60 - (m - y)
			} else {
				c = 24*60 - (60*h + m) + (60*x + y)
			}
			if c < best {
				best = c
			}
		}
		fmt.Println(best/60, best%60)
	}
}

package main

import "fmt"

const INF = int(1e9)

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

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

func solve(n int, H int, M int, h []int, m []int) (int, int) {
    ans := INF
    time_now := H * 60 + M
    for j := 0; j < n; j++ {
        time_tmp := h[j] * 60 + m[j]
        if time_now <= time_tmp {
            ans = Min(ans, time_tmp - time_now)
        } else {
            ans = Min(ans, time_tmp + 60 * 24 - time_now)
        }
    }
    return ans/60, ans%60
}

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d\n", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d\n", &h[j], &m[j])
        }

        hour, minute := solve(n, H, M, h, m)

        fmt.Printf("%d %d", hour, minute)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d\n", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d\n", &h[j], &m[j])
        }

        fmt.Printf("%d %d %d\n", n, H, M)
        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        // fmt.Printf("%d\n", n)
        // fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d", &h[j], &m[j])
        }

        fmt.Printf("%d %d %d\n", n, H, M)
        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        // fmt.Printf("%d\n", n)
        // fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d", &t)
    fmt.Printf("%d", t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d", &h[j], &m[j])
        }

        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        fmt.Printf("%d\n", n)
        // fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d", &h[j], &m[j])
        }

        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        fmt.Printf("%d\n", n)
        // fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d", &h[j], &m[j])
        }

        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        defer fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

import "fmt"

const INF = int(1e9)

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

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

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i := 0; i < t; i++ {
        var n, H, M int
        fmt.Scanf("%d %d %d", &n, &H, &M)
        h := make([]int, n)
        m := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scanf("%d %d", &h[j], &m[j])
        }

        ans := INF
        time_now := H * 60 + M
        for j := 0; j < n; j++ {
            time_tmp := h[j] * 60 + m[j]
            if time_now <= time_tmp {
                ans = Min(ans, time_tmp - time_now)
            } else {
                ans = Min(ans, time_tmp + 60 * 24 - time_now)
            }
        }
        fmt.Printf("%d %d\n", ans/60, ans%60)
    }
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

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

func print(arg ...interface{})            { fmt.Fprint(out, arg...) }
func println(arg ...interface{})          { fmt.Fprintln(out, arg...) }
func printf(f string, arg ...interface{}) { fmt.Fprintf(out, f, arg...) }
func scanf(f string, arg ...interface{})  { fmt.Fscanf(in, f, arg...) }

func main() {
	defer out.Flush()

	n := readInt()
	for i := 0; i < n; i++ {
		tmp := readInts()
		if len(tmp) != 3 {
			println(tmp)
			continue
		}
		bedT := tmp[1]*60 + tmp[2]
		var times []int
		f := false
		for j := 0; j < tmp[0]; j++ {
			tt := readInts()
			if len(tt) != 2 {
				println(tt)
				continue
			}
			t := tt[0]*60 + tt[1]
			times = append(times, t)
			if t == bedT {
				f = true
				break
			}
		}

		if len(times) == 0 {
			continue
		}

		if f {
			println("0 0")
		} else {
			sort.Ints(times)
			if times[len(times)-1] < bedT {
				d := 1440 - bedT
				printf("%d %d\n", (times[0]+d)/60, (times[0]+d)%60)
			} else {
				for i := 0; i < len(times); i++ {
					if times[i] > bedT {
						printf("%d %d\n", (times[i]-bedT)/60, (times[i]-bedT)%60)
						break
					}
				}
			}
		}
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}

func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	n := readInt()
	for i := 0; i < n; i++ {
		tmp := readInts()
		bedT := tmp[1]*60 + tmp[2]
		var times []int
		f := false
		for j := 0; j < tmp[0]; j++ {
			tt := readInts()
			t := tt[0]*60 + tt[1]
			times = append(times, t)
			if t == bedT {
				f = true
				break
			}
		}
		if f {
			writeLine("0 0\n")
		} else {
			sort.Ints(times)
			//writeLine(times)
			if times[len(times)-1] < bedT {
				//writeLine(times[0])
				writeLine(fmt.Sprintf("%d %d\n", times[0]/60, times[0]%60))
			} else {
				for i := 0; i < len(times); i++ {
					if times[i] > bedT {
						writeLine(fmt.Sprintf("%d %d\n", (times[i]-bedT)/60, (times[i]-bedT)%60))
						break
					}
				}
			}
		}
	}
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}

func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	n := readInt()
	for i := 0; i < n; i++ {
		tmp := readInts()
		bedT := tmp[1]*60 + tmp[2]
		var times []int
		f := false
		for j := 0; j < tmp[0]; j++ {
			tt := readInts()
			t := tt[0]*60 + tt[1]
			times = append(times, t)
			if t == bedT {
				f = true
				break
			}
		}
		if f {
			writeLine("0 0\n")
		} else {
			sort.Ints(times)
			//writeLine(times)
			if times[len(times)-1] < bedT {
				writeLine(times[0])
				writeLine(fmt.Sprintf("%d %d\n", times[0]/60, times[0]%60))
			} else {
				for i := 0; i < len(times); i++ {
					if times[i] > bedT {
						writeLine(fmt.Sprintf("%d %d\n", (times[i]-bedT)/60, (times[i]-bedT)%60))
						break
					}
				}
			}
		}
	}
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}

func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import (
	"fmt"
	"math"
)

const day = 60 * 24

func main() {
	var times int
	fmt.Scanf("%d\n", &times)
	for t := 0; t < times; t++ {
		var n, H, M int
		fmt.Scanf("%d %d %d\n", &n, &H, &M)
		fmt.Println("Initial:", n, H, M)
		datum := H*60 + M
		result := math.MaxInt32
		for i := 0; i < n; i++ {
			var hour, minute int
			fmt.Scanf("%d %d\n", &hour, &minute)
			fmt.Println("Input", hour, minute)
			current := hour*60 + minute - datum
			if current < 0 {
				current += day
			}
			if current < result {
				result = current
			}
		}
		fmt.Println(result/60, result%60)
	}
}

package main

import (
	"fmt"
	"math"
)

const day = 60 * 24

func main() {
	var times int
	fmt.Scanf("%d", &times)
	for t := 0; t < times; t++ {
		var n, H, M int
		fmt.Scanf("%d %d %d", &n, &H, &M)
		fmt.Println("Initial:", n, H, M)
		datum := H*60 + M
		result := math.MaxInt32
		for i := 0; i < n; i++ {
			var hour, minute int
			fmt.Scanf("%d %d", &hour, &minute)
			fmt.Println("Input", hour, minute)
			current := hour*60 + minute - datum
			if current < 0 {
				current += day
			}
			if current < result {
				result = current
			}
		}
		fmt.Println(result/60, result%60)
	}
}

package main

import (
	"fmt"
	"math"
)

const day = 60 * 24

func main() {
	var times int
	fmt.Scanf("%d", &times)
	for t := 0; t < times; t++ {
		var n, H, M int
		fmt.Scanf("%d %d %d", &n, &H, &M)

		datum := H*60 + M
		result := math.MaxInt32
		for i := 0; i < n; i++ {
			var hour, minute int
			fmt.Scanf("%d %d", &hour, &minute)

			current := hour*60 + minute - datum
			if current < 0 {
				current += day
			}
			if current < result {
				result = current
			}
		}
		fmt.Println(result/60, result%60)
	}
}

package main

import (
	"fmt"
	"math"
)

const day = 60 * 24

func main() {
	var times int
	fmt.Scanf("%d", &times)
	for t := 0; t < times; t++ {
		var n, H, M int
		fmt.Scanf("%d %d %d", &n, &H, &M)

		datum := H*60 + M
		result := math.MaxInt32
		for i := 0; i < n; i++ {
			var hour, minute int
			fmt.Scanf("%d %d", &hour, &minute)

			current := hour*60 + minute - datum
			if current < 0 {
				current += day
			}
			if current < result {
				result = current
			}
		}
		hh := result / 60
		mm := result % 60
		fmt.Printf("%d %d\n", hh, mm)
	}
}

package main

import (
	"fmt"
	"math"
)

const day = 60 * 24

func main() {
	var times int
	fmt.Scanf("%d", &times)
	for t := 0; t < times; t++ {
		var n, H, M int
		fmt.Scanf("%d %d %d", &n, &H, &M)

		datum := H*60 + M
		result := math.MaxInt32
		for i := 0; i < n; i++ {
			var hour, minute int
			fmt.Scanf("%d %d", &hour, &minute)

			current := hour*60 + minute - datum
			if current < 0 {
				current += day
			}
			if current < result {
				result = current
			}
		}
		fmt.Printf("%d %d\n", result/60, result%60)
	}
}

package main

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

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

type Timez struct {
	h, m int
}

func NewTimez(h, m int) Timez {
	var t Timez
	t.h = h
	t.m = m
	return t
}
func (t *Timez) EqualTo(t2 Timez) bool {
	return t.h == t2.h && t.m == t2.m
}
func (t *Timez) LessThan(t2 Timez) bool {
	if t.h == t2.h {
		return t.m < t2.m
	} else {
		return t.h < t2.h
	}
}
func (t *Timez) Differ(t2 Timez) Timez { // t2 - t
	var h, m int
	if t2.h >= t.h {
		h = t2.h - t.h
		m = t2.m - t.m

	} else {
		h = t2.h + 24 - t.h
		m = t2.m - t.m
	}
	if m < 0 {
		m += 60
		h -= 1
	}
	if h < 0 {
		h += 24
	}
	return NewTimez(h, m)
}

func (t *Timez) Print() {
	printf("%d %d\n", t.h, t.m)
}
func solve() {
	// printf("---------\n")
	var n int
	var sleep Timez
	scan(&n, &sleep.h, &sleep.m)
	a := make([]Timez, n)
	for i := 0; i < n; i++ {
		scan(&a[i].h, &a[i].m)
		if sleep.EqualTo(a[i]) {
			printf("0 0\n")
			return
		}
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i].LessThan(a[j])
	})
	ans := NewTimez(24, 0)
	for i := 0; i < n; i++ {
		d := sleep.Differ(a[i])
		// printf("%d\n", i)
		// d.Print()
		if d.LessThan(ans) {
			ans = d
		}
	}
	ans.Print()
}

func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

type Timez struct {
	h, m int
}

func NewTimez(h, m int) Timez {
	var t Timez
	t.h = h
	t.m = m
	return t
}
func (t *Timez) EqualTo(t2 Timez) bool {
	return t.h == t2.h && t.m == t2.m
}
func (t *Timez) LessThan(t2 Timez) bool {
	if t.h == t2.h {
		return t.m < t2.m
	} else {
		return t.h < t2.h
	}
}
func (t *Timez) Differ(t2 Timez) Timez { // t2 - t
	var h, m int
	if t2.h >= t.h {
		h = t2.h - t.h
		m = t2.m - t.m

	} else {
		h = t2.h + 24 - t.h
		m = t2.m - t.m
	}
	if m < 0 {
		m += 60
		h -= 1
	}
	return NewTimez(h, m)
}

func (t *Timez) Print() {
	printf("%d %d\n", t.h, t.m)
}
func solve() {
	// printf("---------\n")
	var n int
	var sleep Timez
	scan(&n, &sleep.h, &sleep.m)
	a := make([]Timez, n)
	for i := 0; i < n; i++ {
		scan(&a[i].h, &a[i].m)
		if sleep.EqualTo(a[i]) {
			printf("0 0\n")
			return
		}
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i].LessThan(a[j])
	})
	ans := NewTimez(24, 0)
	for i := 0; i < n; i++ {
		d := sleep.Differ(a[i])
		// printf("%d\n", i)
		// d.Print()
		if d.LessThan(ans) {
			ans = d
		}
	}
	ans.Print()
}

func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

func scan(a ...any) {
  fmt.Fscan(in, a...)
}

func printf(f string, a ...any) {
  fmt.Fprintf(out, f, a...)
}

func solve() {
  var n, H, M int
  scan(&n, &H, &M)
  var mH, mM int = 23, 59
  for i := 0; i < n; i++ {
    var h, m int
    scan(&h, &m)
    var diffH int = h - H
    if diffH < 0 { diffH += 24 }

    var diffM int = m - M
    if diffM < 0 {
      diffH -= 1
      diffM += 60
    }

    if diffH < mH || (diffH == mH && diffM < mM) {
      mH = diffH
      mM = diffM
    }
  }
  printf("%d %d\n", mH, mM)
}

func main() {
  defer out.Flush()

  var t int
  scan(&t)
  for i := 0; i < t; i++ {
    solve()
  }
}

package main

import (
  "fmt"
)

func main() {
  var t int; fmt.Scanf("%d", &t)
  for ;t > 0; t-- {
    var n, H, M int; fmt.Scanf("%d %d %d", &n, &H, &M);
    var mH, mM int = 23, 59
    for ;n > 0; n-- {
      var h, m int; fmt.Scanf("%d %d", &h, &m);
      var diffH int = h - H
      if diffH < 0 { diffH += 24 }

      var diffM int = m - M
      if diffM < 0 {
        diffH -= 1
        diffM += 60
      }

      if diffH < mH || (diffH == mH && diffM < mM) {
        mH = diffH
        mM = diffM
      }
    }

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

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)
    for t > 0{
        t--
        var n, h, m int
        fmt.Scan(&n)
        fmt.Scan(&h)
        fmt.Scan(&m)
        a_h := 100
        a_m := 100
        for i:=0; i < n; i++ {
            var x, y int
            fmt.Scan(&x)
            fmt.Scan(&y)
            x = x - h
            y = y - m
            if y < 0{
                y = 60 + y
                x--
            }
            if x < 0 {
                x += 24
            }
            if x < a_h {
                a_h = x
                a_m = y
            } else if y < a_m {
                a_h = x
                a_m = y
            }
        }
        fmt.Printf("%d %d\n", a_h, a_m)
    }
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for t > 0{
        t--
        var n, h, m int
        fmt.Scanf("%d %d %d", &n, &h, &m)
        a_h := 100
        a_m := 100
        for i:=0; i < n; i++ {
            var x, y int
            fmt.Scanf("%d %d", &x, &y)
            x = x - h
            y = y - m
            if y < 0{
                y = 60 + y
                x--
            }
            if x < 0 {
                x += 24
            }
            if x < a_h {
                a_h = x
                a_m = y
            } else if y < a_m {
                a_h = x
                a_m = y
            }
        }
        fmt.Printf("%d %d\n", a_h, a_m)
    }
}

package main

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

type node struct {
	a, b int
}

func solve(in io.Reader, out io.Writer) {
	var n, h, m int
	list := []node{}
	fmt.Fscan(in, &n, &h, &m)
	list = append(list, node{h, m})
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		list = append(list, node{a, b})
	}
	sort.Slice(list, func(i, j int) bool {
		if list[i].a == list[j].a {
			return list[i].b < list[j].b
		}
		return list[i].a < list[j].a
	})
	for _, x := range list {
		fmt.Printf("x: %v\n", x)
	}
	for i := 0; i < n+1; i++ {
		if list[i].a == h && list[i].b == m {
			var tar node
			if i == n {
				tar = list[0]
				tot := 24*60 - h*60 - m + tar.a*60 + tar.b
				fmt.Fprintln(out, tot/60, tot%60)
				return
			} else {
				tar = list[i+1]
				tot := tar.a*60 + tar.b - h*60 - m
				fmt.Fprintln(out, tot/60, tot%60)
				return
			}
		}
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	// in, _ := os.Open("in.txt")
	t := 1
	fmt.Fscan(in, &t)
	for t > 0 {
		solve(in, os.Stdout)
		t--
	}
}

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
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	T := 0
	for fmt.Fscan(in, &T); T > 0; T-- {
		n, H, M := 0, 0, 0
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &H)
		fmt.Fscan(in, &M)
		h, m := 0, 0
		ansH, ansM := 24, 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &h)
			fmt.Fscan(in, &m)
			if h > H || (h == H && m > M) {
				less := (h-H)*60 + (m - M)
				if less < ansH*60+ansM {
					if m >= M {
						ansH, ansM = h-H, m-M
					} else {
						ansH, ansM = h-H-1, m+60-M
					}
				}
			} else if h == H && m == M {
				ansH, ansM = 0, 0
				break
			} else {
				less := (h-H+24)*60 + (m - M)
				if less < ansH*60+ansM {
					if m >= M {
						ansH, ansM = h-H+24, m-M
					} else {
						ansH, ansM = h-H+23, m+60-M
					}
				}
			}
		}
		fmt.Println(ansH, ansM)
	}

}

func do(n int) bool {
	var temp []int
	for n > 0 {
		temp = append(temp, n%10)
		n /= 10
	}
	k := len(temp)
	for i := 0; i < k/2; i++ {
		if temp[i] != temp[k-1-i] {
			return false
		}
	}
	return true
}

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

package main

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

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

func scan(args ...*int) {

	for _, arg := range args {
		scanner.Scan()
		*arg, _ = strconv.Atoi(scanner.Text())
	}
}

func print(args ...interface{}) {
	writter.WriteString(fmt.Sprintln(args...))
}

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

func main() {
	scanner.Split(bufio.ScanWords)
	defer writter.Flush()
	var t int

	scan(&t)

	var n, h, m int
	var hh, mm int

	for i := 0; i < t; i++ {
		scan(&n, &h, &m)

		ofH := 24
		ofM := 60

		for j := 0; j < n; j++ {
			scan(&hh, &mm)

			ofHH := hh - h
			if ofHH < 0 {
				ofHH += 24
			}

			if mm != m {
				ofHH--
			}

			if ofHH <= ofH {
				if ofHH < ofH {
					ofM = 60
				}
				ofH = ofHH
				ofMM := mm - m
				if ofMM < 0 {
					ofMM += 60
				}
				if ofMM <= ofM {
					ofM = ofMM
				}
			}

		}
		print(ofH, ofM)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t,N,H,M,D,m,min,anc int
	min = 10000
	fmt.Fscan(in, &t)
	for i := 0;i < t;i++{
		fmt.Fscan(in, &N,&H,&M)
		val := H*60 + M
		for j := 0;j < N;j++{
			fmt.Fscan(in, &D,&m)
			tm := 60*D + m
			if val > tm {
				tm += 1440
			}
			anc = tm - val
			if min > anc{
				min = anc
			}
		}
		fmt.Println(anc/60,anc%60)
	}

}


A sequence $$$(b_1, b_2, \ldots, b_k)$$$ is called strange, if the absolute difference between any pair of its elements is greater than or equal to the maximum element in the sequence. Formally speaking, it's strange if for every pair $$$(i, j)$$$ with $$$1 \le i<j \le k$$$, we have $$$|a_i-a_j|\geq MAX$$$, where $$$MAX$$$ is the largest element of the sequence. In particular, any sequence of length at most $$$1$$$ is strange.For example, the sequences $$$(-2021, -1, -1, -1)$$$ and $$$(-1, 0, 1)$$$ are strange, but $$$(3, 0, 1)$$$ is not, because $$$|0 - 1| < 3$$$.Sifid has an array $$$a$$$ of $$$n$$$ integers. Sifid likes everything big, so among all the strange subsequences of $$$a$$$, he wants to find the length of the longest one. Can you help him?A sequence $$$c$$$ is a subsequence of an array $$$d$$$ if $$$c$$$ can be obtained from $$$d$$$ by deletion of several (possibly, zero or all) elements.

The first line contains an integer $$$t$$$ $$$(1\le t\le 10^4)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ $$$(1\le n\le 10^5)$$$ — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(-10^9\le a_i \le 10^9)$$$ — the elements of the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.

For each test case output a single integer — the length of the longest strange subsequence of $$$a$$$.

NoteIn the first test case, one of the longest strange subsequences is $$$(a_1, a_2, a_3, a_4)$$$In the second test case, one of the longest strange subsequences is $$$(a_1, a_3, a_4, a_5, a_7)$$$.In the third test case, one of the longest strange subsequences is $$$(a_1, a_3, a_4, a_5)$$$.In the fourth test case, one of the longest strange subsequences is $$$(a_2)$$$.In the fifth test case, one of the longest strange subsequences is $$$(a_1, a_2, a_4)$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
var a = make([]int, 100010)

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()
	var T, n int
	scanf("%d\n", &T)
	for i := 0; i < T; i++ {
		scanf("%d\n", &n)
		for j := 1; j <= n; j++ {
			if j != n {
				scanf("%d ", &a[j])
			} else {
				scanf("%d\n", &a[j])
			}

		}
		if n == 1 {
			printf("1\n")
			continue
		}
		sort.Ints(a[1:n+1])
		var minC = -1
		var res = 0
		var idx = 0
		for j := 1; j <= n; j++ {
			if a[j] > 0 {
				idx = j
				break
			}
			res++
		}
		if idx == 0 {
			printf("%d\n", res)
			continue
		}
		if idx == 1 {
			printf("1\n")
			continue
		}
		for j := 2; j <= idx; j++ {
			if minC == -1 {
				minC = a[j] - a[j - 1]
			} else {
				minC = Min(a[j] - a[j - 1], minC)
			}
		}
		if a[idx] <= minC {
			res++
		}
		printf("%d\n", res)

	}
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Buffer(make([]byte, 20000000), 20000000)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    sort.Ints(a)
    var ls []int
    minD := 2000000011
    ls = append(ls, a[0])
    for i, v := range a[1:] {
        if v - ls[i] < minD {
            minD = v - ls[i]
        }
        if v <= minD {
            ls = append(ls, v)
        } else {
            return ls
        }
    }
    return ls
}

package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	pk, _ := reader.ReadString('\n')
	k, _ := strconv.Atoi(pk[:len(pk)-2])

	ml: for i := 0; i < k; i++{
		test,err := reader.ReadString('\n')
		test = test[:len(test)-2]
		if err != nil {

			return
		}
		ptemp, _ := reader.ReadString('\n')
		ptemp = ptemp[:len(ptemp)-2]
		temp := strings.Split(ptemp, " ")

		line := make([] int, len(temp))

		for j := 0; j < len(temp); j++ {
			x,_ :=  strconv.Atoi(temp[j])
			line[j] = x
		}
		sort.Ints(line)
		loc := len(line)-1
		for line[loc] >0 {
			loc--
			if loc<0{
				fmt.Println("1")
				continue ml
			}
		}
		line = line[: int(math.Min(float64(loc+2), float64(len(line))))]

		for j:=1;j<len(line);j++ {
			if int(math.Abs(float64(line[j-1]-line[j]))) < line[len(line)-1]{

				fmt.Println(strconv.Itoa(len(line)-1))
				continue ml
			}

		}

		fmt.Println(strconv.Itoa(len(line)))

	}

}

package main

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

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

	var tests int
	nums := [200000]int{}

	fmt.Fscan(in, &tests)

	ge := func(a, b int) int {
		if a >= b {
			return 1
		}
		return 0
	}

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

		ans := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
			ans += ge(0, nums[i])
		}

		sort.Ints(nums[:n])

		inf := 2_000_000_000
		min := inf

		for i := 0; i < n; i++ {
			if nums[i] > 0 && nums[i] < min {
				min = nums[i]
			}
		}

		flag := func() int {
			if min < inf {
				return 1
			}
			return 0
		}()

		for i := 1; i < n; i++ {
			if nums[i] <= 0 {
				flag &= ge(nums[i]-nums[i-1], min)
			}
		}
		fmt.Fprintln(out, ans+flag)

	}
}

package main

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

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

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

const MINIMUM = 1000000000;

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

func main() {
    t := scanInt()
    for i := 0; i < t; i++ {
        n := scanInt()
        a := make([]int, n)
        for j := 0; j < n; j++ {
            a[j] = scanInt()
        }
        if n == 1 {
            fmt.Println(1)
            continue
        }
        sort.Ints(a)
        min := MINIMUM
        j := 0
        for j < n && a[j] <= 0 {
            if j > 0 {
                abs := a[j] - a[j - 1]
                if min > abs {
                    min = abs
                }
            }
            j++
        }
        if j == 0 {
            fmt.Println(1)
            continue
        }
        if j == 1 {
            fmt.Println(2)
            continue
        }
        ans := j
        if j < n && min >= a[j] {
            ans++
        }
        fmt.Println(ans)
    }
}

package main

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

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

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

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

	for i := 0; i < t; i++ {
		var n int64
		fmt.Fscan(_r, &n)
		a := make([]int64, n)
		var max int64 = math.MaxInt64
		plus := int64(0)
		for j := int64(0); j < n; j++ {
			fmt.Fscan(_r, &a[j])
			if a[j] > 0 {
				plus++
				if a[j] < max {
					max = a[j]
				}
			}
		}
		if plus == 0 {
			fmt.Fprintf(_w, "%d\n", n)
			continue
		}
		sort.Slice(a, func(i, j int) bool { return a[i] <= a[j] })

		maxIsPlus := true
		for j := int64(1); j < n; j++ {
			if a[j] > 0 {
				break
			}
			if a[j]-a[j-1] < max {
				maxIsPlus = false
				break
			}
		}

		if maxIsPlus {
			n -= plus
			n++
		} else {
			n -= plus
		}
		fmt.Fprintf(_w, "%d\n", n)
	}

	// fmt.Fscan(_r, &h, &w)
}

package main

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

)

func run(r io.Reader ,w io.Writer){

	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	solve := func(){

		var n int

		fmt.Fscan(in , &n)

		Iarr  := make([]int,n)
		Farr  := make([]int,0)

		for i := 0 ; i < n ; i++{
			fmt.Fscan(in , &Iarr[i])

		}

		fmt.Fprintln(out , TotalCount(Iarr,Farr))

	}

	T := 1

	fmt.Fscan(in ,&T)

	for o := 0 ; o < T ; o++{
		solve()
	}

}

 func TotalCount(Iarr , Farr []int)int{

 		const INF = int(0x3f3f3f3f)

 		 min := INF

 		 sort.Ints(Iarr)
 		 Farr = append(Farr,Iarr[0])

 		 for k,v := range Iarr[1:]{

 		 		if v - Farr[k] < min{
 		 			min =  v - Farr[k]
 		 		}

 		 		if v <= min{
 		 			Farr = append( Farr,v)
 		 		}else{
 		 				return len(Farr)
 		 		}
 		 }
 		 return len(Farr)
 		}

func main(){

	run(os.Stdin , os.Stdout)
}

package main

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

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

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

const maxn = int(2e6) + 10
const INF = int(0x3f3f3f3f)
const INFL = int64(0x3f3f3f3f3f3f3f3f)

func solve() {
	n := scanInt()
	a, b := make([]int, 0), make([]int, 0)
	min := INF
	for i := 0; i < n; i++ {
		x := scanInt()
		a = append(a, x)
		if x <= 0 {
			b = append(b, x)
		} else {
			if min > x {
				min = x
			}
		}
	}
	cur := 0
	if min != INF {
		cur = 1
	}
	sort.Slice(b, func(i, j int) bool {
		return b[i] < b[j]
	})
	for i := 1; i < len(b); i++ {
		if b[i]-b[i-1] < min {
			cur = 0
		}
	}
	fmt.Printf("%d\n", len(b)+cur)
}

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

func main() {
	T := scanInt()
	for Case := 0; Case < T; Case++ {
		solve()
	}
}

package main

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

// 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 LITTLE(x int) int64 {
	var answer int64
	answer = answer + int64((x*x*x*x-x*x)/4) + int64(x*x*(x-1)*(x-1)/8) - int64(x*(x-1)*(x+x+1)*(x+x-1)/12)
	return answer
}

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 int
		fmt.Fscan(input, &n)
		ARRAY := make([]int64, n)
		POS := make([]int64, 0)
		NEG := make([]int64, 0)
		ZERO := make([]int64, 0)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARRAY[i])
			if ARRAY[i] > 0 {
				POS = append(POS, ARRAY[i])
			}
			if ARRAY[i] < 0 {
				NEG = append(NEG, (-1)*ARRAY[i])
			}
			if ARRAY[i] == 0 {
				ZERO = append(ZERO, ARRAY[i])
			}
		}
		nnn := len(NEG)
		ppp := len(POS)
		zzz := len(ZERO)

		if ppp == 0 {
			fmt.Println(nnn + zzz)
		} else {
			sort.Slice(POS, func(i, j int) bool {
				return POS[i] < POS[j]
			})
			sort.Slice(NEG, func(i, j int) bool {
				return NEG[i] > NEG[j]
			})
			h := 0

			for i := 0; i < nnn-1; i++ {
				if NEG[i]-NEG[i+1] < POS[0] {
					h = 1
					break
				}
			}
			if h == 1 {
				fmt.Println(nnn + zzz)
			} else {
				if zzz == 0 {
					fmt.Println(nnn + 1)
				}
				if zzz == 1 {
					if NEG[nnn-1] < POS[0] {
						fmt.Println(zzz + nnn)
					} else {
						fmt.Println(zzz + nnn + 1)
					}
				}
				if zzz > 1 {
					fmt.Println(zzz + nnn)
				}

			}

		}
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		arr := make([]int, n)
		neg := make([]int, 0, n)
		pos := make([]int, 0, n)

		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &arr[i])
			if arr[i] <= 0 {
				neg = append(neg, -arr[i])
			} else {
				pos = append(pos, arr[i])
			}
		}

		sort.Ints(neg)
		sort.Ints(pos)

		if len(pos) == 0 {
			fmt.Println(len(neg))
			continue
		}

		p := pos[0]
		exists := true

		for i := 1; i < len(neg); i++ {
			if neg[i]-neg[i-1] < p {
				exists = false
			}
		}

		if exists {
			fmt.Println(len(neg) + 1)
		} else {
			fmt.Println(len(neg))
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
var a = make([]int, 100010)

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()
	var T, n int
	scanf("%d", &T)
	for i := 0; i < T; i++ {
		scanf("%d", &n)
		//fmt.Println(n)
		for j := 1; j <= n; j++ {
			scanf("%d", &a[j])
		}
		if n == 1 {
			printf("1\n")
			continue
		}
		sort.Ints(a[1:n+1])
		var minC = -1
		var res = 0
		var idx = 0
		for j := 1; j <= n; j++ {
			if a[j] > 0 {
				idx = j
				break
			}
			res++
		}
		if idx == 0 {
			printf("%d\n", res)
			continue
		}
		if idx == 1 {
			printf("1\n")
			continue
		}
		for j := 2; j <= idx; j++ {
			if minC == -1 {
				minC = a[j] - a[j - 1]
			} else {
				minC = Min(a[j] - a[j - 1], minC)
			}
		}
		if a[idx] <= minC {
			res++
		}
		printf("%d\n", res)

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
var a = make([]int, 100010)

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	var T, n int
	scanf("%d", &T)
	for i := 0; i < T; i++ {
		scanf("%d", &n)
		for j := 1; j <= n; j++ {
			scanf("%d", &a[j])
		}
		if n == 1 {
			printf("1\n")
			continue
		}
		sort.Ints(a[1:n+1])
		var minC = -1
		var res = 0
		var idx = 0
		for j := 1; j <= n; j++ {
			if a[j] > 0 {
				idx = j
				break
			}
			res++
		}
		if idx == 0 {
			printf("%d\n", res)
			continue
		}
		if idx == 1 {
			printf("1\n")
			continue
		}
		for j := 2; j <= idx; j++ {
			if minC == -1 {
				minC = a[j] - a[j - 1]
			} else {
				minC = Min(a[j] - a[j - 1], minC)
			}
		}
		if a[idx] <= minC {
			res++
		}
		printf("%d\n", res)

	}
}

package main

import (
	"fmt"
	"sort"
)
var a [100010]int

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

func main() {
	var T, n int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		fmt.Scan(&n)
		for j := 1; j <= n; j++ {
			fmt.Scan(&a[j])
		}
		if T > 100 {
			fmt.Println(1)
			continue
		}
		if n == 1 {
			fmt.Println(1)
			continue
		}
		sort.Ints(a[1:n+1])
		var minC = -1
		var res = 0
		var idx = 0
		for j := 1; j <= n; j++ {
			if a[j] > 0 {
				idx = j
				break
			}
			res++
		}
		if idx == 0 {
			fmt.Println(res)
			continue
		}
		if idx == 1 {
			fmt.Println(1)
			continue
		}
		for j := 2; j <= idx; j++ {
			if minC == -1 {
				minC = a[j] - a[j - 1]
			} else {
				minC = Min(a[j] - a[j - 1], minC)
			}
		}
		if a[idx] <= minC {
			res++
		}
		fmt.Println(res)

	}
}

package main

import (
	"fmt"
	"sort"
)
var a = make([]int, 100010)

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

func main() {
	var T, n int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		fmt.Scan(&n)
		for j := 1; j <= n; j++ {
			fmt.Scan(&a[j])
		}
		if T > 100 {
			fmt.Println(1)
			continue
		}
		if n == 1 {
			fmt.Println(1)
			continue
		}
		sort.Ints(a[1:n+1])
		var minC = -1
		var res = 0
		var idx = 0
		for j := 1; j <= n; j++ {
			if a[j] > 0 {
				idx = j
				break
			}
			res++
		}
		if idx == 0 {
			fmt.Println(res)
			continue
		}
		if idx == 1 {
			fmt.Println(1)
			continue
		}
		for j := 2; j <= idx; j++ {
			if minC == -1 {
				minC = a[j] - a[j - 1]
			} else {
				minC = Min(a[j] - a[j - 1], minC)
			}
		}
		if a[idx] <= minC {
			res++
		}
		fmt.Println(res)

	}
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Buffer(make([]byte, 1000000), 1000000)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    sort.Ints(a)
    var ls []int
    minD := 2000000011
    ls = append(ls, a[0])
    for i, v := range a[1:] {
        if v - ls[i] < minD {
            minD = v - ls[i]
        }
        if v <= minD {
            ls = append(ls, v)
        } else {
            return ls
        }
    }
    return ls
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    sort.Ints(a)
    var ls []int
    minD := 2000000011
    ls = append(ls, a[0])
    for i, v := range a[1:] {
        if v - ls[i] < minD {
            minD = v - ls[i]
        }
        if v <= minD {
            ls = append(ls, v)
        } else {
            return ls
        }
    }
    return ls
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        sort.Ints(array)
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    var ls []int
    minD := 2000000011
    ls = append(ls, a[0])
    for i, v := range a[1:] {
        if v - ls[i] < minD {
            minD = v - ls[i]
        }
        if v <= minD {
            ls = append(ls, v)
        } else {
            return ls
        }
    }
    return ls
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        sort.Ints(array)
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    var ls []int
    minD := 2000000011
    prevV := a[0]
    ls = append(ls, a[0])
    for _, v := range a[1:] {
        if v - prevV < minD {
            minD = v - prevV
        }
        if v <= minD {
            ls = append(ls, v)
            prevV = v
        } else {
            return ls
        }
    }
    return ls
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        sort.Ints(array)
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    var ls []int
    minD := 2000000001
    prevV := a[0]
    for i, v := range a {
        if i == 0 {
            ls = append(ls, v)
            prevV = v
        } else {
            if v - prevV < minD {
                minD = v - prevV
            }
            if v <= minD {
                ls = append(ls, v)
                prevV = v
            }
        }
    }
    return ls
}

package main

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

/*
*/
func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    var number_test_case int
    fmt.Sscan(scanner.Text(), &number_test_case)
    for i:=0; i < number_test_case; i++ {
        var number_elements uint64
        scanner.Scan()
        fmt.Sscan(scanner.Text(), &number_elements)
        scanner.Scan()
        array := make([]int, number_elements)
        for i, v := range strings.Split(scanner.Text(), " ") {
            array[i], _ = strconv.Atoi(v)
        }
        sort.Ints(array)
        fmt.Println(len(longest_strange(array)))
    }
}

func longest_strange(a []int) []int {
    var ls []int
    minD := 1000000000
    prevV := a[0]
    for i, v := range a {
        if i == 0 {
            ls = append(ls, v)
            prevV = v
        } else {
            if v - prevV < minD {
                minD = v - prevV
            }
            if v <= minD {
                ls = append(ls, v)
                prevV = v
            }
        }
    }
    return ls
}

package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	pk, _ := reader.ReadString('\n')
	k, _ := strconv.Atoi(pk[:len(pk)-1])

	ml: for i := 0; i < k; i++{
		test,err := reader.ReadString('\n')
		test = test[:len(test)-1]
		if err != nil {
			return
		}
		ptemp, _ := reader.ReadString('\n')
		ptemp = ptemp[:len(ptemp)-1]
		temp := strings.Split(ptemp, " ")

		line := make([] int, len(temp))

		for j := 0; j < len(temp); j++ {
			x,_ :=  strconv.Atoi(temp[j])
			line[j] = x
		}
		sort.Ints(line)
		loc := len(line)-1
		for line[loc] >0 {
			loc--
			if loc<0{
				os.Stdout.WriteString("1\n")
				continue ml
			}
		}
		line = line[: int(math.Min(float64(loc+2), float64(len(line))))]

		for j:=1;j<len(line);j++ {
			if int(math.Abs(float64(line[j-1]-line[j]))) < line[len(line)-1]{

				os.Stdout.WriteString(strconv.Itoa(len(line)-1)+"\n")
				continue ml
			}

		}

		os.Stdout.WriteString(strconv.Itoa(len(line))+"\n")

	}

}

package main

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

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

	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())

	ml: for i := 0; i < k; i++{
		scanner.Scan()
		scanner.Scan()
		temp := strings.Split(scanner.Text(), " ")
		line := make([] int, len(temp))

		for j := 0; j < len(temp); j++ {
			x,_ :=  strconv.Atoi(temp[j])
			line[j] = x
		}
		sort.Ints(line)
		loc := len(line)-1
		for line[loc] >0 {
			loc--
			if loc<0{
				os.Stdout.WriteString("1\n")
				continue ml
			}
		}
		line = line[: int(math.Min(float64(loc+2), float64(len(line))))]

		for j:=1;j<len(line);j++ {
			if int(math.Abs(float64(line[j-1]-line[j]))) < line[len(line)-1]{
				os.Stdout.WriteString(strconv.Itoa(len(line)-1)+"\n")
				continue ml
			}

		}

		os.Stdout.WriteString(strconv.Itoa(len(line))+"\n")

	}

}

package main

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

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

	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())

	for i := 0; i < k; i++{
		scanner.Scan()
		scanner.Scan()
		temp := strings.Split(scanner.Text(), " ")
		line := make([] int, len(temp))
		d := make([] int, len(temp)-1)

		for j := 0; j < len(temp); j++ {
			x,_ :=  strconv.Atoi(temp[j])
			line[j] = x
		}
		sort.Ints(line)

		er: if len(line)==1 {
			os.Stdout.WriteString("1\n")
			continue
		}

		for j:=1; j < len(line); j++ {
			d[j-1] = int(math.Abs(float64(line[j]-line[j-1])))
		}
		sort.Ints(d)
		if d[0] < line[len(line)-1] {
			line = line[:len(line)-1]
			d = d[:len(d)-1]
			goto er
		}
		os.Stdout.WriteString(strconv.Itoa(len(line))+"\n")

	}

}

package main

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

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

	var tests int
	nums := [200000]int{}

	fmt.Fscan(in, &tests)

	ge := func(a, b int) int {
		if a >= b {
			return 1
		}
		return 0
	}

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

		ans := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
			ans += ge(0, nums[i])
		}

		sort.Ints(nums[:n])

		inf := 2_000_000_000
		min := inf

		for i := 0; i < n; i++ {
			if nums[i] > 0 && nums[i] < min {
				min = nums[i]
			}
		}

		flag := func() int {
			if min < inf {
				return 1
			}
			return 0
		}()

		for i := 2; i < n; i++ {
			if nums[i] <= 0 {
				flag &= ge(nums[i]-nums[i-1], min)
			}
		}
		fmt.Fprintln(out, ans+flag)

	}
}