New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $h$ hours and $m$ minutes, where $0 \le hh < 24$ and $0 \le mm < 60$. We use 24-hour time format!

Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $0$ hours and $0$ minutes.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 1439$) — the number of test cases.

The following $t$ lines describe test cases. The $i$-th line contains the time as two integers $h$ and $m$ ($0 \le h < 24$, $0 \le m < 60$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $h=0$ and $m=0$. It is guaranteed that both $h$ and $m$ are given without leading zeros.


-----Output-----

For each test case, print the answer on it — the number of minutes before the New Year.


-----Example-----
Input
5
23 55
23 0
0 1
4 20
23 59

Output
5
60
1439
1180
1

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
for _ in range(int(input())):
	(h, m) = tuple(map(int, input().split()))
	print(1440 - h * 60 - m)


(h1, m1) = (23, 60)
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print((h1 - h) * 60 + (m1 - m))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = (23 - a) * 60 + (60 - b)
	print(c)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print(24 * 60 - (h * 60 + m))


for i in range(int(input())):
	(h, m) = map(int, input().split(' '))
	print(60 - m + 60 * (24 - h - 1))


def solve():
	(h, m) = map(int, input().split())
	print(1440 - (h * 60 + m))
test = 1
test = int(input())
for i in range(test):
	solve()


for i in range(int(input())):
	(h, m) = [int(a) for a in input().split()]
	print(24 * 60 - h * 60 - m)


from math import gcd, ceil, log
from collections import Counter, deque
from heapq import heappush, heappop, heapify

def rl():
	return list(map(int, input().split()))

def arp(arr):
	return ''.join(arr)
for _ in range(int(input())):
	(h, m) = rl()
	tot = 1440
	print(1440 - (h * 60 + m))


for i in range(int(input())):
	(h, m) = [int(elem) for elem in input().split()]
	print((23 - h) * 60 + 60 - m)


import sys, math
MOD = 998244353
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	ans = 24 * 60 - h * 60 - m
	print(ans)


n = int(input())
c = []
for i in range(n):
	(a, b) = input().split()
	e = int(a)
	d = int(b)
	c.append([e, d])
for i in c:
	k = (23 - i[0]) * 60 + (60 - i[1])
	print(k)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print((23 - a) * 60 + 60 - b)


t = int(input())
a = [[0, 0]] * t
for i in range(t):
	(h, m) = map(int, input().split())
	a[i] = (23 - h) * 60 + (60 - m)
for i in range(t):
	print(a[i])


def sr(ch):
	ch1 = ch + ' '
	l = []
	p = ''
	for i in ch1:
		if i != ' ':
			p = p + i
		else:
			l.append(int(p))
			p = ''
	return l
n = int(input())
l = []
for i in range(n):
	ch = str(input())
	l.append(ch)
for ch in l:
	l1 = sr(ch)
	x = sr(ch)[0]
	y = sr(ch)[1]
	p = 24 - x - 1
	j = 60 - y
	print(j + p * 60)


T = int(input())
out = []
for i in range(0, T):
	(h, m) = map(int, input().split())
	output = 1440 - (60 * h + m)
	out.append(output)
for i in range(0, T):
	print(out[i])


def main():
	t = int(input())
	for _ in range(t):
		(h, m) = map(int, input().split())
		print((24 - h) * 60 - m)
main()


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	print(24 * 60 - n * 60 - s)


x = int(input())
while x > 0:
	time = input()
	(h, m) = time.split()
	h = int(h)
	m = int(m)
	print((23 - h) * 60 + (60 - m))
	x -= 1


for i in range(int(input())):
	(hrs, Min) = list(map(int, input().split()))
	print((23 - hrs) * 60 + (60 - Min))


(_, *s) = open(0)
for s in s:
	(a, b) = map(int, s.split())
	c = 0
	if b:
		c += 60 - b
		a += 1
	print((24 - a) * 60 + c)


t = int(input())
for idfvbgf in range(t):
	(a, b) = [int(i) for i in input().split(' ')]
	ans = (24 - a) * 60 - b
	print(ans)


t = int(input())
listah = []
listam = []
total = []
for i in range(t):
	(h, m) = [int(s) for s in input().split()]
	while h == 0 and m == 0 or ((h < 0 or h >= 24) or (m < 0 or m >= 60)):
		(h, m) = [int(s) for s in input().split()]
	listah.append(h)
	listam.append(m)
	t = listam[i] + listah[i] * 60
	resultado = 1440 - t
	total.append(resultado)
print(*total, sep='\n')


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
for i in range(ii()):
	(h, m) = mi()
	ans = 1440 - (h * 60 + m)
	print(ans)


import math
import os
import random
import re
import sys

def function(row):
	a = 60 - row[1]
	row[0] = row[0] + 1
	b = 24 - row[0]
	b = b * 60
	print(a + b)
m = int(input())
matrix = []
for _ in range(m):
	row = list(map(int, input().split()))
	function(row)


def solve(h, m):
	print((23 - h) * 60 + 60 - m)
n = int(input())
for i in range(n):
	(hh, mm) = map(int, input().split())
	solve(hh, mm)


n = input()
for _ in range(int(n)):
	(h, m) = input().split()
	print((23 - int(h)) * 60 + 60 - int(m))


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
for _ in range(II()):
	(h, m) = MI()
	print((24 - h) * 60 - m)


t = int(input())
while t != 0:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	print((24 - a) * 60 - b)
	t -= 1


num = int(input())
for k in range(0, num):
	n = list(map(int, input().split()))
	a = n[0]
	b = n[1]
	time = 60 * (24 - a) + 60 - b
	time = time - 60
	print(time)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	if m == 0:
		print((24 - h) * 60)
	else:
		min = 60 - m
		hrmin = (23 - h) * 60
		print(min + hrmin)


import sys

def main():
	(h, m) = [int(i) for i in sys.stdin.readline()[:-1].split()]
	answer = 1440 - h * 60 - m
	sys.stdout.write(f'{answer}\n')
T = int(sys.stdin.readline())
for t in range(T):
	main()


n = int(input())
h = list()
m = list()
for i in range(n):
	st = input()
	h.append(24 - int(st[:st.find(' ')]))
	m.append(60 - int(st[st.find(' '):]))
for i in range(n):
	if m[i] != 0:
		h[i] -= 1
	print(h[i] * 60 + m[i])


def timeToNewYr(h, m):
	s = (23 - h) * 60 + (60 - m)
	return s
n = int(input())
for i in range(n):
	(h, m) = [int(x) for x in input().split(' ')]
	print(timeToNewYr(h, m))


k = 1440
for i in range(int(input())):
	time = list(map(int, input().split()))
	print(k - (time[0] * 60 + time[1]))


for i in range(int(input())):
	(hour, min) = [int(_) for _ in input().split()]
	if min != 0:
		hour += 1
		time = 60 - min + (24 - hour) * 60
	else:
		time = (24 - hour) * 60
	print(time)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	k = h * 60 + m
	print(1440 - k)


n = int(input())
for i in range(n):
	(h, m) = (int(x) for x in input().split())
	min = 60 - m
	h += 1
	min += (24 - h) * 60
	print(min)


t = int(input())
for i in range(t):
	(h, m) = list(map(int, input().split()))
	print(1440 - (h * 60 + m))


from sys import stdin
r = stdin.readline

def main():
	cases = int(r())
	mins = 24 * 60
	for case in range(cases):
		(a, b) = map(int, r().strip().split())
		print(mins - (a * 60 + b))
main()


for _ in range(int(input())):
	(spent_hour, spent_minute) = map(int, input().split())
	hour_left = 24 - spent_hour
	hour_convert = hour_left * 60
	minute_left = hour_convert - spent_minute
	print(minute_left)


n = int(input())
a = list()
for i in range(n):
	s = input().split()
	(t, m) = (int(s[0]), int(s[1]))
	a.append(24 * 60 - (t * 60 + m))
for i in range(n):
	print(a[i])


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	l = (24 - (x + 1)) * 60
	r = 60 - y
	print(l + r)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	ss = 24 * 60
	mm = h * 60 + m
	print(ss - mm)


n = int(input())
for x in range(n):
	out = 0
	(h, m) = map(int, input().split())
	if h != 23:
		out += (23 - h) * 60
	out += 60 - m
	print(out)


def new_year(h, m):
	return (23 - h) * 60 + (60 - m)
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	print(new_year(h, m))


t = int(input())
for case in range(t):
	(h, m) = map(int, input().split())
	print(60 - m + 60 * (24 - h - 1))


from datetime import *
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	x = timedelta(hours=24) - timedelta(hours=h, minutes=m)
	print(int(x.seconds / 60))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	h = 24 - h
	print(h * 60 - m)


test = int(input())
for i in range(test):
	(h, m) = input().split()
	count = 24 * 60 - int(h) * 60 - int(m)
	print(count)


for case in ' ' * int(input()):
	(a, b) = map(int, input().split())
	print(1440 - a * 60 - b)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(h, m) = list(map(int, stdin.readline().split()))
	vis = h * 60 + m
	print(24 * 60 - vis)


q = int(input())
for i in range(q):
	(w, e) = map(int, input().split())
	if e != 0:
		print(60 - e + 60 * (24 - w - 1))
	else:
		print(60 * (24 - w))


import sys
input = sys.stdin.readline
tc = int(input())
for _ in range(tc):
	(h, m) = map(int, input().split())
	ans = 0
	ans = (24 - h) * 60 - m
	print(ans)


n = int(input())
for i in range(n):
	ln = list(map(int, input().split(' ')))
	m = ln[0]
	s = ln[1]
	print(24 * 60 - (m * 60 + s))


t = int(input())
for x in range(t):
	(hr, mins) = map(int, input().split())
	print(24 * 60 - (hr * 60 + mins))


n = int(input())
for i in range(n):
	t = input().split(' ')
	m = int(t[0]) * 60 + int(t[1])
	print(1440 - m)


test = int(input())
for j in range(test):
	(h, m) = list(map(int, input().split()))
	req = h * 60 + m
	ans = 1440 - req
	print(ans)


t = int(input())
l = []
for i in range(t):
	(h, m) = list(map(int, input().split()))
	a = 1440
	b = h * 60 + m
	c = a - b
	l.append(c)
for i in range(len(l)):
	print(l[i])


e = int(input())
p = []
for ee in range(e):
	(h, m) = map(int, input().split())
	m = m + h * 60
	p.append(1440 - m)
for i in range(len(p)):
	print(p[i])


numCases = int(input())
for i in range(numCases):
	(hours, minutes) = input().split(' ')
	minRemain = (24 - (int(hours) + 1)) * 60 + (60 - int(minutes))
	print(minRemain)


t = int(input())
while t > 0:
	(hh, mm) = map(int, input().split())
	ans = (23 - hh) * 60 + (60 - mm)
	print(ans)
	t -= 1


def solve():
	(h, m) = map(int, input().split())
	t = h * 60 + m
	x = 24 * 60 - t
	print(x)
for i in range(int(input())):
	solve()


from sys import stdin
loop = int(stdin.readline().strip())
while loop > 0:
	x = stdin.readline().strip().split()
	sum = (23 - int(x[0])) * 60 + (60 - int(x[1]))
	print(sum)
	loop -= 1


n = int(input())
hour = 23
minute = 60
for item in range(n):
	readline = input().split()
	h = int(readline[0])
	m = int(readline[1])
	print((hour - h) * 60 + (minute - m))


t = int(input())
for i in range(t):
	hh = 23
	mm = 60
	(h, m) = list(map(int, input().split()))
	print((hh - h) * 60 + mm - m)


tc = int(input())
for _ in range(tc):
	(m, s) = map(int, input().split())
	ans = 0
	if s != 0:
		ans += (24 - m) * 60
		ans -= s
	elif s == 0:
		ans = (24 - m) * 60
	print(ans)


t = int(input())
for i in range(t):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	result = (23 - h) * 60 + (60 - m)
	print(result)


def tilMidnight(hour, minute):
	return 24 * 60 - 60 * hour - minute
n = int(input())
for i in range(n):
	(hour, minute) = map(int, input().split())
	print(tilMidnight(hour, minute))


t = int(input())
for _ in range(t):
	s = input()
	(h, m) = map(int, s.split())
	print((23 - h) * 60 + (60 - m))


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	line = stdin.readline()
	line = line.split(' ')
	hours = 23 - int(line[0])
	minutes = 60 - int(line[1])
	retval = minutes + 60 * hours
	print(retval)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	ans = (24 - h - 1) * 60 + (60 - m)
	print(ans)


def solve():
	t = int(input())
	for _ in range(t):
		(h, m) = map(int, input().split())
		remain_h = 23 - h
		remain_m = 60 - m
		print(remain_h * 60 + remain_m)
solve()


def newYear(h, m):
	distinct_h = 23 - h
	distinct_m = 60 - m
	print(distinct_h * 60 + distinct_m)
t = int(input())
for j in range(t):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	newYear(h, m)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hours = 24 - h - 1
	minutes = 60 - m
	timerem = hours * 60 + minutes
	print(timerem)


def minuteBeforeNewYear(hh, mm):
	return (23 - hh) * 60 + (60 - mm)
t = int(input())
if 1 <= t <= 1439:
	for i in range(t):
		(x, y) = input().split()
		(hh, mm) = [int(i) for i in [x, y]]
		res = minuteBeforeNewYear(hh, mm)
		print(res)


n = int(input())
while n:
	arr = list(map(int, input().split()))
	h = arr[0]
	m = arr[1]
	print((24 - h) * 60 - m)
	n -= 1


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	p = 24 - h
	q = 0 - m
	tt = 60 * p + q
	print(tt)


t = int(input())
for i in range(0, t):
	(hr, mins) = map(int, input().split())
	hr_in_min = hr * 60
	min_left = 1440 - (hr_in_min + mins)
	print(min_left)


n = int(input())
for i in range(n):
	(h, m) = list(map(int, input().split()))
	res = 0
	if m == 0:
		res = (24 - h) * 60
	else:
		res = (23 - h) * 60 + (60 - m)
	print(res)


HOURS_IN_A_DAY = 24
MINUTES_IN_A_DAY = 24 * 60
for i in range(int(input())):
	(hours, minutes) = [int(i) for i in input().split()]
	total_minutes = minutes + hours * 60
	print(MINUTES_IN_A_DAY - total_minutes)


n = int(input())
for i in range(0, n):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	m = 60 - m
	h = 24 - h
	h = h - 1
	print(h * 60 + m)


n = int(input())
while n > 0:
	(h, m) = map(int, input().split())
	k = (23 - h) * 60 + (60 - m)
	print(k)
	n = n - 1


n = int(input())
const = 24 * 60
for i in range(n):
	source = input().split(' ')
	a = int(source[0])
	b = int(source[1])
	sum1 = a * 60 + b
	print(const - sum1)


result = []
a = int(input())
for m in range(a):
	(c, b) = map(int, input().split())
	result.append((23 - c) * 60 + (60 - b))
for a in result:
	print(a)


t = int(input())
while t:
	t = t - 1
	(h, m) = list(map(int, input().split(' ')))
	m1 = 24 * 60
	m2 = h * 60 + m
	print(m1 - m2)


N = int(input())
q = []
for i in range(N):
	(a, b) = map(int, input().split())
	q.append((a, b))
for i in range(N):
	(a, b) = q[i]
	ans = 0
	if b > 0:
		ans = (23 - a) * 60 + (60 - b)
		print(ans)
	else:
		ans = (24 - a) * 60
		print(ans)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	ans = (23 - h) * 60
	ans += 60 - m
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	t = 1440
	print(t - a * 60 - b)


n = int(input())
mass = []
for i in range(n):
	st = input()
	(h, m) = [int(i) for i in st.split(' ')]
	ans = 60 * 24
	mass.append(ans - (h * 60 + m))
for i in range(n):
	print(mass[i])


for nt in range(int(input())):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + (60 - m))


import sys
t = int(sys.stdin.readline())
for line in sys.stdin:
	(h, m) = map(int, line.split())
	print(str((24 - h) * 60 - m))


import sys

def main():
	n = int(input())
	ans = [0]
	for i in range(0, n):
		x = list(map(int, input().split()))
		hour = 23 - x[0]
		minu = 60 - x[1]
		time = minu + hour * 60
		ans.insert(i, time)
	ans.pop()
	for i in ans:
		print(i)
main()


t = int(input())
for i in range(t):
	time = [int(x) for x in input().split()]
	newyear = 24 * 60
	print(newyear - (time[0] * 60 + time[1]))


quantity = input()
quantity = int(quantity)
time_list = list()
answer = list()
for _ in range(quantity):
	time_list.append(input())
for i in range(quantity):
	word_from_list = time_list[i]
	j = 0
	for word in word_from_list.split():
		j += 1
		word_int = int(word)
		if j % 2 != 0:
			word_int *= 60
			answer.append(word_int)
		else:
			answer[i] = answer[i] + word_int
for k in range(len(answer)):
	print(1440 - answer[k])


t = int(input())
for test in range(0, t):
	(h, m) = map(int, input().split())
	ans = (23 - h) * 60 + 60 - m
	print(str(ans))


from sys import stdin
input = stdin.readline
tc = int(input())
for i in range(tc):
	(h, m) = map(int, input().split())
	minutes = h * 60 + m
	print(1440 - minutes)


t = int(input())
out = []
for i in range(t):
	(h, m) = map(int, input().split())
	out.append(1440 - h * 60 - m)
for i in out:
	print(i)


from sys import stdin, stdout
x = []
for line in stdin:
	x.append(line.rstrip())
del x[0]
for i in x:
	k = i.split(' ')
	print((23 - int(k[0])) * 60 + (60 - int(k[1])))


n = int(input())
for a in range(n):
	dt = input()
	h = dt.split()[0]
	m = dt.split()[1]
	print((23 - int(h)) * 60 + (60 - int(m)))


n = int(input())
c = []
for i in range(n):
	l = list(map(int, input().split()))
	c.append((24 - l[0]) * 60 - l[1])
for k in c:
	print(k)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	print(1440 - 60 * a - b)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	e = (23 - n) * 60 + (60 - m)
	print(e)


x = int(input())
while x:
	y = [int(i) for i in input().split()]
	z = 23 - y[0]
	n = 60 - y[1]
	print(z * 60 + n)
	x -= 1


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		(h, m) = map(int, input().split())
		print((23 - h) * 60 + (60 - m))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	l = list(map(int, input().split(' ')))
	s = l[0] * 60 + l[1]
	print(1440 - s)


time_all = 24 * 60
for __ in range(int(input())):
	(h, m) = map(int, input().split())
	t = h * 60 + m
	print(time_all - t)


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(h, m) = map(int, I().split())
	ans += '{}\n'.format(1440 - (h * 60 + m))
print(ans)


tc = int(input())
for t in range(tc):
	(h, m) = map(int, input().split(' '))
	print(24 * 60 - (h * 60 + m))


t = int(input())
for i in range(t):
	(hour, minute) = map(int, input().split())
	hour_do = 24 - hour
	new_minute = hour_do * 60 - minute
	print(new_minute)


n = int(input())
k = 0
a = []
for i in range(n):
	(a1, a2) = map(int, input().split())
	a.append((24 - a1 - 1) * 60 + (60 - a2))
for i in range(n):
	print(a[i])


T = int(input())
for i in range(T):
	(h, m) = map(int, input().split())
	deltaH = 23 - h
	deltaM = 60 - m
	totalMinsLeft = deltaH * 60 + deltaM
	print(totalMinsLeft)


h = int(input())
for i in range(0, h):
	time_list = input().split(' ')
	hours = int(time_list[0])
	mintues = int(time_list[1])
	result = 1440 - hours * 60 - mintues
	print(result)


t = int(input())
for o in range(t):
	(h, m) = map(int, input().strip().split())
	print((24 - (h + 1)) * 60 + 60 - m)


i = lambda : map(int, input().split())
for _ in [0] * [*i()][0]:
	(a, b) = i()
	print(60 * (24 - a) - b)


q = int(input())
for _ in range(q):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + 60 - m)


def program():
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	time_left = (23 - h) * 60 + (60 - m)
	print(time_left)
t = int(input())
for i in range(t):
	program()


t = int(input())
for i in range(t):
	(h, m) = [int(i) for i in input().split()]
	(k, m) = (60 - m, 0)
	(k, h) = ((24 - (h + 1)) * 60 + k, 0)
	print(k)


import datetime
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	a = datetime.datetime.strptime(f'28 12 2019 {h} {m}', '%d %m %Y %H %M')
	b = datetime.datetime(2020, 1, 1, 0, 0)
	c = b - a
	print(int(c.seconds / 60))


def minBeforeNY(h, m):
	return (23 - h) * 60 + 60 - m
tc = int(input())
for i in range(tc):
	inp = list(map(int, input().split()))
	print(minBeforeNY(inp[0], inp[1]))


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	ans = 0
	if m != 0:
		h += 1
		ans += 60 - m
	if h != 24:
		ans += 60 * (24 - h)
	print(ans)


t = int(input())
for i in range(0, t):
	time = input()
	h = int(time[0:time.find(' ')])
	m = int(time[time.find(' ') + 1:])
	r = 0
	while h < 24:
		while m < 60:
			m = m + 1
			r = r + 1
		h = h + 1
		m = 0
	print(r)


def TimeTillMidnight(h, m):
	print(1440 - (h * 60 + m))
q = int(input())
for i in range(q):
	inp = input().split()
	(h, m) = (int(inp[0]), int(inp[1]))
	TimeTillMidnight(h, m)


n = int(input())
for i in range(n):
	(h, m) = list(map(int, input().split()))
	print(24 * 60 - (h * 60 + m))


n = int(input())
for i in range(0, n):
	(h, m) = map(int, input().split())
	h = int(h)
	m = int(m)
	t = h * 60 + m
	dan = 24 * 60
	preostanek = dan - t
	print(preostanek)


import json
x = 60 * 24
t = int(input())
for i in range(t):
	lst = input().split()
	lst = list(map(lambda x: int(x) if x.isdigit() else 0, lst))
	a = lst[0]
	b = lst[1]
	a = 60 * a + b
	print(x - a)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	time = h * 60 + m
	difftime = 1440 - time
	print(difftime)


t = int(input())
for i in range(t):
	(a, b) = [int(e) for e in input().split()]
	d = 60 - b
	if a >= 23:
		a = 0
		f = a + d
		print(f)
	elif a < 23:
		c = (23 - a) * 60
		a = c
		f = a + d
		print(f)


t = int(input())
x = 0
while x < t:
	x += 1
	(h, m) = [int(x) for x in input().split()]
	print(1440 - (h * 60 + m))


T = int(input())
for _ in range(T):
	(h, m) = map(int, input().split())
	r = (23 - h) * 60 + (60 - m)
	print(r)


a = int(input())
d = list()
r = 0
while r < a:
	b = [int(b) for b in input().split()]
	c = 1440 - (b[0] * 60 + b[1])
	d.append(c)
	r = r + 1
r = 0
while r < a:
	print(d[r])
	r = r + 1


for i in [0] * int(input()):
	(s, d) = map(int, input().split())
	print((23 - s) * 60 + (60 - d))


tests = int(input())
for x in range(tests):
	array = input().split(' ')
	array = int(array[0]) * 60 + int(array[1])
	print(1440 - array)


t = int(input())
for x in range(t):
	I = input()
	a = I.split(' ')
	print((23 - int(a[0])) * 60 + 60 - int(a[1]))


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	next = h + 1
	next_m = 60 - m
	diff = (24 - next) * 60
	print(diff + next_m)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	a = h * 60 + m
	print(1440 - a)


for _ in range(int(input())):
	(h, m) = [int(i) for i in input().split()]
	res = (23 - h) * 60 + 60 - m
	print(res)


def solve(h, m):
	mintues = 0
	if h == 23:
		if m == 0:
			return 60
		else:
			mintues += 60 - m
	elif m == 0:
		mintues += (24 - h) * 60
		return mintues
	else:
		mintues += (23 - h) * 60
		mintues += 60 - m
	return mintues
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print(solve(h, m))


t = int(input())
out = []
for i in range(t):
	a = [int(c) for c in input().split()]
	out.append((23 - a[0]) * 60 + (60 - a[1]))
for i in range(t):
	print(out[i])


def solve():
	t = int(input())
	ny = 1440
	for i in range(t):
		(h, m) = [int(s) for s in input().split()]
		m = h * 60 + m
		print(ny - m)
solve()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print((23 - x) * 60 + 60 - y)


q = int(input())
for i in range(q):
	(h, m) = map(int, input().split())
	time = h * 60 + m
	timeleft = 1440 - time
	print(timeleft)


for _ in range(int(input())):
	(h, s) = map(int, input().split())
	a = (24 - h - 1) * 60 + (60 - s)
	print(a)


x = int(input())
for i in range(x):
	(a, b) = map(int, input().split())
	c = (24 - a) * 60
	print(c - b)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	if m == 0:
		print((24 - h) * 60)
	else:
		mm = (23 - h) * 60 + (60 - m)
		print(mm)


n = int(input())
for _ in range(n):
	(h, m) = map(int, input().split())
	t = 1440
	ans = h * 60 + m
	print(t - ans)


from math import *
t = int(input())
for _ in range(t):
	arr = list(map(int, input().split(' ')))
	res = (24 - arr[0]) * 60 - arr[1]
	print(res)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	r = (24 - h) * 60 - m
	print(r)


t = int(input())
while t:
	(h, m) = map(int, input().split())
	mins = 1440 - (h * 60 + m)
	print(mins)
	t -= 1


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	a = 23
	b = 60
	aa = a - h
	bb = b - m
	print(aa * 60 + bb)


t = int(input())
for i in range(t):
	(hrs, mins) = map(int, input().split())
	hrs = hrs * 60
	totMinLeft = 1440 - (hrs + mins)
	print(totMinLeft)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	s1 = s2 = 0
	if m > 0:
		s1 = 60 - m
		temp = 24 - h - 1
		s2 = temp * 60
		print(s1 + s2)
	else:
		temp = 24 - h
		s1 = temp * 60
		print(s1)


t = int(input())
for i in range(t):
	h_m = list(map(int, input().split(' ')))
	(h, m) = h_m
	ans = 0
	if m != 0:
		h += 1
		ans += (24 - h) * 60
		ans += 60 - m
	elif h == 0:
		ans = 0
	else:
		ans += (24 - h) * 60
	print(ans)


import sys
t = 1
t = int(input())
for i in range(t):
	(n, m) = list(map(int, sys.stdin.readline().strip().split()))
	print((24 - n - 1) * 60 + 60 - m)


def solution(t):
	h = 23
	m = 60
	out = []
	for i in range(t):
		(a, b) = map(int, input().split())
		hours = h - a
		minutes = m - b
		out.append(hours * 60 + minutes)
	print('\n'.join(map(str, out)))

def main():
	t = int(input())
	solution(t)
main()


def func(n):
	for i in range(n):
		l = list(map(int, input().split()))
		counter = 0
		while l[0] != 23:
			l[0] += 1
			counter += 60
		while l[1] != 60:
			l[1] += 1
			counter += 1
		print(counter)
n = int(input())
func(n)


t = int(input())
for T in range(t):
	(h, m) = [int(x) for x in input().split()]
	ans = 60 - m
	ans += (24 - h) * 60
	print(ans - 60)


t = int(input())
for i in range(t):
	(h, m) = list(map(int, input().split()))
	total = 24 * 60
	val = h * 60 + m
	print(total - val)


for _ in range(int(input())):
	cnt = 0
	q = []
	(h, m) = map(int, input().split())
	te = 1440 - h * 60 - m
	print(te)


a = int(input())
t = 24 * 60
for i in range(a):
	(x, y) = map(int, input().split())
	print(t - x * 60 - y)


t = int(input())
time = []
for i in range(t):
	data = [int(x) for x in input().split()]
	time.append(data)
for (h, m) in time:
	if h == 23:
		print(60 - m)
	else:
		wait = 23 * 60 - h * 60 + (60 - m)
		print(wait)


def fon(liste):
	c = (23 - liste[0]) * 60
	d = 60 - liste[1]
	return c + d
n = int(input())
for i in range(n):
	s = [int(i) for i in input().split()]
	print(fon(s))


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	left = 1440
	s = h * 60 + m
	print(abs(left - s))


t = int(input())
for i in range(t):
	(h, m) = [int(j) for j in input().split()]
	p = 1440
	s = h * 60 + m
	q = p - s
	print(q)


for _ in range(int(input())):
	s = input().split()
	(h, m) = (int(s[0]), int(s[1]))
	cnt = 60 - m
	if m > 0:
		h += 1
	else:
		cnt = 0
	cnt += (24 - h) * 60
	print(cnt)


for _ in range(int(input())):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	a = a * 60
	b = a + b
	print(24 * 60 - b)


t = int(input())
TOTAL = 24 * 60
for i in range(t):
	(x, y) = input().split()
	CUR = int(y) + int(x) * 60
	print(TOTAL - CUR)


def main(hr, min):
	total_min = 24 * 60
	curr_time = hr * 60 + min
	return total_min - curr_time
n = int(input())
for i in range(n):
	values = input().split()
	(curr_hour, curr_min) = (int(values[0]), int(values[1]))
	print(main(curr_hour, curr_min))


n = int(input())
mas = [0] * n
h = 24
t = 60
t2 = 0
for i in range(n):
	k = [int(g) for g in input().split()]
	mas[i] = k
for i in mas:
	while True:
		t2 += 1
		i[1] += 1
		if i[1] == 60:
			i[1] = 0
			i[0] += 1
		if i[0] == 24 and i[1] == 0:
			break
	print(t2)
	t2 = 0


t = int(input())
for q in range(0, t):
	(n, m) = map(int, input().split())
	p = (24 - n - 1) * 60
	p += 60 - m
	print(p)


case = int(input())
for caseNum in range(0, case):
	(a, b) = [int(x) for x in input().split()]
	targetHour = 60 * (24 - a - 1)
	targetMin = 60 - b
	answer = targetMin + targetHour
	print(answer)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	t = 24 * 60 - (abs(a) * 60 + abs(b))
	print(t)


T = int(input())
for i in range(T):
	(H, M) = map(int, input().split(' '))
	print((23 - H) * 60 + 60 - M)


t = int(input())
while t:
	t = t - 1
	(h, m) = map(int, input().split())
	h = 23 - h
	m = 60 - m
	print(h * 60 + m)


import sys, math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	(h, m) = invr()
	print((24 - h - 1) * 60 + (60 - m))


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	time = a * 60 + b
	print(1440 - time)


p = int(input())
plusiki = 0
while plusiki < p:
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	h = 23 - h
	m = 60 - m
	print(h * 60 + m)
	plusiki = plusiki + 1


testcases = int(input())
vals = []
for i in range(testcases):
	inputtedtime = input()
	hm = inputtedtime.split(' ')
	hours = int(hm[0])
	minute = int(hm[1])
	remaining_time = 1440 - 60 * hours - minute
	print(remaining_time)


n = int(input())
ans = 0
for i in range(n):
	(p, q) = map(int, input().split())
	ans = (24 - p) * 60 + -q
	print(ans)


q = int(input())
for z in range(q):
	(a, b) = map(int, input().split())
	s = (23 - a) * 60 + (60 - b)
	print(s)


x = int(input())
for i in range(x):
	(a, b) = map(int, input().split())
	print((23 - a) * 60 + (60 - b))


q = int(input())
for qq in range(q):
	[h, m] = list(map(int, input().split()))
	print(60 * (23 - h) + 60 - m)


from datetime import datetime, timedelta
for _ in [0] * int(input()):
	(hr, mi) = map(int, input().split())
	print((datetime(2020, 3, 15, 0, 0, 0) - datetime(2020, 3, 14, hr, mi, 0)).seconds // 60)


n = int(input())
m = list()
h = list()
for i in range(n):
	(h1, m1) = map(int, input().split())
	m.append(m1)
	h.append(h1)
for (i, j) in zip(h, m):
	m2 = 60 - j
	if i != 23:
		h2 = 24 - i - 1
		h2 *= 60
		m2 += h2
	print(m2)
	h2 = m2 = 0


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	if m == 0:
		print((24 - h) * 60)
	else:
		print((24 - h - 1) * 60 + (60 - m))


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	if h == 0 and m == 0:
		print(0)
	else:
		print((23 - h) * 60 + (60 - m))


try:
	while True:
		t = int(input())
		for i in range(t):
			(h, m) = map(int, input().split())
			ans = 60 - m
			ans += (23 - h) * 60
			print(ans)
except EOFError:
	pass


size = int(input())
st = 1440
for i in range(size):
	(hr, mint) = input().split(' ')
	hr = int(hr)
	mint = int(mint)
	tot = hr * 60 + mint
	print(st - tot)


def q():
	a = input().split(' ')
	if len(a) > 1:
		s = 60 * int(a[0]) + int(a[1])
		print(1440 - s)
	else:
		print(1440 - int(a[0]))
t = int(input())
for i in range(t):
	q()


n = int(input())
qlst = [list(map(int, input().split())) for i in range(n)]
for i in qlst:
	res = 1440 - (60 * i[0] + i[1])
	print(res)


line = int(input())
data = []
for i in range(0, line):
	user = input()
	user = user.split(' ')
	data.append(user)
midNightMin = 1440
for i in range(0, len(data)):
	print(midNightMin - (int(data[i][0]) * 60 + int(data[i][1])))


t = int(input())
ans = []
for i in range(t):
	(h, m) = input().split()
	tot_min = int(h) * 60 + int(m)
	ans.append(1440 - tot_min)
for j in range(len(ans)):
	print(ans[j])


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	h_ = (24 - h - 1) * 60
	m_ = 60 - m
	print(h_ + m_)


t = int(input())
if 1 <= t <= 1439:
	for i in range(t):
		(h, m) = input().split()
		h = int(h)
		m = int(m)
		if 0 <= h < 24 and 0 <= m < 60:
			z = 1440 - h * 60 - m
			print(z)


bruh = int(input())
lit = []
for i in range(bruh):
	(o, t) = input().split()
	lit.append([int(o), int(t)])
for i in range(bruh):
	print((23 - lit[i][0]) * 60 + (60 - lit[i][1]))


def call():
	(h, m) = map(int, input().split())
	coN = 0
	coN += h * 60
	coN += m
	print(1440 - coN)
for i in range(int(input())):
	call()


def solve(hrs, mins):
	total_mins = 0
	if mins == 0:
		total_mins += 60
	else:
		total_mins += abs(60 - mins)
	return abs(hrs - 23) * 60 + total_mins
T = int(input().strip())
res = []
for _ in range(T):
	(hrs, mins) = map(int, input().strip().split(' '))
	res.append(solve(hrs, mins))
for r in res:
	print(r)


t = int(input())
while t > 0:
	t = t - 1
	(h, m) = map(int, input().split())
	a = (24 - h) * 60 - m
	print(a)


import sys
n = int(input())
ans = []
for _ in range(n):
	x = sys.stdin.readline()
	y = list(map(int, x.split()))
	ans.append((23 - y[0]) * 60 + (60 - y[1]))
for i in ans:
	print(i)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	(v, d, u) = (0, 0, 0)
	if h > 0 or m > 0:
		v = abs(h - 23)
		d = abs(m - 60)
		u = v * 60 + d
		print(u)
	else:
		print(24 * 60)


t = int(input())
while t > 0:
	(h, m) = map(int, input().split())
	if h == 0 and m == 0:
		print('0')
	else:
		mini = (24 - h) * 60 - m
	print(mini)
	t -= 1


t = int(input())
for i in range(t):
	(hour, minute) = map(int, input().split())
	total_minutes = hour * 60 + minute
	print(1440 - total_minutes)


t = int(input())
for _ in range(t):
	c = 0
	(a, b) = map(int, input().split())
	d = 23 - a
	e = 60 - b
	f = d * 60
	print(e + f)


tests = int(input())
while tests > 0:
	(h, m) = [int(i) for i in input().split(' ')]
	print(1440 - h * 60 - m)
	tests = tests - 1


t = int(input())

def solve():
	n = list(map(int, input().split()))
	p = (23 - n[0]) * 60 + (60 - n[1])
	print(p)
for x in range(t):
	solve()


import sys
f = sys.stdin.read().strip().split('\n')
n = int(f[0])
del f[0]
f_int = []
for i in f:
	f_int.append(list(map(int, i.split(' '))))
for (h, m) in f_int:
	answer = (24 - h - 1) * 60 + (60 - m)
	print(answer)


T = int(input())
for _ in range(T):
	(h, m) = list(map(int, input().split()))
	left = 0
	if h == 23:
		left = 60 - m
	else:
		left = (24 - h) * 60 - m
	print(left)


def main():
	(h, m) = map(int, input().split())
	ans = (24 - (h + 1)) * 60 + 60 - m
	print(ans)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


n = input()
for i in range(int(n)):
	x = input().split()
	print(str(1440 - (int(x[0]) * 60 + int(x[1]))) + '\n')


import math
import os
import random
import re
import sys

def minutes_to_midnight(h, m):
	minutes_in_day = 1440
	h_to_minutes = h * 60
	minutes = minutes_in_day - h_to_minutes - m
	return minutes

def solve():
	t = int(input())
	for _ in range(t):
		(h, m) = list(map(int, input().split()))
		minutes = minutes_to_midnight(h, m)
		print(minutes)
result = solve()


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	print(1440 - (m * 60 + n))


t = int(input())
for i in range(t):
	data = list(map(int, input().split()))
	print((23 - data[0]) * 60 + (60 - data[1]))


N = int(input())
for i in range(N):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + (60 - m))


for _ in range(int(input())):
	(hours, mins) = map(int, input().split(' '))
	if hours == 0 and mins == 0:
		print(0)
	else:
		print(60 * (24 - hours) - mins)


t = int(input())
while t > 0:
	t -= 1
	(h, m) = tuple(map(int, input().strip().split(' ')))
	print((23 - h) * 60 + (60 - m))


for _ in range(int(input())):
	(H, M) = list(map(int, input().split()))
	print(abs(1440 - 60 * H - M))


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	x = 24 - h
	y = 60 - m
	if x == 1:
		print(y)
	else:
		x = x - 1
		x = x * 60
		print(x + y)


test = int(input())
clock = []
for x in range(test):
	time = input()
	clock = time.split(' ')
	hour = int(clock[0])
	minute = int(clock[1])
	minrem = 60 - minute
	hrrem = 23 - hour
	rem = minrem + 60 * hrrem
	print(rem)


t = int(input())
while t:
	inp = list(map(lambda x: int(x), input().split()))
	h = inp[0]
	min = inp[1]
	ans = 1440 - (h * 60 + min)
	print(ans)
	t -= 1


t = int(input())
while t:
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	t -= 1
	print((24 - h) * 60 - m)


import math
nb_cases = int(input())
for c in range(nb_cases):
	(h, m) = [int(x) for x in input().split()]
	print((23 - h) * 60 + (60 - m))


t = int(input())

def solve(x, y):
	if x == 23:
		cnt = 60 - y
		return cnt
	else:
		cnt = 0
		cnt += (23 - x) * 60
		cnt += 60 - y
		return cnt
for i in range(t):
	(h, m) = map(int, input().split())
	print(solve(h, m))


t = int(input())
for g in range(0, t):
	hm = list(map(int, input().split()))
	h = hm[0]
	m = hm[1]
	x = 23 - h
	y = 60 - m
	print(60 * x + y)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	minToZero = 0
	if m:
		minToZero = 60 - m
	if minToZero:
		h += 1
	hrToZero = 24 - h
	print(hrToZero * 60 + minToZero)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hours = 0
	minutes = 0
	if m > 0:
		hours = 24 - h - 1
		minutes = 60 - m
	else:
		hours = 24 - h
		minutes = 0
	print(hours * 60 + minutes)


for x in range(int(input())):
	(h, m) = map(int, input().split())
	i = 1
	while h < 24:
		if i == 1:
			min = 60 - m
		else:
			min = min + 60
		h = h + 1
		i += 1
	print(min)


testCase = int(input())
Output = 0
while testCase != 0:
	(H, Min) = map(int, input().split())
	if 0 <= H < 24 and 0 <= Min < 60:
		Output = (23 - H) * 60 + (60 - Min)
		print(Output)
	testCase = testCase - 1


t = int(input())
for _ in range(t):
	(hh, mm) = map(int, input().split())
	print((23 - hh) * 60 + (60 - mm))


t = int(input())
answer = []
for a in range(t):
	line = input().split()
	h = int(line[0])
	m = int(line[1])
	ans = (24 - h - 1) * 60 + 60 - m
	answer.append(ans)
for b in answer:
	print(str(b))


cases = int(input())
times = []
for i in range(cases):
	inp = input()
	time = inp.split()
	time[0] = 23 - int(time[0])
	time[1] = 60 - int(time[1])
	times.append(time)
for t in times:
	print(t[0] * 60 + t[1])


n = int(input())
while n:
	k = input()
	k = k.split(' ')
	h = int(k[0])
	m = int(k[1])
	ans = 24 * 60 - (h * 60 + m)
	print(ans)
	n -= 1


n = int(input())
x = []
for i in range(n):
	a = list(map(int, input().split()))
	x.append(a)
for i in range(n):
	h = m = sumw = 0
	if x[i][1] != 0:
		m = 60 - x[i][1]
		if x[i][0] != 23:
			h = 23 - x[i][0]
	elif x[i][0] != 24:
		h = 24 - x[i][0]
	sumw = h * 60 + m
	print(sumw)


import sys
import math

def main():
	T = int(sys.stdin.readline())
	for _ in range(T):
		(H, M) = (int(x) for x in sys.stdin.readline().split())
		result = (23 - H) * 60 + (60 - M)
		sys.stdout.write(f'{result}\n')
main()


T = int(input())
for t in range(T):
	(h, m) = list(map(int, input().split()))
	mid = 24 * 60
	now = h * 60 + m
	print(mid - now)


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	q = h * 60 + m
	print(1440 - q)


n = int(input())
c = 0
fin = []
while c < n:
	c += 1
	(a, b) = input().split()
	h = int(a)
	m = int(b)
	totalmin = h * 60 + m
	fin.append(24 * 60 - totalmin)
for i in fin:
	print(i)


for u in range(int(input())):
	(y, m) = map(int, input().split())
	s = 24 * 60
	x = y * 60 + m
	print(s - x)


n = int(input())
for i in range(n):
	(hh, mm) = [int(n) for n in input().split()]
	print(1440 - (hh * 60 + mm))


tests = int(input())
while tests:
	tests -= 1
	(h, m) = map(int, input().split())
	m += 60 * h
	total = 60 * 24
	ans = total - m
	print(ans)


from sys import stdin
inp = iter([int(x) for x in stdin.read().split()])
T = next(inp)
for i in range(T):
	h = next(inp)
	m = next(inp)
	print(24 * 60 - (h * 60 + m))


t = int(input())
for i in range(t):
	dados = input().split()
	hora = int(dados[0]) * 60
	minutos = int(dados[1])
	dia = 24 * 60
	print((hora + minutos - dia) * -1)


n = int(input())
for _ in range(n):
	a = [int(i) for i in input().split()]
	print(60 * (24 - a[0]) - a[1])


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	hrs = x * 60
	total = hrs + y
	print(1440 - total)


for t in range(int(input())):
	(h, m) = map(int, input().split(' '))
	if m == 0:
		h1 = 24 - h
		m1 = 0
	else:
		h1 = 23 - h
		m1 = 60 - m
	res = h1 * 60 + m1
	print(res)


t = int(input())
for z in range(t):
	line = input()
	(h, m) = (int(s) for s in line.split())
	time = (23 - h) * 60 + 60 - m
	print(time)


t = int(input())
while t > 0:
	h = 0
	(a, b) = map(int, input().split())
	h = a * 60 + b
	print(abs(h - 1440))
	t -= 1


N = int(input())
for _ in range(N):
	(hh, mm) = map(int, input().split())
	print(24 * 60 - (hh * 60 + mm))


t = int(input())
x = []
for i in range(t):
	(h, m) = map(int, input().split())
	j = [h, m]
	x.append(j)
for c in x:
	i = 24
	j = 0
	if c[0] == 0 and c[1] == 0:
		print(0)
	if j < c[1]:
		i = i - 1
		j += 60
	print((i - c[0]) * 60 + (j - c[1]))


import sys
first = 0
for line in sys.stdin:
	if first == 0:
		first = line
	else:
		(h, m) = line.split()
		h = int(h)
		m = int(m)
		hours_left = 24 - h - 1
		minutes_left = 60 - m
		if minutes_left == 0:
			hours_left += 1
		print(hours_left * 60 + minutes_left)


n = int(input())
for i in range(n):
	d = 0
	e = 0
	f = 0
	g = 1440
	(h, m) = map(int, input().split())
	d = h * 60
	e = d + m
	print(g - e)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	ans = (23 - a) * 60 + (60 - b)
	print(ans)


t = int(input())

def hour(h, k):
	count = (24 - h) * 60 - k
	return count
for i in range(t):
	(h, k) = map(int, input().split())
	print(hour(h, k))


def m(a):
	for i in a:
		total = 0
		minutes = 60 - i[1]
		total += minutes
		i[0] += 1
		hours = 24 - i[0]
		total += hours * 60
		print(total)
count = int(input())
ar = []
for _ in range(count):
	ar.append(list(map(int, input().split())))
m(ar)


import sys
t = int(input())
for i in range(t):
	(hh, mm) = tuple(map(int, input().split(' ', 2)))
	print(24 * 60 - (hh * 60 + mm))


import sys
a = input()
a = int(a)
r = 0
d = 0
i = 0
while i < a:
	riga = list(map(int, input().strip().split()))
	h = riga[0]
	m = riga[1]
	d = m + h * 60
	r = 1440 - d
	print(r)
	i = i + 1


n = int(input())
for y in range(n):
	sc = list(map(int, input().split()))
	print(1440 - (sc[0] * 60 + sc[1]))


queryes = int(input())
for q in range(queryes):
	(h, m) = map(int, input().split())
	if h == 0 and m == 0:
		print(0)
		continue
	print(60 - m + (23 - h) * 60)


try:
	n = int(input())
	for i in range(0, n):
		(m, n) = map(int, input().split())
		k = m * 60 * 60 + n * 60
		c = 86400 - k
		s = c // 60
		print(s)
except:
	pass


cnt = int(input())
for _ in range(cnt):
	(hr, mn) = tuple(map(int, input().split()))
	print((23 - hr) * 60 + 60 - mn)


q = int(input())
for i in range(q):
	a = input().split()
	h = int(a[0])
	m = int(a[1])
	print((23 - h) * 60 + 60 - m)


n = int(input())
while n > 0:
	(p, q) = map(int, input().split())
	r = p * 60 + q
	print(1440 - r)
	n = n - 1


lines = int(input())
for a in range(lines):
	(H, M) = map(int, input().split(' '))
	print(24 * 60 - 60 * H - M)


n = int(input())
res = []
for i in range(n):
	count = 0
	(h, m) = map(int, input().split())
	hour = (23 - h) * 60
	minu = 60 - m
	total = hour + minu
	res.append(total)
for i in res:
	print(i)


t = int(input())
for q in range(t):
	(h, m) = [int(i) for i in input().split()]
	lol = 60 - m
	if h == 23:
		print(lol)
		continue
	else:
		h += 1
		lol += (24 - h) * 60
		print(lol)


import sys
t = input()
t = int(t)
i = 0
g = 24 * 60
while i < t:
	riga = list(map(int, input().strip().split()))
	h = riga[0]
	m = riga[1]
	mm = h * 60 + m
	output = g - mm
	i = i + 1
	print(output)


totalCase = input()
for case in range(int(totalCase)):
	inputNumber = input()
	newNumber = inputNumber.split()
	hour = 24 - int(newNumber[0])
	minute = 60 - int(newNumber[1])
	totalMinute = minute
	if hour > 1:
		totalMinute = totalMinute + (hour - 1) * 60
	print(totalMinute)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split(' '))
	tot = h * 60
	tot += m
	print(1440 - tot)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	if h >= 23:
		print(60 - m)
	else:
		p = (24 - h - 1) * 60 + (60 - m)
		print(p)


tests = int(input())
for te in range(tests):
	(h, m) = list(map(int, input().split()))
	ans = (23 - h) * 60 + (59 - m) + 1
	print(ans)


queries = int(input())
for i in range(queries):
	(hours, minutes) = map(int, input().split())
	h_m = (23 - hours) * 60
	m_m = 60 - minutes
	print(h_m + m_m)


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	newh = 23 - h
	newm = 60 - m
	timereq = newh * 60 + newm
	print(timereq)


t = int(input())
if t >= 1 and t <= 1439:
	for i in range(t):
		hora = input().split()
		tempo = int(hora[0]) * 60 + int(hora[1]) - 1440
		tempo *= -1
		print(tempo)


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	h = l[0]
	m = l[1]
	print((23 - h) * 60 + 60 - m)


tests = int(input())
for i in range(tests):
	(h, m) = map(int, input().split())
	minutes = 24 * 60 - (h * 60 + m)
	print(minutes)


t = int(input())
while t:
	read = input().split()
	h = int(read[0])
	m = int(read[1])
	print(60 - m + 60 * (23 - h))
	t -= 1


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	result = (24 - a) * 60 - b
	print(result)


for _ in [0] * int(input()):
	a = list(map(int, input().split()))
	print((23 - a[0]) * 60 + (60 - a[1]))


import datetime
test_cases = int(input())
midnight = datetime.datetime.strptime('00.00', '%H.%M')
for input_line in range(test_cases):
	case = input().split()
	time = case[0] + '.' + case[1]
	time = datetime.datetime.strptime(time, '%H.%M')
	minutes = midnight - time
	print(int(minutes.seconds / 60))


def f(h, m):
	a = (23 - h) * 60
	b = 60 - m
	return a + b
t = int(input())
while t > 0:
	t -= 1
	(h, m) = map(int, input().split())
	print(f(h, m))


n = int(input())
for i in range(n):
	line = input()
	line = line.split()
	h = int(line[0])
	m = int(line[1])
	print(1440 - (h * 60 + m))


mod = 10 ** 9 + 7
import math

def ain():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b) = ain()
	sol = (24 - a) * 60 - b
	print(sol)


for _ in range(int(input())):
	(h, m) = list(map(int, input().split()))
	diff = (23 - h) * 60 + 60 - m
	print(diff)


t = int(input())
for i in range(t):
	hm = [int(s) for s in input().split()]
	h = hm[0]
	m = hm[1]
	hh = (23 - h) * 60
	mm = 60 - m
	print(hh + mm)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
for _ in range(inp()):
	(h, m) = inpl()
	if m == 0:
		print((24 - h) * 60)
	else:
		print((24 - h - 1) * 60 + 60 - m)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(h, m) = map(int, sys.stdin.readline().split())
	ft = 1440
	pt = 60 * h + m
	res = ft - pt
	print(res)


t = int(input())
for _ in range(0, t):
	(a, b) = map(int, input().split())
	print(60 * (24 - a) - b)


t = int(input())
for _ in range(t):
	(h, m) = [int(i) for i in input().split()]
	hours_pending = 24 - h - 1
	minutes_pending = 60 - m
	ans = hours_pending * 60 + minutes_pending
	print(ans)


n = int(input())
lst = []
for _ in range(n):
	lst.append(list(map(int, input().split())))
for i in lst:
	h = i[0]
	m = i[1]
	if m == 0:
		yo = 24 - h
		print(yo * 60)
	else:
		yo = 60 - m
		yo2 = 23 - h
		yo2 *= 60
		print(yo + yo2)


answer = []
for _ in range(int(input())):
	(hours, minutes) = map(int, input().split())
	total_minutes = 1440 - (hours * 60 + minutes)
	answer.append(total_minutes)
for i in answer:
	print(i)


n = int(input())
for i in range(n):
	var = input().split()
	hour = int(var[0])
	minute = int(var[1])
	if minute != 0:
		temp_hour = 23 - hour
		temp_min = 60 - minute
	elif minute == 0:
		temp_hour = 24 - hour
		temp_min = 0
	print(temp_hour * 60 + temp_min)


def main():

	def solve():
		(h, m) = map(int, input().split())
		print((24 - h) * 60 - m)
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for _ in range(t):
	(h, m) = [int(x) for x in input().split()]
	res = (23 - h) * 60 + (60 - m)
	print(res)


import sys
import bisect

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(h, m) = rl()
	print((23 - h) * 60 + 60 - m)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	if h < 23:
		print((23 - h) * 60 + (60 - m))
	elif h == 0 and m == 0:
		print('0')
	else:
		print(60 - m)


n = int(input())
remain = []
for i in range(n):
	(h, m) = input().split()
	h = int(h) * 60
	m = int(m)
	remain.append(24 * 60 - (h + m))
for i in remain:
	print(i)


for _ in range(int(input())):
	li = list(map(int, input().split()))
	print(60 - li[1] + (23 - li[0]) * 60)


t = int(input())
s = []
for infi in range(0, t):
	x = input()
	xx = x.split()
	h = int(xx[0])
	m = int(xx[1])
	g = 60 - m + (24 - h - 1) * 60
	s.append(g)
for i in s:
	print(i)


x = int(input())
for i in range(x):
	(hh, mm) = [int(j) for j in input().split()]
	print((23 - hh) * 60 + 60 - mm)


t = int(input())
while t:
	li = [int(i) for i in input().split()]
	mi = 60 - li[1]
	hr = 24 - li[0] - 1
	print(hr * 60 + mi)
	t -= 1


k = int(input())
while k > 0:
	n = [int(x) for x in input().split()]
	if n[1] != 0:
		print(str(60 * (24 - n[0] - 1) + (60 - n[1]) % 60))
	else:
		print(str(60 * (24 - n[0]) + (60 - n[1]) % 60))
	k = k - 1


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
for _ in range(n):
	(h, m) = get_list()
	print((24 - h) * 60 - m)


n = int(input())
for i in range(n):
	(hours, mins) = map(int, input().split())
	if hours < 12:
		a = 12 * 60
		a = (12 - (hours + 1)) * 60 + a + (60 - mins)
		print(a)
	if hours == 12:
		a = 60 - mins + (24 - (hours + 1)) * 60
		print(a)
	if hours > 12 and hours < 24:
		a = 60 - mins + (24 - (hours + 1)) * 60
		print(a)


for io in range(int(input())):
	l = [int(x) for x in input().split()]
	print((23 - l[0]) * 60 + (60 - l[1]))


T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	print(24 * 60 - 60 * A - B)


t = int(input())
for i in range(t):
	(hrs, min) = map(int, input().split())
	hrss = (24 - hrs) * 60 - min
	print(hrss)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return list(map(int, input().split()))

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(h, m) = getVars()
	print(60 * 24 - h * 60 - m)


for _ in range(int(input())):
	(h, m) = list(map(int, input().split()))
	print((23 - h) * 60 + 60 - m, sep=' ', end='\n')


for __ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	print(24 * 60 - a * 60 - b)


n = int(input())
for i in range(n):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	a = (23 - h) * 60 + (60 - m)
	print(a)


t = input()
for _ in range(int(t)):
	s = input().split(' ')
	h = int(s[0]) * 60
	m = int(s[1]) + h
	print(1440 - m)


for _ in range(int(input())):
	(n, k) = [int(__) for __ in input().split()]
	print(60 * (23 - n) + (60 - k))


def countdown(all_cases):
	[print(1440 - i) for i in all_cases]

def test_cases():
	cases = []
	number_cases = int(input())
	while number_cases > 0:
		(hora, minutos) = input().split()
		hora = int(hora)
		minutos = int(minutos)
		final = hora * 60 + minutos
		cases.append(final)
		number_cases -= 1
	return cases
all_cases = test_cases()
countdown(all_cases)


t = int(input().strip())
for i in range(t):
	(h, m) = map(int, input().strip().split(' '))
	x = 24 * 60
	y = 60 * h + m
	print(x - y)


def time_before_new_year(h, m):
	return (23 - h) * 60 + 60 - m
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print(time_before_new_year(h, m))


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(h, m) = f()
	if m == 0:
		print((24 - h) * 60)
	else:
		print(max(0, 24 - h - 1) * 60 + 60 - m)


t = int(input())
while t != 0:
	time = [int(x) for x in input().split()]
	hrs = int(time[0])
	min = int(time[1])
	totalHrs = 23 - hrs
	totalMin = 60 - min
	print(totalHrs * 60 + totalMin)
	t -= 1


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	h = l[0]
	m = l[1]
	min = (23 - h) * 60
	min2 = 60 - m
	print(min + min2)


a = int(input())
b = []
for i in range(a):
	b = input().split()
	print(((int(b[0]) - 23) * 60 + int(b[1]) - 60) * -1)


t = int(input())
while t > 0:
	(h, m) = list(map(int, input().split()))
	min_left = 60 - m
	hour_left = 24 - h - 1
	print(hour_left * 60 + min_left)
	t = t - 1


case = int(input())
for i in range(case):
	(h, m) = (int(v) for v in input().split())
	print(1440 - h * 60 - m)


t = int(input())
m = []
for i in range(t):
	m.append(list(map(int, input().split())))
for i in m:
	a = i[0]
	b = i[1]
	print(1440 - (a * 60 + b))


t = int(input())
for _ in range(0, t):
	arr = list(map(int, input().strip().split(' ')))
	hours = 24 - arr[0] - 1
	minutes = 60 - arr[1]
	print(hours * 60 + minutes)


t = int(input())
while t > 0:
	a = input().split()
	h = int(a[0])
	m = int(a[1])
	h = 23 - h
	m = 60 - m
	r = h * 60 + m
	print(r)
	t -= 1


import sys
input = sys.stdin.readline
result = ''
for i in range(int(input())):
	(h, m) = map(int, input().split())
	ans = (24 - h) * 60 - m
	result += str(ans) + '\n'
print(result)


n = int(input())
i = 0
for i in range(n):
	(t0, t1) = map(int, input().split())
	h = 24 - t0
	s = 60 * h - t1
	print(s)


q = int(input())
for i in range(q):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	midh = 24
	midm = 60
	h = midh - a - 1
	m = midm - b
	tot = h * 60 + m
	print(tot)


t = int(input())
list1 = []
for i in range(0, t):
	a = input().split()
	t1 = int(a[0])
	t2 = int(a[1])
	m = 23 - t1
	n = 60 - t2
	ans = m * 60 + n
	list1.append(ans)
for a in range(len(list1)):
	print(list1[a])


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		(a, b) = LI()
		x = 0
		x += 60 - b
		a += 1
		if a == 24:
			pass
		else:
			x += 60 * (24 - a)
		ans.append(x)
	for x in ans:
		print(x)
main()


m = int(input())
for i in range(m):
	(a, b) = map(int, input().split())
	h = 24 - a - 1
	m = abs(60 - b)
	print(h * 60 + m)


tc = int(input())
min_day = 24 * 60
for i in range(tc):
	(h, m) = [int(x) for x in input().split()]
	time = h * 60 + m
	left_m = min_day - time
	print(left_m)


t = int(input())
while t:
	t -= 1
	(h, m) = [int(i) for i in input().split()]
	x = (23 - h) * 60 + (60 - m)
	print(x)


t = int(input())
for j in range(t):
	res = 0
	(n, k) = list(map(int, input().split()))
	res += n * 60
	res += k
	print(1440 - res)


for i in range(int(input())):
	s = input().split()
	h = int(s[0])
	m = int(s[1])
	f = h * 60
	print(24 * 60 - f - m)


for _ in range(int(input())):
	(h, m) = [int(s) for s in input().split()]
	ans = 24 - h
	ans2 = 60 - m
	print((ans - 1) * 60 + ans2)


n = int(input())
sum = 0
listA = []
for i in range(0, n):
	(k, l) = [int(i) for i in input().split()]
	sum = (23 - k) * 60 + (60 - l)
	listA.append(sum)
for i in range(0, n):
	print(listA[i])


t = int(input())
for i in range(0, t):
	(n, m) = list(map(int, str(input()).split(' ')))
	print(24 * 60 - (n * 60 + m))


n = int(input())
inputs = [list(map(int, input().split(' '))) for i in range(n)]
res = []
for i in range(len(inputs)):
	res.append(str((23 - inputs[i][0]) * 60 + (60 - inputs[i][1])))
print('\n '.join(res))


def solve(h, m):
	return 24 * 60 - h * 60 - m
n = int(input())
for i in range(n):
	(h, m) = [int(x) for x in input().strip().split(' ')]
	print(solve(h, m))


t = int(input())
for i in range(0, t):
	x = input()
	h = int(x.split(' ')[0])
	m = int(x.split(' ')[1])
	remaining = (24 - h - 1) * 60 + (60 - m)
	print(remaining)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	t = 0
	if h < 23:
		t = t + (23 - h) * 60
	if m < 60:
		t = t + (60 - m)
	print(t)


def main():
	tst_case = int(input())
	while tst_case != 0:
		(hh, mm) = map(int, input().split())
		req_min = 60 - mm
		req_hr = 24 - hh - 1
		req_min += req_hr * 60
		print(req_min)
		tst_case -= 1
main()


def solver(time):
	hr = time[0]
	min = time[1]
	return (24 - hr - 1) * 60 + (60 - min)
test_cases = input()
for test in range(int(test_cases)):
	time = [int(x) for x in input().split()]
	print(solver(time))


T = int(input())
for i in range(T):
	(H, M) = input().split()
	m_tot = int(H) * 60 + int(M)
	m_left = 24 * 60 - m_tot
	print(m_left)


def answer():
	n = int(input())
	while n:
		a = input().split()
		a = [int(x) for x in a]
		(h, m) = (a[0], a[1])
		print((23 - h) * 60 + 60 - m)
		n -= 1
answer()


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	print((24 - a - 1) * 60 + 60 - b)


k = int(input())
l = []
j = []
for i in range(k):
	k = [int(s) for s in input().split()]
	h = abs(k[0] - 23) * 60
	m = abs(k[1] - 60)
	r = h + m
	j.append(r)
for o in j:
	print(o)


def inp(dtype=str, strip=True):
	s = input()
	res = [dtype(p) for p in s.split()]
	res = res[0] if len(res) == 1 and strip else res
	return res

def problem1():
	t = inp(int)
	for _ in range(t):
		(h, m) = inp(int)
		print((23 - h) * 60 + (60 - m))

def problem2():
	pass

def problem3():
	pass

def problem4():
	pass

def problem5():
	pass
problem1()


t = int(input())
for i in range(0, t):
	(h, m) = input().split()
	c = 0
	h = int(h)
	m = int(m)
	c = 1440 - h * 60 - m
	print(c)


t = int(input())
for k in range(t):
	entrada = list(map(int, input().split(' ')))
	horas = int(entrada[0])
	minutos = int(entrada[1])
	print(24 * 60 - (horas * 60 + minutos))


T = int(input())
while T:
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + (60 - m))
	T -= 1


def main():
	t = int(input())
	while t:
		t -= 1
		(h, m) = [int(i) for i in input().split()]
		print((23 - h) * 60 + (60 - m))
main()


t = int(input())
while t:
	(h, m) = map(int, input().split())
	k = 0
	if m != 0:
		k += 60 - m
		k += (24 - h - 1) * 60
	else:
		k += (24 - h) * 60
	print(k)
	t -= 1


t = int(input())
for i in range(t):
	(hh, mm) = map(int, input().split())
	print(1440 - hh * 60 - mm)


for _ in range(int(input())):
	vals = list(map(int, input().split()))
	h = vals[0]
	m = vals[1]
	ans = (24 - (h + 1)) * 60 + (60 - m)
	print(ans)


T = int(input())
for _ in range(0, T):
	(h, m) = map(int, input().split())
	x = h * 60 + m
	ans = 24 * 60 - x
	print(ans)


s = int(input())
for i in range(1, s + 1):
	(d, m) = list(map(int, input().split()))[:2]
	n = 24 - d
	h = 23 - d
	j = 60 - m
	if m == 0:
		f = 60 * n
	else:
		f = h * 60 + j
	print(f)


def case():
	(h, m) = map(int, input().split())
	minpassed = h * 60 + m
	print(24 * 60 - minpassed)
for _ in range(int(input())):
	case()


n = int(input())
a = list((list(map(int, input().split())) for i in range(n)))
for i in range(n):
	print(abs(a[i][0] - 23) * 60 + abs(a[i][1] - 60))


n = int(input())
for i in range(n):
	(hour, minute) = map(int, input().split())
	diff_h = abs(23 - hour)
	diff_m = abs(60 - minute)
	print(diff_h * 60 + diff_m)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	if h >= 24 or m >= 60:
		break
	else:
		y = 24 * 60
		z = h * 60 + m
		print(abs(y - z))


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
for _ in range(int(stdin.readline())):
	(x, y) = map(int, stdin.readline().strip().split())
	sum = 60 - y + (24 - (x + 1)) * 60
	stdout.write(str(sum) + '\n')


t = int(input())
for i in range(t):
	h_m = [int(i) for i in input().split(' ')]
	h_rem = 23 - h_m[0]
	m_rem = 60 - h_m[1]
	print(h_rem * 60 + m_rem)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(hh, mm) = map(int, sys.stdin.readline().split())
	minutes = 60 - mm
	hours = (24 - hh - 1) * 60
	print(minutes + hours)


def solve(h, m):
	hmin = 23 - h
	mmin = 60 - m
	return hmin * 60 + mmin
numTestCase = int(input())
for i in range(numTestCase):
	(h, m) = map(int, input().split())
	print(solve(h, m))


t = int(input())
for i in range(t):
	(hod, min) = input().split()
	(hod, min) = (int(hod), int(min))
	print(60 * 24 - 60 * hod - min)


a = []
t = int(input(''))
for i in range(t):
	x = list(map(int, input('').split()))
	a.append(x)
for i in range(len(a)):
	temp = 23 - a[i][0]
	minutes = 60 - a[i][1]
	minutes = minutes + temp * 60
	print(minutes)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

def solve():
	(a, b) = mints()
	print(24 * 60 - a * 60 - b)
for i in range(mint()):
	solve()


t = int(input())
ans = []
for i in range(t):
	time = list(map(int, input().split()))
	(h, m) = time
	remainhour = 23 - h
	remainmin = 60 - m + remainhour * 60
	ans.append(remainmin)
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	l = input().split(' ')
	h = int(l[0])
	m = int(l[1])
	ans = (23 - h) * 60 + 60 - m
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = (24 - n) * 60
	ans -= k
	print(ans)


def find_minutes_left(hours, minutes):
	hours_left = 23 - hours
	minutes_left = 60 - minutes
	return hours_left * 60 + minutes_left
test_cases = int(input())
final_output = []
while test_cases != 0:
	time_string = input()
	(str_hours, str_minutes) = time_string.split(' ')
	hours = int(str_hours)
	minutes = int(str_minutes)
	minutes_left = find_minutes_left(hours, minutes)
	final_output.append(minutes_left)
	test_cases -= 1
for _ in final_output:
	print(_)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write

def ii():
	return int(readline())

def mi():
	return map(int, readline().rstrip().split())

def li():
	return list(readline().rstrip())

def lmi():
	return list(map(int, readline().rstrip().split()))

def end(*arg):
	print(*arg)
	sys.exit()

def main():
	n = ii()
	for _ in range(n):
		(h, t) = mi()
		ti = h * 60 + t
		print(1440 - ti)
	return
main()


def solve(h, m):
	return (24 - h) * 60 - m
N = int(input())
for _ in range(N):
	(h, m) = map(int, input().split())
	print(solve(h, m))


def HNY2020(h, m):
	one_day_min = 60 * 24
	h_in_min = h * 60
	h_in_min_plus_min = h_in_min + m
	dif_in_min = one_day_min - h_in_min_plus_min
	print(dif_in_min)
n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	HNY2020(h, m)


for _ in range(int(input())):
	(hh, mm) = map(int, input().split())
	cnt = 0
	while hh < 23:
		cnt += 60
		hh += 1
	while mm < 60:
		cnt += 1
		mm += 1
	print(cnt)


t = int(input())
A = [list(map(int, input().split())) for _ in range(t)]
res = []
for a in A:
	ans = (23 - a[0]) * 60
	ans += 60 - a[1]
	res.append(ans)
for a in res:
	print(a)


t = int(input())
while t > 0:
	t -= 1
	(h, m) = map(int, input().split())
	x = 23 - h
	y = 60 - m
	print(x * 60 + y)


for x in range(0, int(input())):
	(hour, minutes) = input().split()
	hourInMinutes = int(hour) * 60
	print(24 * 60 - (int(minutes) + hourInMinutes))


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, m) = map(int, input().split())
	ans = (23 - n % 24) * 60 + 60 - m
	print(ans)


def f(h, m):
	return 1440 - 60 * h - m
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	print(f(h, m))


t = int(input())
while t != 0:
	t -= 1
	(a, b) = map(int, input().split())
	print(60 - b + (23 - a) * 60)


tests = int(input())
for t in range(tests):
	inputstring = input()
	hour = int(inputstring.split(' ')[0])
	minut = int(inputstring.split(' ')[1])
	resultedMinuts = 60 - minut
	hour += 1
	resultedMinuts += (24 - hour) * 60
	print(resultedMinuts)


n = int(input())
b = []
for i in range(n):
	x = list(map(int, input().split()))
	b.append((23 - x[0]) * 60 + (60 - x[1]))
for i in range(n):
	print(b[i])


hours = []
minutes = []
y = 0
z = 0
number = int(input())
for i in range(0, number):
	(h, m) = input().split()
	hours.append(h)
	minutes.append(m)
while y < number and z < number:
	if int(hours[y]) < 24 and int(minutes[z]) < 60:
		k = 24 - (int(hours[y]) + 1)
		l = 60 - int(minutes[z])
		answer = k * 60 + l
		y += 1
		z += 1
		print(answer)


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	rs = 24 * 3600 - a * 3600 - b * 60
	print(int(rs / 60))


t = int(input())
for _ in range(t):
	(h, m) = [int(i) for i in input().split()]
	print(24 * 60 - (h * 60 + m))


from collections import Counter

def solve():
	(a, b) = list(map(int, input().split()))
	if a <= 12:
		return int(60 * (12 - a) - b + 12 * 60)
	return int(60 * (24 - a) - b)
for i in range(int(input())):
	print(solve())


n = int(input())
for _ in range(n):
	x = input().split()
	print(1440 - int(x[0]) * 60 - int(x[1]))


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
for _ in range(int(ri())):
	(h, m) = Ri()
	m1 = 60 - m
	m2 = (24 - h - 1) * 60
	print(m1 + m2)


n = int(input())
num = [[j for j in map(int, input().split())] for i in range(n)]
for i in range(n):
	ans = 0
	ans += (23 - num[i][0]) * 60
	ans += 60 - num[i][1]
	print(ans)


for i in range(int(input())):
	hh = 23
	mm = 60
	(a, b) = map(int, input().split())
	print((hh - a) * 60 + mm - b)


n = int(input(''))
new_year = 24 * 60
output = []
for i in range(n):
	time = list(map(int, input('').split(' ')))
	output.append(new_year - (time[0] * 60 + time[1]))
for o in output:
	print(o)


T = eval(input())
for t in range(T):
	(x, y) = map(int, input().split())
	print((24 - x - 1) * 60 + 60 - y)


t = int(input())
l = []
for i in range(0, t):
	l.append(input().split())
for j in l:
	print(60 * (23 - int(j[0])) + (60 - int(j[1])))


exec(int(input()) * 'a,b=map(int,input().split());print(60*(24-a)-b);')


for _ in range(int(input())):
	A = input().split()
	h = int(A[0])
	m = int(A[1])
	print(24 * 60 - h * 60 - m)


exec(int(input()) * 'h,m=map(int,input().split());print((1440-60*h-m)%1440);')


N_SETS = int(input())
for i in range(N_SETS):
	(h, m) = [int(x) for x in input().split()]
	print((23 - h) * 60 + (60 - m))


n = int(input())
for i in range(n):
	(hh, mm) = map(int, input().split())
	total = 0
	total += 60 - mm
	total += (24 - (hh + 1)) * 60
	print(total)


runtime = int(input(''))

def solve(a, b):
	return 24 * 60 - a * 60 - b
for i in range(0, runtime):
	inputtime = input('')
	hour = int(inputtime.split()[0])
	minutes = int(inputtime.split()[1])
	result = solve(hour, minutes)
	print(result)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	temp1 = 24 * 60
	final = temp1 - (60 * h + m)
	print(final)


for _ in range(int(input())):
	(hour, min) = map(int, input().split())
	ans = (24 - hour) * 60 - min
	print(ans)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(h, m) = mi()
	print((23 - h) * 60 + (60 - m))


A = []
for i in range(int(input())):
	(a, b) = map(int, input().split())
	A.append((24 - a) * 60 + -b)
for a in A:
	print(a)


for i in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	k = 60 - m
	p = n + 1
	x = 24 - p
	print(x * 60 + k)


a = int(input())
for b in range(a):
	(h, m) = map(int, input().split())
	t = h * 60 + m
	print(24 * 60 - t)


times = int(input())
for i in range(times):
	day = 1440
	hour = input()
	hour = hour.split()
	for k in range(len(hour)):
		hour[k] = int(hour[k])
	minutes = hour[0] * 60 + hour[1]
	print(day - minutes)


t = int(input())
while t != 0:
	(h, m) = map(int, input().split())
	s = h * 60 + m
	print(1440 - s)
	t -= 1


(t,) = list(map(int, input().split()))

def solve(h, m):
	return (23 - h) * 60 + (60 - m)
for item in range(t):
	(h, m) = list(map(int, input().split()))
	print(solve(h, m))


t = int(input())
while t:
	(h, m) = map(int, input().split())
	if m:
		print((23 - h) * 60 + 60 - m)
	else:
		print((24 - h) * 60)
	t -= 1


n = int(input())
I = []
for i in range(n):
	k = [int(i) for i in input().split()]
	I.append(k)

def output(l):
	return (23 - l[0]) * 60 + 60 - l[1]
for i in range(n):
	print(output(I[i]))


t = int(input())
for i in range(t):
	(h, m) = [int(x) for x in input().split()]
	print(1440 - h * 60 - m)


t = int(input())
f = 1440
for i in range(t):
	(a, b) = input().strip().split(' ')
	(a, b) = [int(a), int(b)]
	a = 60 * a
	ans = 1440 - (a + b)
	print(ans)


t = int(input())
for i in range(t):
	(h, m) = list(map(int, input().split()))
	ANSWER = 0
	if h != 23:
		ANSWER += 60 * (23 - h)
		if m != 0:
			ANSWER += 60 - m
		if m == 0:
			ANSWER += 60
	else:
		ANSWER += 60 - m
	print(ANSWER)


t = int(input())
while t:
	(hr, mins) = [int(hr) for hr in input().split()]
	val = (23 - hr) * 60 + (60 - mins)
	print(val)
	t -= 1


import math

def s():
	(h, m) = [int(x) for x in input().split(' ')]
	hrs = 24 - h - 1
	ans = 0
	ans += hrs * 60
	ans += 60 - m
	return ans
t = int(input())
for i in range(t):
	ans = s()
	print(ans)


while True:
	n = int(input(''))
	if 1 <= n <= 1439:
		break
i = 0
L = []
while i < n:
	while True:
		ch = input('')
		L.append(ch.split(' '))
		if 0 <= int(L[i][0]) < 24 and 0 <= int(L[i][1]) < 60:
			break
		else:
			L.remove(L[i])
	i += 1
for i in range(n):
	h = int(L[i][0])
	mn = int(L[i][1])
	temp = 0
	while h < 23:
		temp += 60
		h += 1
	print(temp + 60 - mn)


n = int(input())
for i in range(n):
	(h, m) = [int(i) for i in input().split()]
	h *= 60
	total = h + m
	print(1440 - total)


import sys

def main():
	input_data = int(sys.stdin.readline())
	for _ in range(input_data):
		(H, M) = (int(x) for x in sys.stdin.readline().split())
		hr_til_nd = 23 - H
		m_til_nd = 60 - M
		hr_to_min = hr_til_nd * 60
		sys.stdout.write(f'{hr_to_min + m_til_nd}\n')
main()


n = int(input())
for _ in range(n):
	(h, m) = map(int, input().split())
	d1 = 23 - h
	d2 = 60 - m
	s = d1 * 60 + d2
	print(s)


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	r = 0
	if h is 0:
		h = 23
		m = 60 - m
		r = h * 60 + m
		print(r)
	elif h is 23:
		m = 60 - m
		r = m
		print(r)
	elif h > 0 and h < 23:
		h = 24 - h - 1
		m = 60 - m
		r = h * 60 + m
		print(r)


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	t = inin()
	for _ in range(t):
		(x, y) = cin()
		if x == 0 and y == 0:
			print(0)
			continue
		x = 23 - x
		y = 60 - y
		print(x * 60 + y)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import sys
Input = sys.stdin.readline
for i in range(int(input())):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + (60 - m))


t = int(input())
for i in range(t):
	(hour, minute) = [int(x) for x in input().split()]
	print(1440 - (hour * 60 + minute))


for j in range(int(input())):
	(m, n) = map(int, input().split())
	t = m * 60 + n
	print(24 * 60 - t)


lst = []
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	h = 23 - h
	m = 60 - m
	lst.append(h * 60 + m)
for i in range(len(lst)):
	print(lst[i])


from math import *
import os, sys
from bisect import *
from io import BytesIO
sys.setrecursionlimit(10 ** 9)
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	a *= 60
	a += b
	print(24 * 60 - a)


for _ in range(int(input())):
	count = 0
	(h, m) = list(map(int, input().split()))
	z = 24 - h
	count += 60 * z - m
	print(count)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	s = a * 60
	t = s + b
	w = 1440 - t
	print(w)


def minutes_before():
	for i in range(int(input())):
		x = list(map(int, input().split()))
		print((23 - x[0]) * 60 + (60 - x[1]))
minutes_before()


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a < 23 and b < 60:
		o = 23 - a
		p = o * 60
		q = 60 - b
		r = p + q
		print(r)
	elif a == 23:
		e = 60 - b
		print(e)


n = int(input())
for i in range(0, n):
	(a, b) = input().split()
	c = 24 * 60
	d = c - (int(a) * 60 + int(b))
	print(d)


for i in range(int(input())):
	total = 0
	(hours, minutes) = map(int, input().split())
	hours *= 60
	total = hours + minutes
	print(1440 - total)


for i in range(int(input())):
	b = list((int(x) for x in input().split()))
	s = b[0] * 60 + b[1]
	print(24 * 60 - s)


try:
	for _ in range(int(input())):
		(h, m) = map(int, input().split())
		ans = (24 - h - 1) * 60 + (60 - m)
		print(ans)
except Exception as e:
	print(e)


def timer(hr, mi):
	hour = 23
	minutes = 60
	res_hr = hour - hr
	res_mi = minutes - mi
	result = res_hr * 60 + res_mi
	return result
t = int(input())
while t > 0:
	(hr, mi) = input().split()
	(hr, mi) = (int(hr), int(mi))
	print(timer(hr, mi))
	t -= 1


for i in range(int(input())):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	x = 23
	y = 60
	hr = x - a
	mi = y - b
	ans = hr * 60 + mi
	print(ans)


tc = int(input())
for _ in range(tc):
	l = input().split()
	(h, m) = (int(l[0]), int(l[1]))
	print(1440 - (60 * h + m))


for i in range(int(input())):
	j = list(map(int, input().split(' ')))
	a = (24 - j[0]) * 60 - j[1]
	print(a)


for _ in range(int(input())):
	x = input().split()
	(a, b) = (int(x[0]), int(x[1]))
	ans = 60 - b + (24 - a - 1) * 60
	print(ans)


t = int(input())
for _ in range(t):
	lista = list(map(int, input().split()))
	horas = 23 - lista[0]
	minutos = 60 - lista[1]
	qtd = minutos + horas * 60
	print(qtd)


for i in range(int(input())):
	a = list(map(int, input().strip().split()))[:2]
	b = (24 - a[0]) * 60 + (60 - a[1])
	print(b - 60)


for _ in range(int(input())):
	(h, m) = [int(x) for x in input().split()]
	r = (23 - h) * 60 + 60 - m
	print(r)


def time(hour, minute):
	day = 1440
	hour = hour * 60
	return day - (hour + minute)
t = int(input())
a = []
for i in range(t):
	a.append([int(j) for j in input().split()])
for i in range(t):
	for j in range(1):
		print(time(a[i][0], a[i][1]))


exec(int(input()) * 'i,j=map(int,input().split());print(60*(24-i)-j);')


for i in range(int(input())):
	(h, m) = map(int, input().strip().split())
	print(60 - m + 60 * (24 - h - 1) if 24 - h > 1 else 60 - m)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(n, m) = map(int, stdin.readline().strip().split())
	ans = (23 - n) * 60 + (60 - m)
	print(ans)


n = int(input())
for i in range(n):
	(hours, minutes) = map(int, input().split())
	print(24 * 60 - hours * 60 - minutes)


n = int(input())
while n > 0:
	(h, m) = list(map(int, input().split(' ')))
	to_h = 23 - h
	to_m = 60 - m
	print(to_h * 60 + to_m)
	n -= 1


n = int(input())
for i in range(n):
	inn = input()
	h = int(inn.split()[0])
	m = int(inn.split()[1])
	hr = 23 - h
	mr = 60 - m
	print(hr * 60 + mr)


def get_ans(h, m):
	ans = (23 - h) * 60 + (60 - m)
	return ans
t = int(input().strip())
for i in range(t):
	(h, m) = list(map(int, input().strip().split()))
	print(get_ans(h, m))


from sys import stdin, stdout
n = int(stdin.readline().strip())
for t in range(n):
	(h, c) = list(map(int, stdin.readline().strip().split()))
	ans = 0
	if c != 0:
		ans += 60 - c
		h += 1
	ans += (24 - h) * 60
	print(ans)


t = int(input())
for i in range(t):
	(h, m) = [int(x) for x in input().split()]
	total = (23 - h) * 60 + 60 - m
	print(total)


def main():
	answer = ''
	for test in range(int(input())):
		(hours, minutes) = list(map(int, input().split(' ')))
		time = hours * 60 + minutes
		answer += str(24 * 60 - time) + '\n'
	print(answer)
main()


from sys import stdin
h = 0
m = 0
day = 0
timeres = 0
t = int(stdin.readline())
while t != 0:
	t -= 1
	timeres = 0
	(h, m) = (int(x) for x in stdin.readline().split())
	day = 60 * 24
	timeres = h * 60 + m
	print(day - timeres)


import sys
t = int(sys.stdin.readline().rstrip())

def main():
	for _ in range(t):
		(h, m) = map(int, sys.stdin.readline().split())
		ans = (24 - h) * 60 - m
		yield ans
ans = main()
print(*ans, sep='\n')


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	(h, m) = map(int, input().split())
	minutes = 24 * 60 - (h * 60 + m)
	print(minutes)
t = int(input())
for _ in range(t):
	main()


M = int(input())
things = []
for x in range(0, M):
	a = input()
	things.append(a)
for x in things:
	(a, b) = x.split()
	a = int(a)
	b = int(b)
	ans = (23 - a) * 60 + (60 - b)
	print(ans)


def solve(h, m):
	return (23 - h) * 60 + (60 - m)
for i in range(int(input())):
	(h, m) = map(int, input().split())
	print(solve(h, m))


time = 1440
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	if h != 0 or m != 0:
		print(time - (h * 60 + m))
	else:
		print(0)


import operator as o
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	if m != 0:
		min = 60 * (23 - h) + 60 - m
	else:
		min = 60 * (24 - h)
	print(min)


def main():
	t = int(input())
	for i in range(t):
		(h, m) = map(int, input().split())
		ans = 60 * (24 - min(h + 1, 24))
		ans += 60 - m
		print(ans)
main()


def func(hm):
	(h, m) = list(map(int, hm.split()))
	return 1440 - h * 60 - m

def main():
	t = int(input())
	for i in list(map(func, [input() for i in range(t)])):
		print(i)
main()


t = int(input())
answers = []
for ti in range(t):
	all = 1440
	ints = list(map(int, input().split()))
	(h, m) = (ints[0], ints[1])
	answers.append(all - (60 * h + m))
for a in answers:
	print(a)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = 1440
	y = int(a * 60 + b)
	print(int(c - y))


def solve_test():
	n = int(input())
	for i in range(n):
		(h, m) = map(int, input().split())
		minute = 1440 - h * 60 - m
		print(minute)

def main():
	solve_test()
main()


t = int(input())
for numbers in range(t):
	(a, b) = map(int, input().split())
	print(24 * 60 - b - a * 60)


test = int(input())
while test:
	left = 0
	(h, m) = map(int, input().split())
	if 24 - h == 1:
		left = 60 - m
	else:
		left = (24 - (h + 1)) * 60 + (60 - m)
	print(left)
	test -= 1


test = int(input())
while test != 0:
	time = input().split(' ')
	hour = int(time[0])
	minute = int(time[1])
	result = (23 - hour) * 60 + (60 - minute)
	print(result)
	test -= 1


t = int(input())
q = []
for i in range(t):
	l = list(input().split())
	h = int(l[0])
	m = int(l[1])
	if m != 0:
		q.append((23 - h) * 60 + (60 - m))
	else:
		q.append((24 - h) * 60)
for i in q:
	print(i)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	m_n = 60 - m
	h_n = (23 - h) * 60
	print(h_n + m_n)


T = int(input())
for i in range(1, T + 1):
	s = input()
	s2 = s.split()
	(h, m) = map(int, s2)
	h = h * 60
	t_in_minutes = h + m
	ttny = 24 * 60 - t_in_minutes
	print(ttny)


t = int(input())
for i in range(t):
	temp = list(input().split())
	n = int(temp[0])
	m = int(temp[1])
	res = 60 * (23 - n) + (60 - m)
	print(res)


for i in range(int(input())):
	t = list(map(int, input().split()))
	print((24 - t[0] - 1) * 60 + 60 - t[1])


t = int(input())
for i in range(t):
	(h, m) = [int(j) for j in input().split()]
	total = 24 * 60
	print(total - h * 60 - m)


n = int(input())
for i in range(0, n):
	(h, m) = map(int, input().split())

	def tongm(a):
		return a * 60
	gt = tongm(24)
	print(gt - (tongm(h) + m))


import sys
import math
CASE = 1
rla = ''

def solve():
	(a, b) = map(int, input().split())
	print((24 - a) * 60 - b)
while True:
	rla = sys.stdin.readline()
	cases = 1
	if not rla:
		break
	if (rla == '\n') | (rla == ''):
		continue
	if CASE == 1:
		cases = int(rla)
	for cas in range(cases):
		solve()


t = int(input())
ny = 24 * 60
for _ in range(t):
	(h, m) = map(int, input().split())
	r = h * 60 + m
	print(ny - r)


t = int(input())
for i in range(t):
	(h, m) = [int(x) for x in input().split()]
	minutesLeft = 0
	minutesLeft += 60 - m
	while h < 23:
		minutesLeft += 60
		h += 1
	print(minutesLeft)


n = int(input())

def get_time(h, m):
	a = (23 - h) * 60
	b = 60 - m
	print(a + b)
for i in range(n):
	(h, m) = map(int, input().split())
	get_time(h, m)


t = int(input())
for z in range(t):
	L = list(map(int, input().split()))
	hr = 24 - L[0]
	min = L[1]
	con = hr * 60 - min
	print(con)


dia = 60 * 24
qtd = int(input())
for _ in range(qtd):
	(h, m) = map(int, input().split())
	atual = h * 60 + m
	print(dia - atual)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	mi = 24 - h
	if m > 0:
		mi = mi - 1
		print(mi * 60 + 60 - m)
	elif m == 0:
		print(mi * 60)


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	x = (23 - h) * 60 + 60 - m
	print(x)


n = int(input())
while n:
	n -= 1
	(q, m) = map(int, input().split(' '))
	print((23 - q) * 60 + 60 - m)


t = int(input())
while t:
	k = input()
	k = k.split(' ')
	h = int(k[0])
	m = int(k[1])
	ans = (23 - h) * 60 + 60 - m
	print(ans)
	t -= 1


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	print(24 * 60 - x * 60 - y)


try:
	n = int(input())
	for i in range(0, n):
		(h, m) = list(map(int, input().split(' ')))
		k = h * 60 + m
		print(1440 - k)
except:
	pass


t = int(input())
total = 60 * 24
for i in range(t):
	inp = input().split()
	(hours, minutes) = (int(inp[0]), int(inp[1]))
	current = hours * 60 + minutes
	print(total - current)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split(' '))
	b = 60 - b
	if b % 60:
		print((23 - a) * 60 + b)
	else:
		print((24 - a) * 60)


t = int(input())
for i in range(t):
	time = input()
	(hh, mm) = tuple(time.split())
	hh = int(hh)
	mm = int(mm)
	minutesLeft = (23 - hh) * 60 + 60 - mm
	print(minutesLeft)


def main(lst):
	res_lst = []
	for i in lst:
		res_lst.append(24 * 60 - (i[0] * 60 + i[1]))
	return res_lst
n = int(input())
lst = []
for i in range(n):
	lst.append(list(map(int, input().split())))
print(*main(lst))


n = int(input())
for x in range(n):
	(a, b) = list(map(int, input().split()))
	total = 24
	remaining = a
	left = total - remaining
	left *= 60
	left -= b
	print(left)


for k in range(int(input())):
	(h, m) = map(int, input().split())
	ans = 0
	ans += 60 - m
	ans += (23 - h) * 60
	print(ans)


x = int(input())
while x > 0:
	s = input()
	y = s.split(' ')
	h = int(y[0])
	m = int(y[1])
	hl = 23 - h
	ml = 60 - m
	res = hl * 60 + ml
	print(res)
	x = x - 1


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	pre = h * 60 + m
	output = 1440 - pre
	print(output)


T = int(input())
while T > 0:
	l = input().split()
	h = int(l[0])
	m = int(l[1])
	print(24 * 60 - (h * 60 + m))
	T -= 1


test = int(input())
i = 0
constant = 1440
while i < test:
	(hour, minute) = input().split()
	hour = int(hour)
	minute = int(minute)
	current = hour * 60 + minute
	left = constant - current
	print(left)
	i += 1


for i in range(int(input())):
	(hours, mins) = map(int, input().split())
	net_time = hours * 60 + mins
	total_time = 1440 - net_time
	print(total_time)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	d = abs(x * 60 + y - 24 * 60)
	print(d)


q = int(input())
while q:
	(h, m) = map(int, input().split())
	ans = 60 - m
	ans += (24 - (h + 1)) * 60
	print(ans)
	q -= 1


def main():
	t = int(input())
	for i in range(t):
		arr = input().split(' ')
		(arr[0], arr[1]) = (int(arr[0]), int(arr[1]))
		if arr[0] == 23:
			print(60 - arr[1])
		else:
			h = 0
			for i in range(arr[0] + 1, 24):
				h += 1
			print(h * 60 + 60 - arr[1])
main()


try:
	tc = int(input())
except:
	exit()
for _ in range(tc):
	(h, m) = map(int, input().split())
	if h == 23:
		print(60 - m)
	else:
		ans = 60 - m
		ans += (24 - h - 1) * 60
		print(ans)


s = ''
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	d = 24 * 60 - h * 60 - m
	s += str(d) + '\n'
print(s)


t = int(input())
hm = [list(map(int, input().split())) for _ in range(t)]
for hmi in hm:
	resh = 23 - hmi[0]
	resm = 60 - hmi[1]
	print(resh * 60 + resm)


t = int(input())
if 1 <= t <= 1439:
	for i in range(t):
		mins = []
		time = input().split()
		time = [int(i) for i in time]
		for h in range(time[0], 24):
			for m in range(time[1], 60):
				mins.append(1)
			time[0] += 1
			time[1] = 0
		print(len(mins))
else:
	print('NO')
	exit()


testcase = int(input())
for _ in range(testcase):
	hm = input().split()
	(h, m) = (int(hm[0]), int(hm[1]))
	print(1440 - (h * 60 + m))


T = int(input())
for i in range(T):
	(h, m) = map(int, input().split())
	s = (23 - h) * 60 + (60 - m)
	print(s)


def main():
	t = int(input())
	for _ in range(t):
		(h, m) = map(int, input().split())
		if m == 0:
			print((24 - h) * 60)
		else:
			print((23 - h) * 60 + 60 - m)
main()


num_of_q = int(input())
d = 24 * 60
for i in range(num_of_q):
	(h, m) = [int(i) for i in input().split()]
	m += h * 60
	print(d - m)


def solution(h, m):
	return 1440 - (h * 60 + m)
for _ in range(int(input())):
	(h, m) = [int(x) for x in input().split()]
	print(solution(h, m))


t = int(input())
for _ in range(t):
	(h, m) = [int(i) for i in input().split()]
	c = 0
	c += 60 - m
	c += (24 - h - 1) * 60
	print(c)


ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
for _ in range(ii()):
	(a, b) = kk()
	print(60 - b + 60 * (23 - a))


tests = int(input())
for i in range(tests):
	c = 0
	(h, m) = map(int, input().strip().split())
	c += (24 - h) * 60 - m
	print(c)


minutes_in_a_day = 24 * 60
t = int(input())
answer = [0] * t
for n in range(t):
	(h, m) = [int(i) for i in input().split()]
	minutes_passed = h * 60 + m
	answer[n] = minutes_in_a_day - minutes_passed
print(*answer, sep='\n')


for t in range(int(input())):
	(h, m) = map(int, input().split())
	total = h * 60 + m
	req = 24 * 60
	print(req - total)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + 59 - m + 1)


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	for _ in range(t):
		(h, m) = MI()
		ans = (24 - (h + 1)) * 60 + (60 - m)
		print(ans)
main()


t = input()
t = int(t)
for i in range(t):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	if h == 0 and m == 0:
		print(0)
		continue
	ret = 24 * 60
	ret -= h * 60
	ret -= m
	print(ret)


t = int(input())
for _ in range(t):
	s = list(map(int, input().split()))
	(h, m) = (s[0], s[1])
	print((24 - h) * 60 - m)


n = int(input())
a = []
sum1 = []
for i in range(n):
	b = list(map(int, input().split()))
	a.append(b)
for i in range(len(a)):
	s = 0
	for j in range(1):
		a[i][j] = a[i][j] * 60
	for j in range(len(b)):
		s = s + a[i][j]
	sum1.append(60 * 24 - s)
for i in range(len(sum1)):
	print(sum1[i])


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = 24 - a - 1
	d = 60 - b
	f = c * 60 + d
	print(f)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	print(60 * 24 - (a * 60 + b))


t = int(input())
for i in range(t):
	time = input().split()
	print(1440 - (int(time[0]) * 60 + int(time[1])))


from sys import stdin
from collections import defaultdict
t = int(stdin.readline().strip())
for _ in range(t):
	(h, m) = list(map(int, stdin.readline().split()))
	print(24 * 60 - (h * 60 + m))


t = int(input())
for i in range(t):
	[h, m] = list(map(int, input().split()))
	tot = h * 60 + m
	if tot != 0:
		print(1440 - tot)
	else:
		print(0)


import sys
from bisect import bisect_left as bl, bisect_right as br, bisect
import math
from itertools import zip_longest as zl
from itertools import groupby as gb
from itertools import combinations as comb
from itertools import combinations_with_replacement as cwr
from collections import defaultdict as dd
from collections import deque as dq
from collections import Counter as c
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return input()

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
for _ in range(int(data())):
	(h, m) = sp()
	ans = 0
	if m == 0:
		ans += (24 - h) * 60
	else:
		ans += (24 - h - 1) * 60
		ans += 60 - m
	print(ans)


T = int(input())
for t in range(T):
	(h, m) = map(int, input().split())
	print(60 - m + 60 * (23 - h))


T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	hrs = 23 - A
	mins = 60 - B
	print(hrs * 60 + mins)


t = int(input())
while t != 0:
	(h, m) = map(int, input().split())
	hr = 24 - h
	if hr == 1:
		ans = 60 - m
		print(ans)
	else:
		minutes = 60 * hr
		ans = minutes - m
		print(ans)
	t = t - 1


import math
testCases = int(input())
for _ in range(testCases):
	(h, m) = [int(x) for x in input().split()]
	print((23 - h) * 60 + (60 - m))


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hl = (23 - h) * 60
	ml = 60 - m
	print(hl + ml)


rounds_remaining = int(input())
while rounds_remaining > 0:
	rounds_remaining -= 1
	line = input()
	ints = line.split()
	print((23 - int(ints[0])) * 60 + 60 - int(ints[1]))


t = int(input())
while t:
	(n, m) = map(int, input().split())
	print(24 * 60 - n * 60 - m)
	t = t - 1


const_time = 1440
cols = int(input())
for time in range(cols):
	(h, m) = map(int, input().split())
	print(const_time - (h * 60 + m))


from collections import defaultdict, Counter
import heapq
import math
import sys
import os
di = {}
arr = []
dd = defaultdict(list)

def solve():
	(h, m) = [int(i) for i in input().split(' ')]
	h = 23 - h
	m = 60 - m
	ans = h * 60 + m
	print(ans)
T = int(input())
for i in range(T):
	solve()


def fun(h, m):
	ans = 0
	if m == 0:
		ans += (24 - h) * 60
	else:
		ans += (23 - h) * 60 + 60 - m
	return ans
t = int(input())
while t:
	(h, m) = map(int, input().split())
	print(fun(h, m))
	t -= 1


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(h, m) = I()
	ans = 0
	ans = 60 - m
	h += 1
	h %= 24
	ans += (24 - h) % 24 * 60
	print(ans)


case_num = int(input())
i = 1
while i <= case_num:
	hour_min = list(map(int, input().split()))
	print((23 - hour_min[0]) * 60 + 60 - hour_min[1])
	i += 1


t = int(input())
i = int(0)
f = []
for i in range(0, t):
	f.append(input().split())
for i in range(0, t):
	h = int(f[i][0])
	m = int(f[i][1])
	print((23 - h) * 60 + 60 - m)


tc = int(input())
for tcase in range(tc):
	(h, m) = map(int, input().split())
	total = h * 60 + m
	ans = 24 * 60 - total
	print(ans)


t = int(input())
for i in range(t):
	v = [int(x) for x in input().split(' ')]
	h = v[0]
	m = v[1]
	result = 1440 - h * 60 - m
	print(result)


def minutes_to_new_year(hour, minute):
	minutes_to_full_hour = 60 - minute
	hour += 1
	return (24 - hour) * 60 + minutes_to_full_hour
tests_number = int(input())
for _ in range(tests_number):
	(hour, minute) = map(int, input().split())
	result = minutes_to_new_year(hour, minute)
	print(result)


import time
LOCAL = False
start_time = None
if LOCAL:
	start_time = time.time()
t = int(input())
while t > 0:
	t -= 1
	(h, m) = list(map(lambda x: int(x), input().split(' ')))
	print((24 - h) * 60 - m)
if LOCAL:
	print('--- %s seconds ---' % (time.time() - start_time))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	print(60 - m + (23 - n) * 60)


x = int(input())
lst = []
for i in range(0, x):
	(x, y) = map(int, input().split())
	c = 24 - x - 1
	d = 60 - y
	lst.append(c * 60 + d)
print(*lst, sep='\n')


def solve():
	(h, m) = map(int, input().split())
	ans = (23 - h) * 60 + 60 - m
	print(ans)
t = int(input())
for _ in range(t):
	solve()


def gao():
	(h, m) = map(int, input().split())
	print(24 * 60 - h * 60 - m)
n = input()
for i in range(int(n)):
	gao()


t = int(input())
lst = list()
for i in range(t):
	data = input().split()
	h = int(data[0])
	m = int(data[1])
	time_passed = h * 60 + m
	rem = 1440 - time_passed
	lst.append(rem)
for k in lst:
	print(k)


t = int(input())
arr = []
for _ in range(t):
	arr.append(list(map(int, input().strip().split())))
for idx in range(t):
	[h, m] = arr[idx]
	print(60 * (23 - h) + (60 - m))


t = int(input())
for test in range(t):
	total = 1440
	(hh, mm) = map(int, input().split())
	time_spent = hh * 60 + mm
	print(total - time_spent)


t = int(input())
times = [tuple((int(i) for i in input().split())) for time in range(t)]
for (h, m) in times:
	a = 60 * (24 - h - 1) + (60 - m)
	print(a)


def solve():
	(h, m) = map(int, input().split())
	hh = (24 - h - 1) * 60 + (60 - m)
	print(hh)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
l = []
for i in range(t):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	ans = 60 * (23 - a) + (60 - b)
	l.append(ans)
for i in range(t):
	print(l[i])


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	if n == 0 and m == 0:
		print(0)
	else:
		print(24 * 60 - (n * 60 + m))


for i in range(int(input())):
	(h, m) = [int(x) for x in input().split()]
	p = int(23 - h) * 60
	q = 60 - m
	print(p + q)


nabori = int(input())
for nabor in range(nabori):
	(h, m) = map(int, input().split(' '))
	print((23 - h) * 60 + (60 - m))


t = int(input())
for i in range(0, t):
	(a, b) = input().split()
	(hh, mm) = (int(a), int(b))
	tot_min = (23 - hh) * 60 + (60 - mm)
	print(tot_min)


for t in range(0, int(input())):
	(a, b) = map(int, input().split())
	tm = 24 * 60
	tl = a * 60 + b
	print(tm - tl)


a = int(input())
i = 0
while i < a:
	b = input().split(' ')
	g = int(b[0])
	f = int(b[1])
	c = g * 60 + f
	print(1440 - c)
	i = i + 1


from sys import stdin
input = stdin.readline
t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print(0)
	else:
		print(24 * 60 - (a * 60 + b))


n = int(input())
m = []
for i in range(n):
	(hh, mm) = map(int, input().split())
	x = (23 - hh) * 60
	y = x + (60 - mm)
	m.append(y)
	x = 0
	y = 0
for i in range(n):
	print(m[i])


t = int(input())
for _ in range(t):
	(h, m) = (int(i) for i in input().split())
	ans = 0
	if m > 0:
		h += 1
	ans = ans + (24 - h) * 60
	if m != 0:
		ans += 60 - m
	print(ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	m = (24 - a) * 60
	m -= b
	print(m)


import math
import collections
import functools
import sys
input = sys.stdin.read
readInts = lambda : list(map(int, input().split()))

def readChar():
	c = input(1)
	while c == '\n' or c == '\r' or c == ' ':
		c = input(1)
	return c

def readStr():
	c = input(1)
	while c == '\n' or c == '\r' or c == ' ':
		c = input(1)
	s = str()
	while c != '\n' and c != '\r' and (c != ' '):
		s += c
		c = input(1)
	return s

def readInt():
	c = input(1)
	while c != '-' and (not c.isdigit()):
		c = input(1)
	d: int = -1
	x: int = 0
	if c.isdigit():
		d = 1
	else:
		c = input(1)
	while c.isdigit():
		x = x * 10 + ord(c) - ord('0')
		c = input(1)
	return d * x

def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
eps = 10 ** (-9)
inf = 10 ** 18
mod = 10 ** 9 + 7

def solution():
	a = readInt()
	b = readInt()
	print(24 * 60 - a * 60 - b)
tests = 1
tests = readInt()
while tests > 0:
	solution()
	tests -= 1


it = input('')
for i in range(int(it)):
	exin = input()
	time = exin.split(' ')
	time[0] = int(time[0])
	time[1] = int(time[1])
	totalMin = abs(23 - time[0]) * 60 + abs(time[1] - 60)
	print(totalMin)


n = input()
maxtime = 24 * 60
for i in range(0, int(n)):
	f = input()
	f = f.split(' ')
	print(maxtime - int(f[0]) * 60 - int(f[1]))


cases = int(input())
for _ in range(cases):
	(hours, minutes) = map(int, input().split())
	total_min = hours * 60 + minutes
	ans = 24 * 60 - total_min
	print(ans)


import datetime
perma = datetime.datetime(2020, 7, 3)
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	now = datetime.datetime(2020, 7, 2, hour=h, minute=m)
	x = perma - now
	print(int(x.total_seconds() // 60))


t = int(input())
lst = []
for i in range(t):
	d = input()
	d = d.split(' ')
	d = [int(x) for x in d]
	lst.append(d)
for i in lst:
	m = (23 - i[0]) * 60 + 60 - i[1]
	print(m)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline

def factors(n):
	return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(h, m) = li()
	tot = 60 - m
	tot += (24 - (h + 1)) * 60
	print(tot)


n = int(input())
list_ = []
for i in range(n):
	(x, y) = map(int, input().split())
	list_.append([x, y])
k = len(list_)
while k > 0:
	for j in list_:
		hour_ = j[0] * 60
		minutes_ = j[1]
		total_ = hour_ + minutes_
		remain = 1440 - total_
		k = k - 1
		print(remain)


from datetime import timedelta

def driver(h, m):
	t1 = timedelta(hours=24, minutes=0)
	t2 = timedelta(hours=h, minutes=m)
	t3 = t1 - t2
	t3 = str(t3)
	t3 = t3.split(':')
	hours = int(t3[0])
	minutes = int(t3[1])
	print(minutes + hours * 60)

def main():
	for i in range(int(input())):
		f = [int(x) for x in input().split()]
		driver(f[0], f[1])
main()


for _ in range(int(input())):
	(hr, minu) = map(int, input().split())
	print(1440 - (hr * 60 + minu))


import math
for i in range(int(input())):
	(h, m) = map(int, input().split())
	h = 23 - h
	m = 60 - m
	print(h * 60 + m)


num = int(input())
for i in range(num):
	(h, m) = [int(x) for x in input().split()]
	answer = (23 - h) * 60 + (60 - m)
	print(answer)


n = int(input())
l = []
for i in range(n):
	(h, m) = map(int, input().split())
	mn = (23 - h) * 60 + (60 - m)
	l.append(mn)
print(*l, sep='\n')


cases = int(input())
for case in range(cases):
	arr = [int(num) for num in input().split()]
	print(1440 - 60 * arr[0] - arr[1])


for i in range(int(input())):
	(h, m) = map(int, input().split())
	(th, tm) = (24, 60)
	max_time = 24 * 60
	given = h * 60 + m
	minutes = max_time - given
	print(minutes)


x = int(input())
for _ in range(x):
	(a, s) = map(int, input().split())
	print(abs(1440 - (a * 60 + s)))


t = int(input())
for i in range(t):
	L = list(map(int, input().split()))
	MinutesR = 0
	HoursMinutes = (24 - L[0]) * 60
	MinutesR = HoursMinutes - L[1]
	print(MinutesR)


t = int(input())
inp = []
for i in range(t):
	(hours, minutes) = map(int, input().split())
	answer = (24 - hours) * 60 - minutes
	inp.append(answer)
for i in inp:
	print(i)


t = int(input())
for _ in range(t):
	(h, m) = [int(_) for _ in input().split(' ')]
	h = 23 - h
	m = 60 - m
	if m == 60:
		h += 1
		m = 0
	print(str(60 * h + m))


def cal(a, b):
	a = 1440 - (a * 60 + b)
	return a
n = int(input())
lis = []
for i in range(n):
	(a, b) = map(int, input().split())
	lis.append(cal(a, b))
for i in lis:
	print(i)


import sys, math, bisect
from heapq import *
inf = float('inf')
mod = 10 ** 9 + 7

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def SieveOfEratosthenes(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	total_min = 24 * 60
	min_now = h * 60 + m
	print(total_min - min_now)


Q = int(input())
for q in range(Q):
	(h, m) = [int(x) for x in input().split(' ')]
	print((24 - (h + 1)) * 60 + 60 - m)


f = []
for i in range(int(input())):
	a = [int(i) for i in input().split()]
	f.append(1440 - (a[0] * 60 + a[1]))
print(*f, sep='\n')


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	full_hrs = 24 - h - 1
	minutes = 60 - m
	print(full_hrs * 60 + minutes)


test_cases = int(input())

def calculateMins(hrs, mins):
	mins_left = 60 - mins
	hrs_left = 23 - hrs
	return hrs_left * 60 + mins_left
for i in range(test_cases):
	(hrs, mins) = map(int, input().split(' '))
	print(calculateMins(hrs, mins))


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	min = (24 - a) * 60 - b
	print(min)


def ab():
	b = list(map(int, input().split()))
	e = (23 - b[0]) * 60
	l = 60 - b[1]
	print(e + l)
a = int(input())
for i in range(0, a):
	ab()


T = int(input())
if T <= 1439 and T >= 1:
	for i in range(T):
		ch = input()
		l = len(ch)
		id = ch.index(' ')
		sh = ''
		zh = ''
		for i in range(id + 1):
			sh = sh + ch[i]
			i += 1
		h = int(sh)
		for i in range(id, l - 1):
			i += 1
			zh = zh + ch[i]
		m = int(zh)
		if m != 0:
			H = 23 - h
			M = 60 - m
			S = H * 60 + M
			print(S)
		if m == 0:
			S = 24 - h
			print(S * 60)


import math
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	ans = 0
	if m == 0 and h != 0:
		ans = ans + (24 - h) * 60
	elif m == 0 and h == 0:
		print('0')
		continue
	else:
		ans = ans + (24 - h - 1) * 60 + (60 - m)
	print(ans)


t = int(input())
a = []
for i in range(t):
	(h, m) = map(int, input().split())
	r1 = 24 - h
	if m > 0:
		r1 -= 1
		out = r1 * 60 + (60 - m)
	else:
		out = r1 * 60
	a.append(out)
for i in a:
	print(i)


num = int(input())
arr = []
for i in range(num):
	arr.append(input())
arr = [[int(i) for i in c.split(' ')] for c in arr]
for i in range(num):
	print(1440 - 60 * arr[i][0] - arr[i][1])


t = int(input())
for i in range(t):
	k = input().split()
	p = int(k[0])
	r = int(k[1])
	print(24 * 60 - 60 * p - r)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hh = 24 - h
	mm = -m
	print(60 * hh + mm)


n = int(input())
for _ in range(n):
	L = list(map(int, input().split()))
	print((24 - L[0]) * 60 - L[1])


t = int(input())
a = [[int(j) for j in input().split()] for i in range(t)]
for i in range(t):
	print(1440 - (a[i][0] * 60 + a[i][1]))


tests = int(input())

def minutes(h, m):
	return (23 - h) * 60 + (60 - m)
for i in range(0, tests):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	print(minutes(a, b))


t = int(input())
ans = []
for i in range(t):
	(h, m) = map(int, input().split())
	mins = 24 * 60
	x = mins - h * 60 - m
	ans.append(x)
for e in ans:
	print(e)


x = int(input())
for i in range(x):
	y = str(input()).split(' ')
	if int(y[0]) == 23:
		z = 60 - int(y[1])
	else:
		z = (23 - int(y[0])) * 60 + 60 - int(y[1])
	print(z)


from fractions import gcd
from heapq import *
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
MOD = 10 ** 9 + 7

def main():
	t = int(input())
	for i in range(t):
		(h, m) = map(int, input().split())
		print((23 - h) * 60 + (60 - m))
main()


count = int(input())
while count > 0:
	case = input()
	test = case.split(' ')
	hh = int(test[0])
	mm = int(test[1])
	remaining_hrs = 23 - hh
	remaining_minutes = 60 - mm
	remaining_time = remaining_hrs * 60 + remaining_minutes
	print(remaining_time)
	count -= 1


t = int(input())
ansLst = []
for tt in range(t):
	(h, m) = input().split(' ')
	(h, m) = (int(h), int(m))
	h_left = 23 - h
	m_left = 60 - m
	ans = h_left * 60 + m_left
	ansLst.append(ans)
for i in ansLst:
	print(i)


def newyear(h, m):
	print((23 - h) * 60 + (60 - m))
for t in range(int(input())):
	l = list(map(int, input().split()))
	(h, m) = (l[0], l[1])
	newyear(h, m)


import sys

def line():
	return sys.stdin.readline()
t = int(line())
for i in range(t):
	lineRead = line().split(' ')
	h = int(lineRead[0])
	m = int(lineRead[1])
	timeUntil = (24 - h) * 60
	timeUntil = timeUntil - m
	print(timeUntil)


import sys
N = int(sys.stdin.readline())
for i in range(N):
	(a, b) = map(int, sys.stdin.readline().split())
	print((23 - a) * 60 + 60 - b)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	var = 60 - K
	print((23 - N) * 60 + var)


t = int(input())
sres = []
for i in range(t):
	s = 0
	(h, m) = map(int, input().split())
	h = 23 - h
	s += h * 60
	s += abs(m - 60)
	sres.append(s)
for i in sres:
	print(i)


qtd = int(input())
for _ in range(qtd):
	(h, m) = map(int, input().split())
	hr = abs(23 - h) * 60
	mr = abs(60 - m)
	print(hr + mr)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	a = h * 60 + m
	b = 24 * 60
	total = b - a
	print(total)


for iter in range(int(input())):
	(hourses, minutes) = list(map(int, input().split()))
	print((23 - hourses) * 60 + 60 - minutes)


T = int(input().strip())
for t in range(T):
	(H, M) = map(int, input().split())
	minutes = (23 - H) * 60 + (60 - M)
	print(minutes)


t = int(input())
out = []
for i in range(t):
	(hr, mn) = map(int, input().strip().split())
	mn_left = 24 * 60 - (hr * 60 + mn)
	out.append(mn_left)
for num in out:
	print(num)


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	if x < 23:
		k = (23 - x) * 60 + (60 - y)
		print(k)
	else:
		print(60 - y)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().strip().split()))
	if a == 0 and b == 0:
		print(0)
	else:
		print((23 - a) * 60 + (60 - b))


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	mins = a[0] * 60 + a[1]
	print(24 * 60 - mins)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().strip().split())
	print(24 * 60 - n * 60 - m)


for i in range(int(input())):
	a = [int(t) for t in input().split(' ')]
	(h, m) = (a[0], a[1])
	t = 0
	if m == 0:
		t = (24 - h) * 60
	else:
		t = (24 - h) * 60 - m
	print(t)


import math

def BuubleSort(h, m):
	min = 0
	min = (23 - h) * 60
	min += 60 - m
	return min

def main():
	t = int(input())
	for _ in range(t):
		(h, m) = map(int, input().split())
		ans = BuubleSort(h, m)
		print(ans)
main()


t = int(input())
for _ in range(t):
	v = list(map(int, input().split()))
	print((23 - v[0]) * 60 + 60 - v[1])


n = int(input())
v = []
for i in range(n):
	(a, b) = map(int, input().split())
	c = a * 60 + b
	j = abs(c)
	d = 24 * 60 - j
	v.append(d)
for i in range(len(v)):
	print(v[i])


for _ in range(int(input())):
	y = list(map(int, input().split()))
	print(1440 - (y[0] * 60 + y[1]))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + (60 - m))


n = int(input())
for i in range(n):
	time = input().split(' ')
	hr = int(time[0])
	mn = int(time[1])
	remains = (24 - hr - 1) * 60 + (60 - mn)
	print(remains)


import sys
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	print((24 - h - 1) * 60 + (60 - m))


n = int(input())
for _ in range(n):
	x = list(map(int, input().split()))
	h = x[0] * 60 + x[1]
	print(1440 - h)


n = int(input())
for i in range(n):
	l1 = [int(i) for i in input().split(' ')]
	t = 24 - l1[0]
	t = t * 60
	t = t - l1[1]
	print(t)
	l1 = []


t = int(input())
while t:
	(h, m) = list(map(int, input().split()))
	hr = 23 - h
	mi = 60 - m
	res = hr * 60 + mi
	print(res)
	t -= 1


t = int(input())
for i in range(t):
	x = input().split()
	h = int(x[0])
	m = int(x[1])
	if m == 0:
		print(60 * (24 - h))
	elif h == 0:
		print(1440 - m)
	else:
		print(60 * (23 - h) + (60 - m))


t = int(input())
L = []
for i in range(t):
	(h, m) = [int(x) for x in input().split()]
	min_rem = 1440 - (h * 60 + m)
	L.append(min_rem)
for i in range(t):
	print(L[i])


exec(int(input()) * 'a,b=map(int,input().split());print(1440-b-a*60);')


a = int(input())
f = []
for i in range(a):
	(h, m) = list(map(int, input().split()))
	f.append((23 - h) * 60 + (60 - m))
for i in f:
	print(i)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	x = 23 - h
	y = 60 - m
	print(x * 60 + y)


N = int(input())
a = []
for i in range(N):
	a.append(list(map(int, input().split())))
for one in a:
	print((23 - one[0]) * 60 + 60 - one[1])


for j in range(int(input())):
	(s, o) = list(map(int, input().split()))
	n = (23 - s) * 60 + (60 - o)
	print(n)


def main():
	for _ in range(int(input())):
		(h, m) = list(map(int, input().split()))
		print((23 - h) * 60 + 60 - m)
main()


for i in range(int(input())):
	(hour, minutes) = map(int, input().split())
	(rem_hour, rem_minutes) = (23 - hour, 60 - minutes)
	print(rem_hour * 60 + rem_minutes)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	r = 24 - h
	tm = r * 60
	print(tm - m)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hn = h * 60
	d = 24 * 60 - (hn + m)
	print(d)


import math
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	ans = 0
	h1 = 23 - h
	m1 = 60 - m
	print(60 * h1 + m1)


t = int(input())
for query in range(t):
	time = input().split()
	minutes = 60 - int(time[1])
	hours = 23 - int(time[0])
	print(60 * hours + minutes)


for t in range(int(input())):
	(h, m) = map(int, input().split())
	d = (23 - h) * 60
	e = 60 - m
	print(d + e)


t = int(input())
while t:
	t -= 1
	a = [int(i) for i in input().split()]
	h = a[0]
	m = a[1]
	l = 24 * 60 - h * 60 - m
	print(str(l) + '\n')


t = int(input())
for _ in range(0, t):
	(h, m) = input().split()
	res = 24 * 60 - (int(h) * 60 + int(m))
	print(res)


t = int(input())
for x in range(t):
	(h, m) = map(int, input().split())
	eq = h * 60 + m
	print(1440 - eq)


k = int(input())
for i in range(k):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	m = 1440 - a * 60 - b
	print(m)


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	k = 1440
	d = n * 60
	print(k - d - m)


n = int(input())
for a in range(n):
	time = input().split()
	hours = int(time[0])
	mins = int(time[1])
	total = 0
	total += (23 - hours) * 60
	total += 60 - mins
	print(total)


a = int(input())
for i in range(0, a):
	b = list(map(int, input().split()))
	c = 0
	if b[1] == 0:
		c = c + (24 - b[0]) * 60
	if b[1] > 0:
		c = c + (60 - b[1])
		c = c + (23 - b[0]) * 60
	print(c)


for i in [0] * int(input()):
	(h, m) = map(int, input().split())
	print((24 - h) * 60 - m)


a = int(input())
for x in range(a):
	b = list(map(int, input().split()))
	c = 24 - b[0]
	d = 60 - b[1]
	print(c * 60 - b[1])


n = int(input())
min_left = 0
for i in range(n):
	(h, m) = map(int, input().split())
	if h == 23:
		min_left = 60 - m
	else:
		min_left = 60 - m + (23 - h) * 60
	print(min_left)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
T = int(input())
while T:
	(h, m) = get_ints()
	ans = (23 - h) * 60 + (60 - m)
	print(ans)
	T -= 1


def new_year(hours, minutes):
	x = hours * 60 + minutes
	return 1440 - x
for _ in range(int(input())):
	(h, m) = [int(i) for i in input().split()]
	print(new_year(h, m))


testcase = int(input())
while testcase != 0:
	line = input().split()
	hour = int(line[0])
	minute = int(line[1])
	total = hour * 60 + minute
	minutes_left = 24 * 60 - total
	print(minutes_left)
	testcase -= 1


def inp(n):
	if n == 1:
		return map(int, stdin.readline().split())
	elif n == 2:
		return map(float, stdin.readline().split())
	else:
		return map(str, stdin.readline().split())
from sys import *
for i in range(int(input())):
	(h, m) = inp(1)
	print((24 - h) * 60 - m)


t = int(input())
for ii in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = 0
	if n == 0 and m == 0:
		print(0)
		continue
	if m > 0:
		s = 60 - m
		n += 1
	if n == 24:
		print(s)
	else:
		print((24 - n) * 60 + s)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = (23 - n) * 60
	t += 60 - m
	print(t)


t = int(input())
for i in range(t):
	a = list(map(int, input().strip().split()))[:2]
	h = a[0]
	m = a[1]
	temp = 24 * 60 - (h * 60 + m)
	print(temp)


t = int(input())
for zz in range(t):
	(k, m) = map(int, input().split())
	res = 24 * 60 - 60 * k - m
	print(res)


def main():
	(a, b) = list(map(int, input().split()))
	print(24 * 60 - a * 60 - b)
c = int(input())
for i in range(c):
	main()


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	ho = 24 - h - 1
	mi = 60 - m
	res = ho * 60 + mi
	print(res)


def PrintAns(h, m):
	print(60 * (23 - h) + 60 - m)
n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	PrintAns(h, m)


s = int(input())
for i in range(s):
	(hh, mm) = list(map(int, input().split()))
	ms = hh * 60 + mm
	print(24 * 60 - ms)


t = int(input())
for i in range(t):
	(h, m) = [int(i) for i in input().split()]
	pres = h * 3600 + m * 60
	final = 86400
	ext = final - pres
	print(ext // 60)


n = int(input())
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	k = a * 60 + b
	print(24 * 60 - k)


def sol(h, m):
	return 24 * 60 - h * 60 - m

def main():
	(t,) = [int(x) for x in input().split()]
	for _ in range(t):
		(h, m) = [int(x) for x in input().split()]
		print(sol(h, m))
main()


n = int(input())
i = 0
a = []
while i < n:
	(p, q) = input().split()
	p = int(p)
	q = int(q)
	a.append((23 - p) * 60 + (60 - q))
	i += 1
for i in a:
	print(i)


t = int(input())
s = []
for i in range(t):
	(h, m) = map(int, input().split())
	min = h * 60 + m
	s.append(1440 - min)
for i in s:
	print(i)


import datetime as dt
n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	delta = dt.datetime(2020, 1, 1, 0, 0) - dt.datetime(2019, 12, 31, h, m)
	print(delta.seconds // 60)


def solve():
	t = int(input())
	for _ in range(t):
		s = input()
		(h, m) = map(int, s.split())
		ans = (24 - h) * 60 - m
		print(ans)
solve()


T = int(input())
for t in range(T):
	(h, m) = map(int, input().split())
	a = h * 60 + m
	x = 1440 - a
	print(x)


import sys, os, io
from sys import stdin
import math
from collections import defaultdict
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	(h, m) = li()
	ans = 0
	while h != 0 or m != 0:
		ans += 1
		m += 1
		if m == 60:
			m = 0
			h += 1
			h %= 24
	print(ans)
t = 1
t = ii()
for _ in range(t):
	solve()


def solve():
	(x, y) = input().split()
	h = int(x)
	m = int(y)
	mid = 24 * 60
	pre = h * 60 + m
	print(int(mid - pre))
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
while t > 0:
	(h, m) = [int(i) for i in input().split()]
	print((24 - h) * 60 - m)
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	(h, w) = list(map(int, input().split()))
	print(24 * 60 - h * 60 - w)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	if m == 0:
		hh = (24 - h) * 60
		print(hh)
	else:
		hh = (23 - h) * 60
		print(hh + (60 - m))


n = int(input())
l = []
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if b > 0:
		m = 60 - b
		h = (24 - a - 1) * 60
	else:
		m = 0
		h = (24 - a) * 60
	l.append(h + m)
for i in l:
	print(i)


import bisect
from sys import stdin, stdout
t = int(input())
for i in range(t):
	(h, m) = list(map(int, input().split()))
	hleft = 23 - h
	mleft = 60 - m
	print(hleft * 60 + mleft)


line = int(input())
for i in range(line):
	mylist = list(map(int, input().split()))
	print(1440 - (60 * mylist[0] + mylist[1]))


t = int(input())
for _ in range(t):
	(h, m) = list(map(int, input().split()))
	min = h * 60 + m
	tot = 24 * 60
	r = tot - min
	print(r)


T = int(input())
answer = ''
for t in range(T):
	(a, b) = list(map(int, input().split(' ')))
	h = 23 - a
	m = 60 - b
	result = m + h * 60
	answer += str(result) + '\n'
print(answer)


n = int(input())
sum = 0
for i in range(n):
	(h, m) = map(int, input().split())
	sum = h * 60 + m
	sum = 1440 - sum
	print(sum)
	print('\n')
	sum = 0


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return ll[mid]
		elif ll[mid] < val:
			ans = ll[mid]
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split(' '))
	print((23 - a) * 60 + (60 - b))


t = int(input())
for _ in range(0, t):
	x = list(map(int, input().split()))
	print(1440 - x[0] * 60 - x[1])


no_tests = int(input())
ans = []
while no_tests > 0:
	time = list(map(int, input().split()))
	hrs = int(time[0])
	mins = int(time[1])
	hrs_ret = 23 - hrs
	mins_ret = 60 - mins
	mins_ret += 60 * hrs_ret
	ans.append(mins_ret)
	no_tests -= 1
for i in ans:
	print(i)


t = int(input())
mat = []
if 1 <= t <= 1439:
	for i in range(t):
		(h, m) = map(int, input().split())
		if 0 <= h < 24 and 0 <= m < 60:
			minutes = 1440 - h * 60 - m
			mat.append(minutes)
for this in range(len(mat)):
	print(mat[this])


test = int(input())
vet = []
for x in range(test):
	(h, m) = input().split(' ')
	h = int(h)
	m = int(m)
	vet.append(60 * (23 - h) + (60 - m))
for x in vet:
	print(x)


t = int(input())
for count in range(t):
	(h, m) = map(int, input().split())
	n = 60 - m + 60 * (23 - h)
	print(n)


from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	print((24 - n - 1) * 60 + (60 - m))


q = int(input())
for x in range(q):
	(h, m) = map(int, input().split())
	print(24 * 60 - (h * 60 + m))


a = input()
for i in range(int(a)):
	b = input()
	q = b.split(' ')
	h = int(q[0])
	m = int(q[1])
	mins = (24 - h) * 60 + (60 - m) - 60
	print(mins)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	ans = 1440 - (h * 60 + m)
	print(str(ans))


import math
import sys
import re
n = int(input())
for y in range(n):
	l = list(map(int, input().rstrip().split()))
	a = l[0] + l[1] / 60
	b = 24 - a
	print(round(b * 60))


for i in range(int(input())):
	(hours, mins) = map(int, input().split(' '))
	print((23 - hours) * 60 + (60 - mins))


t = int(input())
lis1 = []
for i in range(0, t):
	a = input().split()
	h = int(a[0])
	m = int(a[1])
	b = 23 - h
	c = 60 - m
	ans = b * 60 + c
	lis1.append(ans)
for a in range(len(lis1)):
	print(lis1[a])


t = int(input())
for _ in range(t):
	a = input().split()
	h = int(a[0])
	m = int(a[1])
	hmax = 24
	remh = hmax - h
	ans = remh * 60 - m
	print(ans)


for i in range(int(input())):
	(h, m) = [int(num) for num in input().split()]
	print(1440 - h * 60 - m)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split(' '))
	minutes = 0
	print((23 - h) * 60 + (60 - m))


n = input()
result = []
inputm = None
for i in range(0, int(n)):
	inputm = input().split()
	h = int(inputm[0]) * 60
	d = int(inputm[1])
	rr = 1440 - h - d
	result.append(rr)
for i in range(0, int(n)):
	print(result[i])


def calc(str):
	(h, m) = map(int, str.split())
	return 60 * 24 - (h * 60 + m)
n = int(input())
test_cases = []
for _ in range(n):
	test_cases.append(input())
for case in test_cases:
	print(calc(case))


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	ans = 60 - m
	hrs = 23 - h
	ans += hrs * 60
	print(ans)


cases = int(input())
returnValue = []
for i in range(cases):
	line = input().split(' ')
	hour = int(line[0])
	minute = int(line[1])
	returnValue.append((23 - hour) * 60 + (60 - minute))
for i in returnValue:
	print(i)


t = int(input())
b = 60 * 24
for c in range(0, t):
	s = [int(i) for i in input().split()]
	a = 60 * s[0] + s[1]
	print(b - a)


for x in range(int(input())):
	a = list(map(int, input().split()))
	hh = a[0]
	mm = a[-1]
	print((23 - hh) * 60 + (60 - mm))


import math
from decimal import Decimal
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(a, b):
	c = []
	ans = 0
	f = int(math.sqrt(a))
	for i in range(1, f + 1):
		if a % i == 0:
			c.append(i)
	l = len(c)
	for i in range(l):
		c.append(a // c[i])
	for i in range(len(c)):
		if c[i] <= b:
			ans += 1
	if a / f == f and b >= f:
		return ans - 1
	return ans
import math
from decimal import Decimal
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(a, b):
	c = []
	ans = 0
	f = int(math.sqrt(a))
	for i in range(1, f + 1):
		if a % i == 0:
			c.append(i)
	l = len(c)
	for i in range(l):
		c.append(a // c[i])
	for i in range(len(c)):
		if c[i] <= b:
			ans += 1
	if a / f == f and b >= f:
		return ans - 1
	return ans
for i in range(int(input())):
	(j, m) = map(int, input().split())
	print(60 * 24 - j * 60 - m)


t = int(input())
for i in range(t):
	(hours, minutes) = map(int, input().split())
	print((23 - hours) * 60 + (60 - minutes))


import sys, math

def ii():
	return int(input())

def mii():
	return map(int, input().split())

def lmii():
	return list(mii())

def main():
	for _ in range(ii()):
		(a, b) = mii()
		a = 23 - a
		b = 60 - b
		print(a * 60 + b)
main()


import sys
T = int(sys.stdin.readline().strip())
for _ in range(T):
	(H, M) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	print(60 - M + (23 - H) * 60)


a = int(input())
for _ in range(a):
	(s, d) = map(int, input().split())
	s = s * 60
	print(24 * 60 - (s + d))


for ii in range(int(input())):
	b = [int(j) for j in input().split()]
	h = b[0]
	m = b[1]
	print((23 - h) * 60 + (60 - m))


t = int(input())
for i in range(t):
	l = input()
	(n, m) = l.split(' ')
	h = (23 - int(n)) * 60 + (60 - int(m))
	print(h)
	l = []


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	mi = a * 60 + b
	to = 24 * 60
	print(to - mi)


t = int(input())
l2 = []
for i1 in range(t):
	(h, m) = map(int, input().split())
	if h == 0 and m == 0:
		c = 0
	else:
		c = (23 - h) * 60 + (60 - m)
	l2.append(c)
for i in range(t):
	print(l2[i])


t = int(input())
for _ in range(t):
	(h, m) = [int(x) for x in input().split()]
	ans = (23 - h) * 60 + (60 - m)
	if h == 0 and m == 0:
		ans = 60
	print(ans)


p = 1440
t = int(input())
for _ in range(t):
	(h, s) = map(int, input().split())
	h = h * 60
	sum = h + s
	print(p - sum)


res = []
for _ in range(int(input())):
	(h, m) = [int(i) for i in input().split()]
	minutes = 60 * (24 - h) - m
	res.append(minutes)
for r in res:
	print(r)


n = int(input())
for i in range(n):
	(h, w) = map(int, input().split())
	h = abs(24 - h - 1)
	w = 60 - w
	print(60 * h + w)


import sys
import math

def alele():
	return list(map(int, sys.stdin.readline().strip().split()))

def ilele():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(A, B) = ilele()
	if A == 0 and B == 0:
		print(0)
	else:
		print((24 - (A + 1)) * 60 + (60 - B))


t = int(input())
for z in range(t):
	(h, m) = map(int, input().split())
	print(1440 - h * 60 - m)


def main():
	t = int(input())
	for _ in range(t):
		(h, m) = [int(x) for x in input().strip().split(' ')]
		remaining_mins = solve(h, m)
		print(remaining_mins)

def solve(h, m):
	return (23 - h) * 60 + (60 - m)
main()


x = int(input())
for i in range(0, x, 1):
	(h, s) = map(int, input().split())
	min = (24 - (h + 1)) * 60 + (60 - s)
	print(min)


n = int(input())
meianoite = 24 * 60
for i in range(n):
	x = str(input()).split(' ')
	h = int(x[0]) * 60
	m = int(x[1])
	total = h + m
	valor = meianoite - total
	print(valor)


a = int(input())
b = []
for i in range(a):
	(k, l) = map(int, input().split())
	r = (24 - k) * 60 - l
	b.append(r)
for i in range(a):
	print(b[i])


a = int(input())
for i in range(a):
	b = input().split()
	c = int(b[0]) * 60 + int(b[1])
	print(1440 - c)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	if m == 0:
		print((24 - h) * 60)
		continue
	x = (24 - h - 1) * 60 + 60 - m
	print(x)


def main():
	t = int(input())
	for _ in range(t):
		(m, s) = map(int, input().split())
		ans = (23 - m) * 60 + 60 - s
		print(ans)
main()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(h, m) = MAP()
	total = 24 * 60
	ans = total - h * 60 - m
	print(ans)


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	a = L[0]
	b = L[1]
	print(24 * 60 - (a * 60 + b))


s = []
n = int(input())
for j in range(n):
	s.append([int(i) for i in input().split(' ')])
for j in range(n):
	print(24 * 60 - s[j][0] * 60 - s[j][1])


repeticiones = int(input())
horas = []
minutos = []
hour = 0
minute = 0
midnight = 60 * 24
tiempo_restante = 0
for i in range(repeticiones):
	(hour, minute) = input().split()
	horas.append(int(hour))
	minutos.append(int(minute))
for j in range(repeticiones):
	tiempo_restante = midnight - (horas[j] * 60 + minutos[j])
	print(tiempo_restante)


t = int(input())
while t:
	t -= 1
	(h, m) = map(int, input().split())
	s = 0
	reh = max(0, 23 - h)
	s += 60 - m
	s += 60 * reh
	print(s)


n = int(input())
for i in range(n):
	time = list(map(int, input().split()))
	h = time[0]
	m = time[1]
	res = (24 - h) * 60 + (0 - m)
	print(res)


t = int(input())
while t > 0:
	lst = list(map(int, input().split()))
	print(60 * (23 - lst[0]) + (60 - lst[1]))
	t = t - 1


t = int(input())
for _ in range(t):
	(hr, mnt) = map(int, input().split())
	time_left = (23 - hr) * 60 + (60 - mnt)
	print(time_left)


T = int(input())
for i in range(T):
	(h, m) = list(map(int, input().split()))
	mi = (24 - h) * 60 - m
	print(mi)


from math import sqrt, gcd, ceil
from collections import deque

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
t = ii()
while t:
	t -= 1
	(y, m) = mi()
	if m >= 0:
		y += 1
	s = (24 - y) * 60
	s += 60 - m
	print(s)


num = int(input())
case = []
minutes_1 = []
minutes_2 = []
for i in range(num):
	(hh, mm) = input().split()
	case.append((int(hh), int(mm)))
	minutes_1.append((24 - case[i][0], 60 - case[i][1]))
	minutes_2.append(60 * minutes_1[i][0] + minutes_1[i][1] - 60)
for i in range(num):
	print(minutes_2[i])


t = int(input())
for q in range(t):
	(h, m) = map(int, input().split())
	ans = 0
	if m != 0:
		ans += (24 - h - 1) * 60
		ans += 60 - m
	else:
		ans += (24 - h) * 60
	print(ans)


exec(int(input()) * 'h,m=map(int,input().split());print((23-h)*60+(60-m));')


num = int(input())
while num != 0:
	time = input()
	array = time.split(' ')
	print(1440 - int(array[0]) * 60 - int(array[1]))
	num -= 1


i = int(input())
minuts = []
for i in range(i):
	(h, m) = [int(i) for i in input().split()]
	minuts.append((24 - h - 1) * 60 + 60 - m)
for elem in minuts:
	print(elem)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	P = x * 60 + y
	print(24 * 60 - P)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	a = 60 - m
	a2 = 24 - h
	a3 = a2 * 60 + a - 60
	print(a3)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	ans = 0
	while h < 23:
		ans = ans + 60
		h = h + 1
	ans = ans + (60 - m)
	print(ans)


local = False
if local:
	file = open('A.txt', 'r')

def IN():
	if local:
		return file.readline()
	else:
		return input()

def solve(hh, mm):
	mmdiff = 60 - mm
	hhdiff = 23 - hh
	return mmdiff + hhdiff * 60
t = int(IN())
for i in range(t):
	(hh, mm) = [int(n) for n in IN().split()]
	print(solve(hh, mm))


T = int(input())
for kase in range(T):
	(h, m) = [int(x) for x in input().split()]
	print(1440 - h * 60 - m)


for i in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	mn = x * 60 + y
	m1 = 24 * 60
	print(m1 - mn)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	hours = 24 - a
	minutes = 0
	if b != 0:
		hours -= 1
	else:
		minutes -= 60
	minutes += 60 - b + 60 * hours
	print(minutes)


import sys
n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	count = 0
	count += (23 - h) * 60
	count += 60 - m
	print(count)


t = input()
for i in range(0, int(t)):
	inp = input()
	mint = inp.split()
	if mint[0] != 0 and mint[1] != 0:
		minutes = (23 - int(mint[0])) * 60 + (60 - int(mint[1]))
		print(minutes)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	if h == 0 and m == 0:
		print(0)
	else:
		print(60 * (24 - h) - m)


t = int(input())
rem = 0
for i in range(t):
	rem = 0
	(h, m) = input().split(' ')
	rem += 60 - int(m)
	rem += (23 - int(h)) * 60
	print(str(rem))


t = int(input())
for i in range(t):
	total_min = 0
	(hour, min) = list(map(int, input().split()))
	total_min = 60 - min
	hour += 1
	while hour < 24:
		total_min += 60
		hour += 1
	print(total_min)


n = int(input())
count = 0
t = []
while count < n:
	s = input()
	s = s.split(' ')
	t.append(s)
	count += 1
for x in t:
	ans = int(x[-1])
	rh = 24 - int(x[0])
	ans = rh * 60 - ans
	print(ans)


n = int(input())
for _ in range(n):
	(hrs, mts) = map(int, input().split(' '))
	print(1440 - 60 * hrs - mts)


for _ in range(int(input())):
	x = 24 * 60
	(y, z) = map(int, input().split())
	y *= 60
	print(x - (y + z))


def task():
	f = input().split()
	k = int(f[0]) * 60
	p = k + int(f[1])
	ans = 24 * 60 - p
	print(ans)
t = int(input())
while t > 0:
	task()
	t -= 1


from sys import stdin
A = int(stdin.readline())
for k in range(0, A):
	B = list(map(int, stdin.readline().split()))
	print((24 - B[0] - 1) * 60 + 60 - B[1])


try:
	t = int(input())
	i = 0
	while i < t:
		(a, b) = list(map(int, input().split()))
		c = a * 60 + b
		print(1440 - c)
		i += 1
except:
	pass


n = int(input())
Min = []
for i in range(n):
	(h, m) = map(int, input().split())
	Min.append((23 - h) * 60 + 60 - m)
for i in Min:
	print(i)


from datetime import timedelta

def ans(h, m):
	delta1 = timedelta(hours=h, minutes=m)
	delta2 = timedelta(hours=24)
	d = delta2 - delta1
	return d.seconds / 60
t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	print(int(ans(l[0], l[1])))


def time(h, m):
	return (24 - h) * 60 - m

def io():
	T = int(input())
	for i in range(T):
		(h, m) = map(int, input().split())
		print(time(h, m))
io()


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	print((23 - l[0]) * 60 + (60 - l[1]))


import math
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	ans = 60 - m + (23 - h) * 60
	print(ans)


count = int(input())
for i in range(count):
	(a, b) = [int(elem) for elem in input().split()]
	print(24 * 60 - a * 60 - b)


a = int(input())
result = ''
print
for i in range(a):
	s = input()
	(hour, minu) = (int(s.split(' ')[0]), int(s.split(' ')[1]))
	result += f'{(24 - hour) * 60 - minu}\n'
print(result)


def pklk(h, m):
	if m != 0:
		m1 = 60 - m
		h1 = (24 - h - 1) * 60
		print(h1 + m1)
	if m == 0:
		print((24 - h) * 60)
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	pklk(h, m)


casos = input()
for i in range(int(casos)):
	(h, m) = [int(x) for x in input().split(' ')]
	rta = (23 - h) * 60 + (60 - m)
	print(rta)


t = int(input())
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	m = a * 60 + b
	print(1440 - m)


n = int(input())
e = []
for i in range(n):
	(y, k) = map(int, input().split())
	new = (24 - y) * 60 - k
	e.append(new)
for i in range(len(e)):
	print(e[i])


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	(n, m) = map(int, input().split())
	print((24 - n) * 60 - m)
	t -= 1


final = []
n = int(input())
for i in range(0, n):
	(h, m) = input().split()
	(h, m) = (int(h), int(m))
	r = h * 60 + m
	final.append(1440 - r)
for i in final:
	print(i)


t = int(input())
x = 24 * 60
for i in range(t):
	(h, m) = list(map(int, input().split()))
	h *= 60
	ans = x - (h + m)
	print(ans)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	(newh, newm) = (24, 0)
	h = newh - h
	m = newm - m
	print(h * 60 + m)


t = int(input())
for _ in range(t):
	args = [int(x) for x in input().split(' ')]
	h = 24 - args[0] - 1
	m = 60 - args[1]
	print(str(h * 60 + m))


cc = int(input())
for i in range(0, cc):
	(h, m) = map(int, input().split(' '))
	m = m + h * 60
	print(1440 - m)


n = int(input())
for i in range(n):
	l = input().split()
	a = int(l[0]) * 60 + int(l[1])
	b = 1440 - int(a)
	print(b)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	k = 23 - n
	l = 60 - m
	p = 60 * k
	print(p + l)


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import sys
sys.setrecursionlimit(10000000)
mod = 998244353

def readInts():
	return list(map(int, input().split()))

def I():
	return int(input())
for _ in range(I()):
	(h, m) = readInts()
	print((23 - h) * 60 + (60 - m))


a = int(input())
l = []
for i in range(0, a):
	j = 0
	b = input()
	while b[j] != ' ':
		j += 1
	if j == 1:
		if len(b) == 4:
			c = int(b[2] + b[3])
			d = int(b[0])
			r = (23 - d) * 60 + (60 - c)
			l.append(r)
		else:
			c = int(b[2])
			d = int(b[0])
			r = (23 - d) * 60 + (60 - c)
			l.append(r)
	elif len(b) == 5:
		c = int(b[3] + b[4])
		d = int(b[0] + b[1])
		r = (23 - d) * 60 + (60 - c)
		l.append(r)
	else:
		c = int(b[3])
		d = int(b[0] + b[1])
		r = (23 - d) * 60 + (60 - c)
		l.append(r)
for i in range(0, a):
	print(l[i])


x = int(input())
n = [0] * x
count = 0
for i in range(x):
	(h, m) = map(int, input().split())
	count = (23 - h) * 60 + (60 - m)
	n[i] = count
	count = 0
for i in n:
	print(i)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print(0)
	else:
		print(24 * 60 - (a * 60 + b))


for _ in range(int(input())):
	(hr, min) = map(int, input().split(' '))
	print((23 - hr) * 60 + (60 - min))


n = int(input())
for i in range(n):
	(h, m) = list(map(int, input().split()))
	a = 24 - h - 1
	b = 60 - m
	print(a * 60 + b)


t = int(input())
while t > 0:
	t -= 1
	s = input().split(' ')
	ans = (24 - int(s[0])) * 60 - int(s[1])
	print(ans)


loop = int(input())
for i in range(loop):
	time = input().split()
	h = int(time[0])
	m = int(time[1])
	print(24 * 60 - (h * 60 + m))


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	summ = h * 60 + m
	total = 24 * 60
	res = total - summ
	print(res)


t = int(input())
a = []
full_day = 24 * 60
for _ in range(t):
	(h, m) = map(int, input().split())
	hour_to_min = h * 60
	sum_of_min_went = hour_to_min + m
	res = full_day - sum_of_min_went
	a.append(res)
print('\n'.join(map(str, a)))


import sys, itertools as it
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	ans = 60 - m
	ans += 60 * (24 - (h + 1))
	print(ans)


f = int(input())
for q in range(f):
	(a, b) = map(int, input().split())
	n = a * 60 + b
	print(1440 - n)


numdetestes = int(input())
i = numdetestes
while i > 0:
	conthoras = str(input()).split(' ')
	contminutos = (23 - int(conthoras[0])) * 60 + 60 - int(conthoras[1])
	i -= 1
	print(contminutos)


t = int(input())
while t > 0:
	t -= 1
	(h, s) = map(int, input().split())
	h = 23 - h
	s = 60 - s
	ans = h * 60 + s
	print(ans)


testcases = int(input())
for _ in range(testcases):
	(n, k) = map(int, input().split())
	ans = (23 - n) * 60 + (60 - k)
	print(ans)


import sys

def solve(T):
	(h, m) = map(int, input().split())
	risposta = 0
	if m == 0:
		return (24 - h) * 60
	else:
		return (23 - h) * 60 + 60 - m
T = int(input())
for t in range(1, T + 1):
	print(solve(T))


t = int(input())
ans = []
for i in range(t):
	(a, b) = map(int, input().split())
	hr = 23 - a
	m = hr * 60 + 60 - b
	ans.append(m)
for item in ans:
	print(item)


qtd = int(input())
for i in range(qtd):
	teste = input()
	(horas, minutos) = teste.split(' ')
	horas = int(horas)
	minutos = int(minutos)
	total = 1440
	resul = total - horas * 60 - minutos
	print(resul)


t = int(input())
for i in range(t):
	(n1, n2) = map(int, input().split())
	ans = (23 - n1) * 60 + (60 - n2)
	print(ans)


tests = int(input())
answer = 0
for i in range(tests):
	(hours, minutes) = list(map(int, input().split()))
	remindingMinutes = 60 - minutes
	remindingHours = 24 - hours - 1
	answer += remindingHours * 60 + remindingMinutes
	print(answer)
	answer = 0


t = int(input())
l = list()
for i in range(t):
	h = input()
	h = h.split()
	s = 60 * (23 - int(h[0])) + (60 - int(h[1]))
	l.append(s)
for i in l:
	print(i)


for testcase in range(int(input())):
	(h, m) = list(map(int, input().split()))
	hours_min = (24 - h - 1) * 60
	mins = 60 - m
	print(hours_min + mins)


t = int(input())
s = 0
e = 0
k = 0
for i in range(t):
	(h, m) = map(int, input().split())
	s = h * 60 + m
	e = 24 * 60
	k = s - e
	print(round(e - s))


n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	if b > 0:
		c = (23 - a) * 60
		d = 60 - b
	else:
		c = (24 - a) * 60
		d = 0
	print(c + d)


elem = int(input())
for x in range(elem):
	ar = []
	for i in input().split(' '):
		ar.append(int(i))
	h = ar[0]
	m = ar[1]
	print((24 - h) * 60 - m)


t = int(input())
for p in range(t):
	(h, m) = map(int, input().split())
	k = 0
	if m == 0:
		k += (24 - h) * 60
	else:
		k += (23 - h) * 60 + 60 - m
	print(k)


n = int(input())
while n:
	(h, m) = map(int, input().split())
	(ans, res, temp) = (0, 0, 0)
	ans = (24 - h) * 60 - m
	print(ans)
	n -= 1


from operator import itemgetter
t = int(input())
while t > 0:
	t = t - 1
	(h, m) = input().strip().split()
	h = int(h)
	m = int(m)
	print((24 - h) * 60 - m)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	k = 1440
	p = h * 60 + m
	print(k - p)


def check(r, g, b):
	(a, b, c) = sorted([r, g, b])
	if c - (a + b) < 2:
		return 'Yes'
	return 'No'
for j in range(int(input())):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + (60 - m))


import math

def shrey():
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	ans = 60 - b + (23 - a) * 60
	print(ans)
T = input()
T = int(T)
for q in range(1, T + 1):
	shrey()


h = int(input())
for i in range(0, h):
	time_list = input().split(' ')
	hours = int(time_list[0])
	minute = int(time_list[1])
	print(1440 - hours * 60 - minute)


a = int(input())
k = [[] for i in range(a)]
for i in range(a):
	(s, t) = map(int, input().split())
	x = 0
	x += 60 * (24 - s - 1) + 60 - t
	k[i].append(x)
for i in k:
	print(*i)


t = int(input())
a = []
for i in range(t):
	(b, c) = map(int, input().split())
	z = (24 - b) * 60
	k = z - c
	print(k)


for _ in range(int(input())):
	(hours, minutes) = (int(num) for num in input().split())
	print(1440 - hours * 60 - minutes)


n = int(input())
for i in range(n):
	(ai, bi) = map(int, input().split())
	x = (23 - ai) * 60
	y = 60 - bi
	print(x + y)


n = int(input())
for i in range(n):
	(h, m) = input().split(' ')
	h = int(h)
	m = int(m)
	h1 = 23
	m1 = 60
	h = h1 - h
	m = m1 - m
	h = h * 60
	m = m + h
	print(m)


from itertools import permutations
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	h1 = 23 - h
	h1 = h1 * 60
	m1 = 60 - m
	print(h1 + m1)


t = int(input(''))
for v in range(t):
	a = input('').split(' ')
	h = int(a[0])
	m = int(a[1])
	ans = (24 - h - 1) * 60 + 60 - m
	print(ans)


for i in range(0, int(input())):
	(n, r) = list(map(int, input().split()))
	print((23 - n) * 60 + (60 - r))


for _ in range(int(input())):
	(hours, minutes) = map(int, input().split())
	print((23 - hours) * 60 + (60 - minutes))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		rr.append(1440 - n * 60 - m)
	return JA(rr, '\n')
print(main())


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	(h, m) = Scanner.map_int()
	print((23 - h) * 60 + 60 - m)

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


n = int(input())
while n:
	(h, m2) = map(int, input().split())
	print(24 * 60 - (h * 60 + m2))
	n -= 1


n = int(input())
lst = []
for i in range(n):
	lst.append(list(map(int, input().split())))
for i in lst:
	print((23 - i[0]) * 60 + (60 - i[1]))


for i in range(int(input())):
	(hrs, mins) = map(int, input().split())
	t_mins = 60 - mins + (24 - hrs - 1) * 60
	print(t_mins)


t = int(input())
hrs = []
min = []
for i in range(0, t):
	(h, m) = input().split()
	hrs.append(h)
	min.append(m)
	hrs[i] = int(hrs[i])
	min[i] = int(min[i])
for i in range(0, t):
	rmfh = 23 - hrs[i]
	rmfh = rmfh * 60
	rmfm = 60 - min[i]
	total_min = rmfh + rmfm
	print(total_min)


for _ in range(int(input())):
	(H, M) = list(map(int, input().split()))
	s = 0
	if H == 0 and M == 0:
		print(s)
	else:
		s = (23 - H) * 60 + (60 - M)
		print(s)


t = int(input())
for i in range(t):
	l = input().strip().split()
	(h, m) = (int(l[0]), int(l[1]))
	total = 0
	if m == 0:
		total = (24 - h) * 60
	else:
		total = 60 - m
		h = h + 1
		total += (24 - h) * 60
	print(total)


t = int(input())
while t:
	l = list(map(int, input().split()))
	h = l[0]
	m = l[1]
	x = (23 - h) * 60
	y = 60 - m
	a = x + y
	print(a)
	t = t - 1


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(h, m) = (int(x) for x in stdin.readline().split())
	print(60 - m + 60 * (24 - h - 1))


a = int(input())
for _ in range(a):
	(h, m) = map(int, input().split())
	s = 24 * 60
	s2 = h * 60 + m
	print(s - s2)


z = int(input())
for x in range(z):
	(n, m) = map(int, input().strip().split()[:2])
	if m == 0:
		print((24 - n) * 60)
	elif n == 0:
		print(24 * 60 - m)
	elif n == 23:
		print(60 - m)
	else:
		print((24 - n) * 60 - m)


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	count = 1440
	m1 = m * 60 + n
	print(count - m1)


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	ans = 60 - m
	n = n + 1
	ans += (24 - n) * 60
	print(ans)


a = int(input())
for i in range(a):
	l1 = list(map(int, input().split(' ')))
	h = 24 - l1[0]
	m = l1[1]
	print(h * 60 - m)


def main():
	t = int(input())
	for i in range(t):
		(hr, mi) = map(int, input().split(' '))
		if 0 - mi < 0:
			time = (23 - hr) * 60 + (60 - mi)
			print(time)
		else:
			time = (24 - hr) * 60
			print(time)
main()


import datetime
q = int(input())
for i in range(q):
	s = input().split(' ')
	a = datetime.datetime(2019, 6, 20, int(s[0]), int(s[1]), 0)
	b = datetime.datetime(2019, 6, 21, 0, 0, 0)
	c = b - a
	nrmin = divmod(c.seconds, 60)
	print(nrmin[0])


t = int(input())
while t != 0:
	(h, m) = map(int, input().split())
	remainingMin = 60 - m
	remainingHour = 24 - h
	remainingMin = remainingMin + (remainingHour - 1) * 60
	print(remainingMin)
	t -= 1


t = int(input())
while 1 <= t <= 1439:
	(h, m) = map(int, input().split())
	if h != 0 or m != 0:
		if 0 <= h < 24 and 0 <= m < 60:
			x = h * 60 + m
			y = 1440 - x
			print(y)
			t = t - 1


def minutes_year():
	cases = input()
	times = []
	maximum = 1440
	for i in range(int(cases)):
		times.append(input().split())
	for i in range(len(times)):
		output = 0
		output += int(times[i][0]) * 60
		output += int(times[i][1])
		print(maximum - output)
	return
minutes_year()


t = int(input())
for i in range(t):
	(h, m) = [int(x) for x in input().split()]
	hr = 24 - h
	mr = 60 - m
	print(hr * 60 - m)


for tin in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print(0)
	x = 24 - a - 1
	y = 60 - b
	print(x * 60 + y)


day = 24 * 60
n = int(input())
for i in range(n):
	(ch, m) = list(map(int, input().split()))
	print(day - ch * 60 - m)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

def MI():
	return map(int, input().split())

def S():
	return input()

def MS():
	return map(str, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def input():
	return sys.stdin.readline().rstrip()

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False

def solve(T):
	(hh, mm) = MI()
	hours = 23 - hh
	mins = 60 - mm
	print(hours * 60 + mins)

def main():
	T = I()
	for i in range(T):
		solve(T)
main()


n = int(input().strip())
results = []
for _ in range(n):
	(a, b) = list(map(int, input().strip().split()))
	results.append((23 - a) * 60 + (60 - b))
print('\n'.join(map(str, results)))


import math
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	print((24 - h - 1) * 60 + (60 - m))


size = int(input())
i = 0
while i < size:
	inp = input().split()
	(h, m) = (int(inp[0]), int(inp[1]))
	print(1440 - h * 60 - m)
	i += 1


import sys

def getMultiLineInput() -> []:
	lines = []
	while True:
		try:
			lines.append(input())
		except EOFError:
			break
	return lines

def calculate(hh: int, mm: int) -> str:
	remain = (23 - hh) * 60
	remain += 60 - mm
	return str(remain)
inputs = getMultiLineInput()
count = int(inputs[0])
for i in range(1, count + 1):
	data = list(map(lambda x: int(x), inputs[i].split()))
	print(calculate(data[0], data[1]))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def pin(l, a):
	mi = min(l)
	pos = 0
	while l[pos] != mi:
		pos += 1
	return [mi, pos]

def main():
	try:
		for _ in range(I()):
			(a, b) = In()
			print((24 - a) * 60 - b)
	except:
		pass
main()


testcases = int(input())
for test in range(testcases):
	x = input().split(' ')
	x = [int(i) for i in x]
	hr = x[0]
	min = x[1]
	total_in = hr * 60 + min
	total_out = 24 * 60
	total = total_out - total_in
	print(total)


t = input('')
i = 0
while i < int(t):
	i = i + 1
	(x, y) = input().split()
	sum = (24 - int(x)) * 60 - int(y)
	print(sum)


n = int(input())
ls = []
res = []
for i in range(n):
	l = list(map(int, input().split()))
	ls.append(l)
for i in range(n):
	x = (24 - ls[i][0]) * 60
	y = 60 - ls[i][1]
	if ls[i][1] == 0:
		res.append(x)
	else:
		res.append(x - 60 + y)
print(*res, sep='\n')


t = int(input())
for i in range(t):
	(h, m) = [int(x) for x in input().split()]
	h1 = 24 - h
	m1 = 60 - m
	print(h1 * 60 + m1 - 60)


import math
t = int(input())
for i in range(0, t):
	(h, m) = map(int, input().split())
	ans = 1440 - (60 * h + m)
	print()
	print(ans)


t = int(input())
for t in range(t):
	(p, q) = map(int, input().split())
	print((23 - p) * 60 + (60 - q))


t = int(input())
(s, n, x) = (0, 0, 0)
for i in range(t):
	(h, m) = [int(i) for i in input().split()]
	if h < 23:
		n = (23 - h) * 60
	else:
		n = 0
	if m < 60:
		s = 60 - m
	else:
		s = 0
	x = n + s
	print(x)


from sys import stdin
for _ in range(int(stdin.readline())):
	(h, m) = map(int, stdin.readline().split())
	ans = (23 - h) * 60 + (60 - m)
	print(ans)


t = int(input())
while t > 0:
	inp = input()
	lis = inp.split()
	h = int(lis[0])
	m = int(lis[1])
	print((23 - h) * 60 + 60 - m)
	t = t - 1


for tt in range(int(input())):
	(h, m) = map(int, input().split())
	hr = 24 - h
	mr = 60 - m
	if mr > 0:
		ans = (hr - 1) * 60 + mr
	else:
		ans = hr * 60
	print(ans)


for i in range(int(input())):
	(h, m) = input().split()
	ho = 23 - int(h)
	mo = 60 - int(m)
	print(ho * 60 + mo)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	th = 24 - h - 1
	tm = 60 - m
	print(tm + th * 60)


t = int(input())
for i in range(t):
	x = list(map(int, input().split()))
	h = 23 - x[0]
	m = 60 - x[1]
	print(h * 60 + m)


class MinutesBeforeNY:

	def solve(self, hh, mm):
		totalminutes = 1440
		hh = 60 * hh
		return totalminutes - (hh + mm)
n = int(input())
for i in range(n):
	(hh, mm) = map(int, input().split())
	mbny = MinutesBeforeNY()
	result = mbny.solve(hh, mm)
	print(result)


t = int(input())
(l, solution) = ([], [])

def solve(x, y):
	totalx = 24
	if x != 0 or y != 0:
		if y == 0:
			return (24 - x) * 60
		else:
			return 60 - y + (24 - x - 1) * 60
for i in range(t):
	l = list(map(int, input().split()))
	(x, y) = (l[0], l[1])
	result = solve(x, y)
	solution.append(result)
for i in solution:
	print(i)


t = int(input())
for _ in range(t):
	(h, m) = (int(v) for v in input().split())
	mm = abs(1440 - h * 60 - m)
	print(mm)


t = int(input())
a = [[12, 30]] * t
for i in range(t):
	a[i] = list(map(int, input().split()))
for i in range(t):
	left = (23 - a[i][0]) * 60 + (60 - a[i][1])
	print(left)


tc = int(input())
while tc:
	(arr, brr) = map(int, input().split(' '))
	x = arr * 60
	ans = abs(x + brr)
	print(24 * 60 - ans)
	tc = tc - 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x = 24 * 60
	print(x - (n * 60 + m))


n = int(input())
for i in range(0, n):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	r = 24 - a
	r = r * 60 - b
	print(r)


t = int(input())
for i in range(t):
	inp = input().split(' ')
	hh = int(inp[0])
	mm = int(inp[1])
	print((24 - hh) * 60 - mm)


s = int(input())
for i in range(s):
	(a, b) = input().split(' ')
	(a, b) = (23 - int(a), 60 - int(b))
	a = a * 60 + b
	print(a)


q = int(input())
for i in range(q):
	(w, e) = map(int, input().split())
	print((23 - w) * 60 + 60 - e)


repetitions = int(input())
for times in range(repetitions):
	(hours, minutes) = map(int, input().split())
	time = hours * 60 + minutes
	hour24 = 1440 - time
	print(hour24)


t = int(input())
for i in range(1, t + 1):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	t = int(a * 60 + b)
	print(1440 - t)


t = int(input())
for i in range(t):
	x = list(map(int, input().split()))
	h = x[0]
	m = x[1]
	if h < 24 and m < 60:
		timeh = 24 - h
		timem = 60 - m
	if timeh == 1:
		print(timem)
	elif timeh == 24:
		print(23 * 60 + timem)
	else:
		print((timeh - 1) * 60 + timem)


n = int(input())
for i in range(n):
	s = input()
	l = s.split()
	if 60 - int(l[1]) < 60:
		a = 60 - int(l[1])
		w = 24 - int(l[0]) - 1
		print(w * 60 + a)
	else:
		w = 24 - int(l[0])
		print(w * 60)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	x = 23 - h
	y = 60 - m
	ans = x * 60 + y
	print(ans)


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')
for _ in range(inp()):
	(h, m) = mulip()
	x = h * 60 + m
	print(1440 - x)


t = int(input())
for i in range(t):
	(h, m) = [int(i) for i in input().split()]
	if m == 0:
		print((24 - h) * 60)
	else:
		total_min_spent = h * 60 + m
		fixed = 24 * 60
		print(fixed - total_min_spent)


n = int(input())
out = []
for i in range(n):
	(h, m) = input().split(' ')
	(h, m) = (int(h), int(m))
	out.append(1440 - (h * 60 + m))
for i in out:
	print(i)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(h, m) = inputnums()
	ans = 60 * (23 - h) + 60 - m
	print(ans)


cases = int(input())
for _ in range(cases):
	time = list(map(int, input().split()))
	print((23 - time[0]) * 60 + (60 - time[1]))


for x in range(int(input())):
	(hour, minutes) = map(int, input().split())
	print((24 - hour) * 60 - minutes)


for _ in range(int(input())):
	f = input().split()
	(r, k) = (23 - int(f[0]), 60 - int(f[1]))
	print(r * 60 + k)


p = int(input())
for _ in range(p):
	(h, m) = map(int, input().split())
	t = 0
	t += 60 - m
	t += 60 * (24 - h - 1)
	print(t)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p
for _ in range(ii()):
	(a, b) = mi()
	a = 24 - a
	print(a * 60 - b)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	min = 1440 - (x * 60 + y)
	print(min)


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return False
for _ in range(int(input())):
	(a, b) = getNM()
	print((24 - a) * 60 - b)


l = []
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l.append((24 - n - 1) * 60 + (60 - m))
[print(i) for i in l]


test = int(input())
while test > 0:
	(h, m) = list(map(int, input().split()))
	if h == 0 and m == 0:
		print(0)
	else:
		res = (23 - h) * 60 + 60 - m
		print(res)
	test = test - 1


import math
test = int(input())
for tes in range(test):
	(h, m) = list(map(int, input().split()))
	main = 23 - h
	mins = 60 - m
	print(main * 60 + mins)


a = input()
a = int(a)
day = []
for i in range(a):
	b = input()
	day.append(b.split())
	for j in range(len(day[i])):
		day[i][j] = int(day[i][j])
	print(60 - day[i][1] + (23 - day[i][0]) * 60)


t = int(input())
for cases in range(t):
	(h, m) = map(int, input().split())
	mins = (23 - h) * 60 + (60 - m)
	print(mins)


import sys
input = sys.stdin.readline
t = int(input().strip())
while t > 0:
	(h, m) = map(int, input().split())
	ans = (24 - h) * 60 - m
	print(ans)
	t -= 1


nTests = int(input())
time = []
minsTil = 0
for test in range(nTests):
	time = [int(k) for k in input().split()]
	minsTil = 60 - time[1]
	minsTil += 60 * (23 - time[0])
	print(minsTil)


T = int(input())
Total = []
h = 0
m = 0
for i in range(T):
	temp = input().split()
	if len(temp) >= 1:
		h = int(temp[0]) * 60
	if len(temp) >= 2:
		m = int(temp[1])
	Total.append(1440 - (h + m))
	h = 0
	m = 0
for i in range(T):
	print(Total[i])


n = int(input())
for _ in range(0, n):
	(h, m) = [int(u) for u in input().split()]
	final_ans = (23 - h) * 60 + (60 - m)
	print(final_ans)


testcases = int(input())
for i in range(testcases):
	(hours, mins) = map(int, input().split())
	hours_min = (23 - hours) * 60
	mins = 60 - mins
	ans = hours_min + mins
	print(ans)


i = int(input())
j = 1
while j <= i:
	hm = [int(i) for i in input().split()]
	h = hm[0]
	m = hm[1]
	print(1440 - (h * 60 + m))
	j = j + 1


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	try:
		for _ in range(I()):
			(a, b) = In()
			temp = (24 - a) * 60 - b
			print(temp)
	except:
		pass
main()


t = int(input(''))
for i in range(t):
	s = input('').split(' ')
	h = int(s[0])
	m = int(s[1])
	print(str(-60 * h - m + 1440))


n = int(input())
lines = []
for _ in range(n):
	line = input().split()
	lines.append((int(line[0]), int(line[1])))
for line in lines:
	print('{}'.format((23 - line[0]) * 60 + 60 - line[1]))


t = int(input())
ans = []
for kk in range(t):
	(h, m) = [int(i) for i in input().split()]
	ans.append((23 - h) * 60 + 60 - m)
for i in ans:
	print(i)


x = int(input())
for i in range(x):
	y = str(input())
	print((23 - int(y[0:2])) * 60 + 60 - int(y[-2:]))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	ans = 60 - l[1]
	ans += (23 - l[0]) * 60
	print(ans)


tests = int(input())
NEW_YEAR = 24 * 60
for i in range(tests):
	(hours, minutes) = map(int, input().split())
	print(NEW_YEAR - (hours * 60 + minutes))


def sol():
	(x, y) = map(int, input().split())
	print(24 * 60 - x * 60 - y)
for n in range(int(input())):
	sol()


n = int(input())
ti = []
for i in range(n):
	k = list(map(int, input().split()))
	ti.append((23 - k[0]) * 60 + 60 - k[1])
for elem in ti:
	print(elem)


t = int(input())
hms = []
for _ in range(t):
	hms += [tuple(map(int, input().split()))]
for (h, m) in hms:
	print(24 * 60 - (h * 60 + m))


import sys
T = input()
T = int(T)
t = 0
while t < T:
	riga = list(map(int, input().strip().split()))
	h = riga[0]
	m = riga[1]
	H = h * 60
	M = H + m
	r = 1440 - M
	print(r)
	t = t + 1


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	tm = abs(h - 23) * 60 + abs(60 - m)
	print(tm)


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	minutes = h * 60 + m
	print(str(24 * 60 - minutes))


def main():
	N = int(input())
	for i in range(N):
		a = [int(i) for i in input().split()]
		print(1440 - (a[0] * 60 + a[1]))
main()


t = int(input())
for _ in range(t):
	(h, m) = (int(v) for v in input().split())
	mm = 24 * 60 - (h * 60 + m)
	print(mm)


from math import pow
I = int(input())
while I > 0:
	(l, r) = map(int, input().split())
	C = l * 60 + r
	print(1440 - C)
	I -= 1


test = int(input())
for t in range(test):
	(h, m) = map(int, input().split())
	ans = 0
	ans += abs(m - 60)
	h += 1
	ans += abs(h - 24) * 60
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split()]
	time = a * 60 + b
	print(24 * 60 - time)


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
from functools import reduce

def factors(n):
	step = 2 if n % 2 else 1
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(sqrt(n)) + 1, step) if n % i == 0)))

def inp():
	return map(int, input().split())
mod = int(1000000000.0) + 7

def solve(a, m):
	ans = []
	ds = []
	for fact in factors(m):
		if m % fact == 0 and fact != m:
			if (m // fact - 1) % a == 0:
				temp = (m - fact) // a
				ds.append(fact)
				ans.append(temp)
	ans.sort()
	an = []
	n = len(ans)
	for i in range(n):
		an.append(str(ans[i]))
	print(n)
	return ' '.join(an)

def solve1(s):
	n = len(s)
for _ in range(int(input())):
	(h, m) = inp()
	print(24 * 60 - (h * 60 + m))


w = int(input())
a = []
for i in range(0, w):
	p = input().split()
	a.append(p)
for i in range(0, w):
	r = a[i]
	print(int(1440 - int(r[0]) * 60 - int(r[1])))


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(a, b) = (int(x) for x in stdin.readline().split())
	print((23 - int(a)) * 60 + 60 - int(b))


t = int(input())
while t:
	t = t - 1
	(h, m) = map(int, input().split())
	ans = 0
	h1 = 24 - h - 1
	h = h1 * 60
	m = 60 - m
	print(h + m)


import math
from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
import bisect
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
t = ii()
for _ in range(t):
	(h, m) = iia()
	if h == 0 and m == 0:
		print(0)
	else:
		if m > 0:
			h = 24 - h - 1
		else:
			h = 24 - h
		if m != 0:
			m = 60 - m
		print(60 * h + m)


for i in range(int(input())):
	(h, m) = list(map(int, input().split()))
	h1 = 24 - h
	m1 = 60 - m
	print((h1 - 1) * 60 + m1)


t = int(input())
res = []
for i in range(t):
	l = list(map(int, input().split(' ')))
	r = 60 * (23 - l[0]) + 60 - l[1]
	res.append(r)
for x in res:
	print(x)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def solve():
	(a, b) = sep()
	if a == 0 and b == 0:
		print(0)
	else:
		ans = 60 - b
		a += 1
		ans += (24 - a) * 60
		print(ans)
testcase(int(inp()))


t = int(input())
while t > 0:
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	rem_min = 60 - m
	rem_h = 23 - h
	rem_min = rem_min + rem_h * 60
	print(rem_min)
	t = t - 1


n = int(input())
while n > 0:
	(h, m) = map(int, input().split())
	count = 0
	hh = 24 - h - 1
	count = count + hh * 60
	mm = 60 - m
	count = count + mm
	print(count)
	n = n - 1


t = int(input())
while t:
	time = input().split()
	h = int(time[0])
	m = int(time[1])
	tmin = (24 - h) * 60 - m
	print(tmin)
	t -= 1


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	print((24 - h) * 60 - m)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
import random

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def bit_combination(k, n=2):
	rt = []
	for tb in range(n ** k):
		s = [tb // n ** bit % n for bit in range(k)]
		rt += [s]
	return rt

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
input = lambda : sys.stdin.readline().rstrip()

def ran_input():
	import random
	n = random.randint(4, 16)
	(rmin, rmax) = (1, 10)
	a = [random.randint(rmin, rmax) for _ in range(n)]
	return (n, a)
show_flg = False
show_flg = True
ans = 0
t = I()
for _ in range(t):
	(h, m) = LI()
	ans = 60 * (23 - h) + 60 - m
	print(ans)


hm = int(input())
for _ in range(hm):
	(h, m) = map(int, input().split())
	mins = h * 60 + m
	print(1440 - mins)


t = int(input())
for tt in range(t):
	hm = input().split(' ')
	h = int(hm[0])
	m = int(hm[1])
	mins = 60 - m
	hrs = 23 - h
	minmore = 60 * hrs
	print(mins + minmore)


for _ in '0' * int(input()):
	(h, m) = map(int, input().split())
	print((23 - h) * 60 + 60 - m)


import sys
times = int(sys.stdin.readline())
for time in range(times):
	(hh, mm) = map(int, sys.stdin.readline().strip().split())
	print(24 * 60 - (hh * 60 + mm))


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hours = 24 - h
	mins = 60 - m
	if h < 23:
		mins = hours * 60 - m
	print(mins)


t = int(input())
for _ in range(t):
	x = 24 * 60
	(a, b) = map(int, input().split())
	z = a * 60 + b
	print(x - z)


T = int(input(''))
for i in range(0, T):
	d = (24, 60)
	(a, b) = map(int, input().split())
	t = (a, b)
	print((d[0] - t[0] - 1) * 60 + d[1] - t[1])


from math import pow
I = int(input())
x = 0
for x in range(I):
	(l, r) = map(int, input().split())
	C = l * 60 + r
	print(1440 - C)


def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	(h, m) = rl()
	print(60 - m + 60 * (24 - h - 1))
t = ri()
for i in range(t):
	solve()


from sys import stdin
inp = stdin.readline
t = int(inp())
for i in range(t):
	(h, m) = [int(x) for x in inp().split()]
	print(str((23 - h) * 60 + (60 - m)))


def newyear(h, m):
	return 1440 - (h * 60 + m)
t = int(input())
for i in range(t):
	(h, m) = [int(i) for i in input().split()]
	print(newyear(h, m))


t = int(input())
for i in range(0, t):
	(hr, mi) = map(int, input().split())
	h = 23 - hr
	m = 60 - mi
	ans = 60 * h + m
	print(ans)


no_of_testcases = int(input())
for i in range(no_of_testcases):
	list_of_numbers = list(map(int, input().split(' ')))
	minutes = 60 - list_of_numbers[1]
	hours = 24 - list_of_numbers[0] - 1
	print(hours * 60 + minutes)


a = int(input())
for _ in range(a):
	l = input().split(' ')
	(h, m) = (int(l[0]), int(l[1]))
	if h == 23:
		print(60 - m)
	else:
		print(60 * (23 - h) + 60 - m)


n = int(input())
for i in range(n):
	(m, k) = map(int, input().split())
	r = 23 - m
	k = 60 - k
	t = r * 60
	print(t + k)


n = int(input())
for i in range(0, n):
	(h, m) = list(map(int, input().split(' ')))
	ans = 1440 - (60 * h + m)
	print(ans)


n = int(input())
s = 0
for i in range(n):
	(h, m) = map(int, input().split())
	s = 24 * 60 - (h * 60 + m)
	print(s)


a = int(input())
for i in range(a):
	read = input()
	time = read.split()
	hour = int(time[0])
	minutes = int(time[1])
	finalMinute = 60 - minutes
	finalHour = 24 - hour - 1
	print(finalMinute + finalHour * 60)


from sys import stdin
t = int(input())
for _ in range(t):
	(h, m) = [int(s) for s in input().split()]
	print((23 - h) * 60 + (60 - m))


t = int(input())
for _ in range(t):
	l = list(map(int, input().strip().split()))
	h = l[0]
	m = l[1]
	print((23 - h) * 60 + (60 - m))


x = int(input())
for i in range(0, x):
	(h, m) = list(map(int, input().split(' ')))
	print(24 * 60 - (h * 60 + m))


test = int(input())
for t in range(test):
	(hh, mm) = [int(x) for x in input().split(' ')]
	print((23 - hh) * 60 + (60 - mm))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	k = (23 - x) * 60 + (60 - y)
	print(k)


n = int(input())
for i in range(n):
	(t, m) = input().split()
	g = 0
	r = 60 - int(m)
	g = g + r
	r2 = 23 - int(t)
	g = g + r2 * 60
	print(g)


import math

def new_year_calculation(h, m):
	cnt_m = 60 - m
	cnt_h = (24 - h - 1) * 60
	cnt = cnt_m + cnt_h
	return cnt
t = int(input())
for i in range(t):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	print(new_year_calculation(h, m))


n = int(input())
for i in range(n):
	k = list(map(int, input().split()))
	s = k[0] * 60 + k[1]
	print(1440 - s)


import os, sys, math
import collections
if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.txt', encoding='utf8')
	input = src.readline

def solve():
	minutes_so_far = h * 60 + m
	return 24 * 60 - minutes_so_far

def integers():
	return map(int, input().strip().split())

def array_of_integers(q):
	return [tuple(map(int, input().strip().split())) for _ in range(q)]
(t,) = integers()
for _ in range(t):
	(h, m) = integers()
	res = solve()
	print(res)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	tt = h * 60 + m
	tl = 24 * 60 - tt
	print(tl)


import datetime as dt
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	x = dt.datetime(1, 1, 1, h, m)
	y = dt.datetime(1, 1, 2, 0, 0)
	z = str(y - x).split(':')
	for i in z:
		if len(i) > 1:
			if i[0] == '0':
				z[z.index(i)] = int(i[1])
		else:
			z[z.index(i)] = int(i)
	print(int(z[0]) * 60 + int(z[1]))


t = int(input(''))
mat = []
for i in range(t):
	mat.append(list(map(int, input().split())))
for i in range(t):
	x = mat[i]
	h = x[0]
	m = x[1]
	print((24 - h - 1) * 60 + (60 - m))


test = int(input())
while test:
	current = list(map(int, input().split(' ')))
	totalmin = 1440
	minpast = current[0] * 60 + current[1]
	print(totalmin - minpast)
	test -= 1


t = int(input())
for i in range(t):
	(h, m) = [int(j) for j in input().split()[:2]]
	x = 23 - h
	y = 60 - m
	ans = x * 60 + y
	print(ans)


T = int(input())
for i in range(1, T + 1):
	s = input()
	s2 = s.split()
	(h, m) = map(int, s2)
	h = h * 60
	t = int(h + m)
	output = t
	real_time = 1440 - t
	print(real_time)


n = int(input())
cases = [list(map(int, input().split())) for _ in range(n)]
for case in cases:
	remain_h = 24 - case[0]
	mins = remain_h * 60 - case[1]
	print(mins)


def func(x):
	z = (24 - int(x.split(' ')[0])) * 60 - int(x.split(' ')[1])
	return z
y = int(input())
for i in range(y):
	x = input()
	print(func(x))


x = int(input())
for i in range(x):
	(m, s) = [int(x) for x in input().split(' ')]
	print(1440 - m * 60 - s)


n = int(input())
for i in range(n):
	(hour, minutes) = map(int, input().split())
	res = 60 * (24 - hour) - minutes
	print(res)


t = int(input())
for i in range(t):
	(h, m) = list(map(int, input().split()))
	s = (24 - h) * 60 - m
	print(s)


t = int(input())
k = []
for i in range(t):
	p = input().split()
	k.append(p)
	k[i][0] = int(k[i][0])
	k[i][1] = int(k[i][1])
for i in range(t):
	time = (23 - k[i][0]) * 60 + (60 - k[i][1])
	print(time)


testes = int(input())
i = 0
while i < testes:
	hora = str(input()).split(' ')
	if int(hora[0]) == 23:
		minutostotal = 60 - int(hora[1])
	else:
		minutostotal = (23 - int(hora[0])) * 60 + 60 - int(hora[1])
	i += 1
	print(minutostotal)


t = int(input())
for i in range(t):
	(h, m) = tuple([int(x) for x in input().split(' ')])
	print(24 * 60 - 60 * h - m)


t = int(input())
while t > 0:
	(h, m) = map(int, input().split())
	mins = 0
	r_h = 23 - h
	r_m = 60 - m
	if r_h > 0:
		mins = r_h * 60
	mins += r_m
	print(mins)
	t -= 1


tc = input()
for i in range(int(tc)):
	(h, m) = [int(x) for x in input().split(' ')]
	ans = (23 - h) * 60 + (60 - m)
	print(ans)


q = int(input())
for iwer in range(q):
	(a, b) = map(int, input().split())
	wyn = 0
	if a > 0:
		wyn += 60 * (24 - a)
	else:
		wyn += 24 * 60
	wyn -= b
	print(wyn)


q = int(input())
for i in range(q):
	m0 = 23
	s0 = 60
	(m, s) = [int(tmp) for tmp in input().split()]
	print((m0 - m) * 60 + (s0 - s))


t = int(input())
owns = []
for i in range(t):
	first = input().split(' ')
	hourt = int(first[0])
	minyt = int(first[1])
	a = 1440 - (hourt * 60 + minyt)
	owns += [a]
for i in range(t):
	print(owns[i])


t = int(input())
while t > 0:
	(h, m) = map(int, input().split())
	H = 23 - h
	M = 60 - m
	if H == 24:
		H = 0
		M = 0
	print(H * 60 + M)
	t -= 1


test = int(input())
for _ in range(test):
	(h, m) = map(int, input().split())
	mi = h * 60 + m
	print(1440 - mi)


import operator
t = int(input())
for i in range(0, t):
	(h, m) = map(int, input().split())
	time = (23 - h) * 60 + (60 - m)
	print(time)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	ans = 24 * 60
	te = a * 60 + b
	print(ans - te)


n = int(input())
sol = []
for i in range(0, n):
	(a, b) = map(int, input().split())
	x = 23 - a
	y = 60 - b
	soln = x * 60 + y
	sol.append(soln)
for i in range(0, len(sol)):
	print(sol[i], '\r')


t = int(input())
i = 0
while i < t:
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	print(1440 - (h * 60 + m))
	i = i + 1


while True:
	x = int(input(''))
	if 0 < x < 1440:
		break
l = list()
for i in range(x):
	s = 0
	while True:
		y = input('')
		h = y.split(' ')
		for j in range(len(h)):
			h[j] = int(h[j])
		if 0 <= h[0] < 24 and 0 <= h[1] < 60:
			s += 1
		if h[0] == 0 and h[1] == 0:
			s -= 1
		if s == 1:
			break
	l.append(h)
r = list()
for j in range(len(l)):
	q = 0
	m = 0
	if l[j][0] != 0:
		q = (24 - l[j][0]) * 60
		m = q - l[j][1]
		r.append(m)
	if l[j][0] == 0:
		m = 24 * 60 - l[j][1]
		r.append(m)
for i in range(len(r)):
	print(r[i])


test_cases = int(input())
tests = [list(map(int, input().strip().split()))[:6] for tests in range(0, test_cases)]
for i in tests:
	print(1380 - i[0] * 60 + (60 - i[1]))


N = int(input())
for _ in range(N):
	(h, m) = [int(x) for x in input().split()]
	print(24 * 60 - (h * 60 + m))


for _ in range(int(input())):
	(X, Y) = map(int, input().split())
	ans = 60 - Y + (23 - X) * 60
	print(ans)


t = int(input())
ans = []
for i in range(t):
	(h, m) = [int(i) for i in input().split()]
	h *= 60
	ans.append(1440 - h - m)
[print(i) for i in ans]


t = int(input())
for _ in range(t):
	(hh, mm) = map(int, input().split())
	minute = hh * 60 + mm
	result = 1440 - minute
	print(result)


import sys

def main():
	x = 24 * 60
	for tc in range(int(input())):
		(h, m) = get_ints()
		y = h * 60 + m
		print(x - y)
get_array = lambda : list(map(int, sys.stdin.readline().split()))
get_ints = lambda : map(int, sys.stdin.readline().split())
input = lambda : sys.stdin.readline().strip()
main()


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	s = a * 60 + b
	r = 24 * 60
	print(r - s)


q = int(input())
for i in range(q):
	(h, m) = list(map(int, input().split()))
	res = (23 - h) * 60 + (60 - m)
	print(res)


n = int(input())
r = 0
for i in range(n):
	n1 = 0
	n2 = 0
	a = str(input())
	if a[2] == ' ' and len(a) == 5:
		n1 += int(a[0]) * 10 + int(a[1])
		n2 += int(a[3]) * 10 + int(a[4])
	elif a[1] == ' ' and len(a) == 4:
		n1 += int(a[0])
		n2 += int(a[2]) * 10 + int(a[3])
	elif a[2] == ' ' and len(a) == 4:
		n1 += int(a[0]) * 10 + int(a[1])
		n2 += int(a[3])
	elif a[1] == ' ' and len(a) == 3:
		n1 = int(a[0])
		n2 = int(a[2])
	print(1440 - (n1 * 60 + n2))


from sys import *
t = int(stdin.readline())
for _ in range(t):
	(h, m) = map(int, stdin.readline().split())
	x = (23 - h) * 60
	y = 60 - m
	print(x + y)


t = int(input())
for i in range(t):
	l = []
	(h, m) = [int(x) for x in input().split()]
	th = h * 60
	tm = th + m
	r = 1440 - tm
	print(r)


print(*map(lambda line: 60 * 24 - line[0] * 60 - line[1], (tuple(map(int, input().split())) for i in range(int(input())))), sep='\n')


t = int(input())
for p in range(t):
	(h, m) = map(int, input().split())
	a = 23 - h
	b = 60 - m
	print(a * 60 + b)


def minutes(h, m):
	return (23 - h) * 60 + (59 - m) + 1
n = int(input())
i = 0
while i < n:
	(h, m) = map(int, input().split())
	print(minutes(h, m))
	i += 1


t = int(input())
total = 24 * 60
for i in range(t):
	(x, y) = map(int, input().split())
	time = x * 60 + y
	print(total - time)


n = int(input())
for i in range(n):
	n2 = list(map(int, input().split()))
	h = n2[0]
	m = n2[1]
	print(1440 - h * 60 - m)


t = int(input())
numbers = [str(input()) for i in range(0, t)]
for i in range(0, len(numbers)):
	minute = int(numbers[i].split(' ')[1])
	hour = int(numbers[i].split(' ')[0])
	print(1440 - hour * 60 - minute)


for _ in range(int(input())):
	data = input()
	d = data.split()
	h = int(d[0])
	m = int(d[1])
	print((24 - h - 1) * 60 + (60 - m))


(minutos_total_ano_novo, horas_ano_novo, minutos_ano_novo) = (list(), 0, 0)
for _ in range(int(input())):
	(h, m) = map(int, input().split(' '))
	horas_ano_novo = (24 - h) * 60
	minutos_ano_novo = 60 - m
	if h == 0 and m == 0:
		(horas_ano_novo, minutos_ano_novo) = (0, 0)
		minutos_total_ano_novo.append(horas_ano_novo + minutos_ano_novo)
	else:
		minutos_total_ano_novo.append(horas_ano_novo - 60 + minutos_ano_novo)
print(*minutos_total_ano_novo, sep='\n')


t = int(input())
for w in range(t):
	a = input().split(' ')
	h = int(a[0])
	m = int(a[1])
	h = 23 - h
	m = 60 - m
	m += h * 60
	print(m)


n = int(input())
data = []
for i in range(n):
	data.append(input())
	data[i] = data[i].split()
for i in range(n):
	print((23 - int(data[i][0])) * 60 + (60 - int(data[i][1])))


t = int(input())
for x in range(0, t):
	s = input()
	i = s.split(' ')
	score = 0
	h = int(i[0])
	m = int(i[1])
	h = 24 - h
	for j in range(h):
		score += 60 - m
		m = 0
	print(score)


for x in range(int(input())):
	(hours, minuts) = map(int, input().split())
	print(1440 - hours * 60 - minuts)


t = int(input())
while t > 0:
	(h, m) = [int(ele) for ele in input().split()]
	print((23 - h) * 60 + 60 - m)
	t -= 1


t = int(input())
l = []
for i in range(t):
	n = list(map(int, input().split()))
	l.append(n[0] * 60 + n[1])
for i in l:
	print(1440 - i)


x = int(input())
for _ in range(x):
	l = list(map(int, input().split()))
	h = 23 - l[0]
	m = 60 - l[1]
	ans = h * 60 + m
	print(ans)


t = int(input())
for ii in range(0, t, 1):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	print((24 - h) * 60 - m)


for i in range(int(input())):
	(h, m) = map(int, input().split())
	hour = 23
	minute = 60
	hour_min = int(hour - h) * 60 + int(minute - m)
	print(hour_min)


t = int(input())
mass = []
for i in range(t):
	(h, m) = map(int, input().split())
	mass.append((23 - h) * 60 + (60 - m))
for i in mass:
	print(i)


T = int(input())
for i in range(T):
	(a, b) = [int(x) for x in input().split()]
	print(24 * 60 - a * 60 - b)


t = int(input())
while t:
	(h, m) = list(map(int, input().split()))
	b = h * 60 + m
	print(24 * 60 - b)
	t = t - 1


for t in range(int(input())):
	(h, m) = map(int, input().split())
	rh = 23 - h
	rm = 60 - m
	print(rh * 60 + rm)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	r = (24 - a - 1) * 60 + (60 - b)
	print(r)


def solve(n, m):
	return 24 * 60 - n * 60 - m

def minToMid():
	N = int(input())
	for _ in range(N):
		(n, m) = map(int, input().split())
		print(solve(n, m))
minToMid()


for _ in range(int(input())):
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	s = 0
	if h < 23:
		if h != 0 and m != 0:
			s = (23 - h) * 60 + (60 - m)
		elif h != 0 and m == 0:
			s = (24 - h) * 60
		else:
			s = 23 * 60 + (60 - m)
	else:
		s = 60 - m
	print(s)


n = int(input())
for i in range(n):
	(h, m) = map(int, input().split())
	done = False
	while not done:
		x = 60 - m
		y = 24 - h - 1
		print(x + y * 60)
		break


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	(h, m) = get_ints()
	ans = 60 - m
	h += 1
	ans += (24 - h) * 60
	print(ans)


cases = int(input())
for i in range(cases):
	time = input().split()
	hours = int(time[0])
	minutes = int(time[1])
	minutesLeft = 60 * (23 - hours) + (60 - minutes)
	print(minutesLeft)


a = int(input())
for i in range(a):
	s = str(input())
	s = s.split(' ')
	b = int(s[0])
	d = int(s[1])
	k = (24 - b) * 60 - d
	print(k)


t = int(input())
for hh in range(0, t):
	(h, m) = [int(x) for x in input().split()]
	if m == 0:
		ans = (24 - h) * 60
	else:
		ans = (24 - h - 1) * 60 + (60 - m)
	print(ans)


n = int(input())
f = []
for i in range(n):
	(hh, mm) = map(int, input().split(' '))
	f.append((24 - hh) * 60 - mm)
for i in range(len(f)):
	print(f[i])


t = int(input())
for i in range(t):
	e = list(map(int, input().split()))
	res = 60 * e[0]
	res += e[1]
	res = 1440 - res
	print(res)


def main():
	cases = int(input())
	for case in range(cases):
		(hh, mm) = [int(x) for x in input().split(' ')]
		mtotal = hh * 60 + mm
		print(60 * 24 - mtotal)
main()


t = input()
for i in range(int(t)):
	(hh, mm) = map(int, input().split())
	lh = 23 - int(hh)
	lm = 60 - int(mm)
	tm = 60 * lh + lm
	print(tm)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
for t in range(I()):
	(h, m) = In()
	mi = (23 - h) * 60 + 60 - m
	print(mi)


case = int(input())
times = list(range(case))
for i in range(case):
	(h, m) = map(int, input().split())
	times[i] = [h, m]
for i in range(case):
	total = 60 * 24 - times[i][1] - times[i][0] * 60
	print(total)


t = int(input())
while t > 0:
	(h, m) = input().split()
	h = int(h)
	m = int(m)
	if m == 0:
		print((24 - h) * 60)
	else:
		h1 = (24 - (h + 1)) * 60 + 60 - m
		print(h1)
	t -= 1


t = int(input())
for i in range(t):
	(h, m) = input().split()
	(h, m) = (int(h), int(m))
	if m == 0:
		ans = (24 - h) * 60
	else:
		ans = (23 - h) * 60 + (60 - m)
	print(ans)


def minutes_left(x, y):
	if x == 0 and y == 0:
		return 0
	else:
		return 24 * 60 - 60 * x - y
t = int(input())
for i in range(0, t):
	(h, m) = map(int, input().split())
	print(minutes_left(h, m))


ntc = int(input())
for i in range(ntc):
	hh = list(map(int, input().split(' ')))
	print((23 - hh[0]) * 60 + 60 - hh[1])


from sys import stdin
t = int(stdin.readline().rstrip())
while t > 0:
	(h, m) = map(int, stdin.readline().split())
	print((23 - h) * 60 + (60 - m))
	t -= 1


for i in range(int(input())):
	qwerty = [int(i) for i in input().split()]
	h = qwerty[0]
	m = qwerty[1]
	j = h * 60 + m
	print(24 * 60 - j)


while True:
	x = int(input(''))
	if 1 <= x <= 1439:
		break
d = []
for i in range(x):
	while True:
		t = input('')
		l = t.split()
		if len(l) == 2:
			if 0 <= int(l[0]) <= 24 and 0 <= int(l[1]) <= 60:
				break
	d.append(l)
for i in range(x):
	print(23 * 60 + 59 - (int(d[i][0]) * 60 + int(d[i][1])) + 1)


x = int(input())
for i in range(x):
	(a, b) = map(int, input().strip().split())
	print(str(1440 - 60 * a - b))


from bisect import bisect_left, bisect_right
from typing import List
import collections
import bisect
import itertools
import functools
from fractions import gcd
import heapq
from math import ceil, sqrt, floor
import sys
sys.setrecursionlimit(50000)
import collections
from collections import defaultdict, deque
import collections
import bisect
from collections import defaultdict, deque
import collections
t = int(input())
for _ in range(t):
	(hh, mm) = list(map(int, input().split()))
	ret = (23 - hh) * 60
	ret += 60 - mm
	print(ret)


tc = int(input())
for ittt in range(tc):
	kk = input()
	arr = kk.split()
	hrs = int(arr[0])
	mins = int(arr[1])
	total = hrs * 60 + mins
	vh = 1440 - total
	print(vh)


(t, l) = (int(input()), [])
while t > 0:
	(h, m) = map(int, input().split(' '))
	h = h * 60 + m
	l.append(1440 - h)
	t -= 1
for x in l:
	print(x)


t = int(input())
for k in range(t):
	(h, m) = map(int, input().split())
	ans = h * 60 + m
	final = 24 * 60 - ans
	print(final)


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (h, m) in Query:
	ans = (23 - h) * 60 + (60 - m)
	print(ans)


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	h = abs(h - 24)
	if h == 1:
		m = abs(m - 60)
		print(m)
	if h == 24:
		h = 24 * 60
		print(h - m)
	if 1 < h < 24:
		h = h - 1
		h = h * 60
		print(h + abs(m - 60))


import sys
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(h, m) = read()
	print(24 * 60 - h * 60 - m)


T = int(input())
for _ in range(T):
	(h, m) = map(int, input().split())
	h_ans = 24 - (1 if m > 0 else 0) - h
	m_ans = 60 - m if m != 0 else 0
	print(60 * h_ans + m_ans)


def minutes(time):
	hours = 23 - time[0]
	mins = 60 - time[1]
	ans = mins
	ans += 60 * hours
	return ans
t = int(input())
for i in range(t):
	x = list(map(int, input().rstrip().split()))
	print(minutes(x))


for i in range(int(input())):
	(h, m) = map(int, input().split())
	ch = 24 - h
	cm = 60 - m
	print(abs(60 - (cm + ch * 60)))


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	(h, m) = rints()
	print((23 - h) * 60 + (60 - m))


import sys
it = iter(sys.stdin.read().splitlines())
limit = 24
minutes = 60
n = int(next(it))
for i in range(n):
	(h, m) = [int(x) for x in next(it).split()]
	tm = abs(h - limit) * minutes - m
	print(tm)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(h, m) = map(int, input().split())
	hoursleft = 24 - h
	minsleft = hoursleft * 60 - m
	print(minsleft)


t = int(input())
while t > 0:
	s = input()
	(hh, mm) = s.split()
	hh = int(hh)
	mm = int(mm)
	m = (23 - hh) * 60 + (60 - mm)
	print(m)
	t = t - 1


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	time = 1440
	time = time - a * 60 - b
	print(time)


num = int(input())
while num > 0:
	arr = list(map(int, input().split()))
	val = 1440
	total = arr[0] * 60 + arr[1]
	left = val - total
	print(left)
	num -= 1


n = int(input())
for i in range(n):
	t_list = [int(x) for x in input().split(' ')]
	min = 1440
	remain = min - (t_list[0] * 60 + t_list[1])
	print(remain)


t = int(input())
for i in range(t):
	(h, m) = list(map(int, input().split()))
	print(str((23 - h) * 60 + 60 - m))


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	if h == 23:
		print(60 - m)
		continue
	else:
		k = 0
		while h != 23:
			h += 1
			k += 60
		k += 60 - m
		print(k)
		continue


try:
	for _ in range(int(input())):
		n = []
		n = n + list(map(int, input().split()))
		h = (23 - n[0]) * 60
		m = 60 - n[1]
		print(h + m)
except:
	pass


a = int(input())
time = []
for i in range(a):
	k = input()
	k = k.split()
	time.append([int(k[0]), int(k[1])])
for i in range(len(time)):
	leasttime = (23 - time[i][0]) * 60 + (60 - time[i][1])
	print(leasttime)


def minutes():
	for _ in range(n):
		(*a,) = [int(x) for x in input().split()]
		yield (60 * (23 - a[0]) + (60 - a[1]))
n = int(input())
ans = minutes()
print(*ans, sep='\n')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b != 0:
		c = 60 - b
		d = (23 - a) * 60
		print(d + c)
	else:
		print((24 - a) * 60)


t = int(input())
for qwe in range(t):
	(h, m) = map(int, input().split())
	time = h * 60 + m
	print(1440 - time)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	diff = 0
	if h != 0:
		diff = (24 - h) * 60 - m
	elif m == 0:
		diff = 0
	else:
		diff = 24 * 60 - m
	print(diff)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for T in range(int(input())):
	(hours, minutes) = [int(i) for i in input().split()]
	print(24 * 60 - (hours * 60 + minutes))


test = int(input())
for i in range(test):
	(h, m) = map(int, input().split(' '))
	hour = 24 - h
	if m != 0:
		hour -= 1
		minute = 60 - m
	else:
		minute = 0
	result = minute + hour * 60
	print(result)


def main():
	t = int(input())
	if 1 <= t <= 1439:
		answers = []
		for i in range(t):
			(hh, mm) = map(int, input().split())
			answers.append((23 - hh) * 60 + (60 - mm))
	for i in range(len(answers)):
		print(answers[i])
main()


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(h, m) = map(int, sys.stdin.readline().split())
	print((24 - h) * 60 - m)


T = int(input())
L = []
for i in range(T):
	L.append([int(n) for n in input().split()])
for i in L:
	print(1440 - 60 * i[0] - i[1])


t = int(input())
for _ in range(t):
	(h, m) = map(int, input().split())
	left_min = 60 - m
	h += 1
	if h == 24:
		h = 0
	while h != 0:
		left_min += 60
		h += 1
		if h == 24:
			h = 0
	print(left_min)


n = int(input())
for i in range(n):
	lista = []
	cadena = ''
	entrada = input()
	for i in range(0, len(entrada)):
		if entrada[i] != ' ':
			cadena = cadena + entrada[i]
		if entrada[i] == ' ' or i == len(entrada) - 1:
			lista.append(int(cadena))
			cadena = ''
			continue
	b = 23 - lista[0]
	a = 60 - lista[1]
	b = b * 60
	respuesta = b + a
	print(respuesta)


t = int(input())
for _ in range(t):
	(hh, mm) = input().split()
	hm = int(hh) * 60
	all = int(hm) + int(mm)
	print(1440 - all)


from collections import defaultdict as dc
import sys
import math
mod = 10 ** 9 + 7

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def binarysearchforsolvingeqautions(a, i, l, r):
	while 1:
		mid = (l + r) / 2
		(p, q) = force(a, mid, i)
		if abs(p - q) < 1e-13:
			return mid
		elif p > q:
			l = mid
		else:
			r = mid

def bs(a, b):
	l = a
	r = b + 1
	x = b
	ans = 0
	while l < r:
		mid = (l + r) // 2
		if x | mid > ans:
			ans = x | mid
			l = mid + 1
		else:
			r = mid
	return ans

def digit(n):
	a = []
	while n > 0:
		a.append(n % 10)
		n = n // 10
	return a

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p
for _ in range(inp()):
	(a, b) = line()
	z = 60 - b
	q = 23 - a
	print(q * 60 + z)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if b == 0 and a == 0:
		print(0)
	elif b == 0 and a > 0:
		print((24 - a) * 60)
	elif a >= 0 and b > 0:
		print((24 - a - 1) * 60 + (60 - b))


from datetime import datetime
for _ in range(int(input())):
	(h, m) = map(int, input().split())
	print(int(divmod((datetime(2020, 1, 1, 0, 0) - datetime(2019, 12, 31, h, m)).total_seconds(), 60)[0]))


n = int(input())
resultados = []
for i in range(n):
	h = input()
	x = h.split()
	h = int(x[0])
	m = int(x[1])
	suma = h * 60 + m
	resultados.append(24 * 60 - suma)
for j in range(n):
	print(resultados[j])


n = int(input())
for case in range(n):
	(h, m) = list(map(int, input().split()))
	print((24 - (h + 1)) * 60 + (60 - m))


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	hl = 23 - h
	ml = 60 - m
	ml += hl * 60
	print(ml)


t = int(input())
while t > 0:
	hm = input().split()
	h = int(hm[0])
	m = int(hm[1])
	total = h * 60 + m
	print(f'{24 * 60 - total}\n')
	t -= 1


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	hour = 24 - h - 1
	minu = 60 - m
	print(hour * 60 + minu)


t = int(input())
ans = []
for _ in range(t):
	(h, m) = map(int, input().split())
	temp = (23 - h) * 60 + (60 - m)
	ans.append(temp)
for i in ans:
	print(i)


x = int(input())
for i in range(0, x):
	(n, m) = [int(a) for a in input().split()]
	k = 23 - n
	d = 60 - m
	print(k * 60 + d)


from __future__ import print_function
from __future__ import division
from sys import stdin
lista = [int(x) for x in stdin.read().split()]
N = lista.pop(0)
time = 24 * 60
for i in range(0, N * 2, 2):
	timeNow = lista[i] * 60 + lista[i + 1]
	print(time - timeNow)


t = int(input())
answer = []
for i in range(t):
	(h, m) = map(int, input().split())
	answer.append((23 - h) * 60 + (60 - m))
for item in answer:
	print(item)


a = int(input())
b = 0
while b < a:
	k = input().split()
	c = int(k[0])
	d = int(k[1])
	c = c * 60
	d = c + d
	print(1440 - d)
	b = b + 1


t = int(input())
res = 60 * 24
for _ in range(t):
	(h, m) = [int(x) for x in input().split()]
	t1 = 60 * h + m
	print(res - t1)


test = int(input())
for _ in range(test):
	(hh, mm) = map(int, input().split())
	if mm == 0:
		a = 60
	else:
		a = 60 - mm
	print((23 - hh) * 60 + a)


n = int(input())
for i in range(n):
	x = input()
	y = x.split(' ')
	a = 23 - int(y[0])
	b = 60 - int(y[1])
	print(a * 60 + b)


import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7
t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	if h == 0 and m == 0:
		print(0)
		continue
	ans = (23 - h) * 60 + 60 - m
	print(ans)


for _ in range(int(input())):
	(h, m) = map(int, input().split())
	total = 1440
	now = h * 60 + m
	print(total - now)


a = int(input())
temp = []
for i in range(a):
	(h, m) = map(int, input().split())
	if m > 0:
		temp.append((24 - h - 1) * 60 + 60 - m)
	else:
		temp.append((24 - h) * 60)
for i in range(a):
	print(temp[i])


try:
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		a = (23 - a) * 60
		b = 60 - b
		print(a + b)
except:
	pass


n = int(input())
for j in range(n):
	l1 = [int(i) for i in input().split()]
	k = l1[0] * 60
	r = k + l1[1]
	res = 1440 - r
	print(res)


for t in range(int(input())):
	(h, m) = list(map(int, input().split()))
	hleft = 24 - h
	mleft = 60 - m
	print((hleft - 1) * 60 + mleft)


for i in range(0, int(input())):
	(h, m) = list(map(int, input().split()))
	print((23 - h) * 60 + (60 - m))


test = int(input())
for _ in range(test):
	(h, m) = map(int, input().split())
	ans = (23 - h) * 60 + 60 - m
	print(ans)


n = int(input())
t = []
for i in range(n):
	l = list(map(int, input().split()))
	r = 60 - l[1] + 60 * (24 - l[0]) - 60
	t.append(r)
for j in t:
	print(j)


t = int(input())
for i in range(t):
	(horas, min) = input().split(' ')
	horas = int(horas)
	min = int(min)
	if horas != 0 and min == 0 or (horas == 0 and min != 0) or (horas != 0 and min != 0):
		tot_min = horas * 60 + min
		tempo_restante = 1440 - tot_min
		print(tempo_restante)


def calc_mins(hours, mins):
	left = 0
	if hours > 24:
		hours %= 24
	elif hours < 24 and hours >= 0:
		if hours == 23:
			left += 0
		else:
			left += (24 - hours) * 60 - 60
	if mins > 60:
		mins %= 60
	elif mins < 60 and mins >= 0:
		if mins == 0:
			left += 60
		else:
			left += 60 - mins
	return left
no_of_tcs = int(input())
hrs = []
mins = []
for i in range(no_of_tcs):
	(a, b) = map(int, input().split())
	hrs.append(a)
	mins.append(b)
for i in range(len(hrs)):
	print(calc_mins(int(hrs[i]), int(mins[i])))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n == 0 and m == 0:
		print(0)
	else:
		if m == 0:
			w = 0
			k = 24 - n
		else:
			k = 24 - n - 1
			w = 60 - m
		print(60 * k + w)


t = int(input())
for _ in range(t):
	(t, m) = map(int, input().split())
	k = 60 - m
	t += 1
	k += (24 - t) * 60
	print(k)


n = int(input())
l = []
for i in range(n):
	u = input().split()
	l += [u]
g = 0
h = 0
m = 0
for i in l:
	h = 23 - int(i[0])
	m = 60 - int(i[-1])
	g = m + h * 60
	print(g)


def main():
	for x in range(int(input())):
		(h, m) = map(int, input().split())
		print(60 * (23 - h) + 60 - m)
main()


t = int(input())
for i in range(t):
	(h, m) = map(int, input().split())
	hour = 23 - h
	minu = 60 - m
	total_min = 60 * hour + minu
	print(total_min)


for _ in range(100):
	pass
t = int(input())
for _ in range(t):
	(ha, m) = map(int, input().split())
	print(24 * 60 - ha * 60 - m)
for _ in range(100):
	pass
for _ in range(100):
	pass
for _ in range(100):
	pass


n = int(input())
ans = []
for i in range(n):
	bars = input().split()
	ans.append(24 * 60 - int(bars[0]) * 60 - int(bars[1]))
for i in ans:
	print(i)


for _ in range(int(input())):
	(h, m) = (int(x) for x in input().strip().split())
	t = h * 60 + m
	t = 24 * 60 - t
	print(t)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(h, m) = map(int, stdin.readline().split())
	stdout.write('{}\n'.format(60 - m + (23 - h) * 60))


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	print((24 - n - 1) * 60 + (60 - k))


t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	if y == 0:
		x = 24 - x
		print(60 * x)
	else:
		a = 60 - y
		b = (24 - x) * 60
		print(a + b - 60)


t = int(input())
for x in range(t):
	hm = [int(y) for y in input().split()]
	tot = 1440
	minutes = hm[0] * 60 + hm[1]
	print(tot - minutes)


for tc in [0] * int(input()):
	(a, b) = map(int, input().split())
	print(1440 - 60 * a - b)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
zero_minutes = 24 * 60
for _ in [0] * RI():
	(hour, mins) = RMI()
	print(zero_minutes - (hour * 60 + mins))


kl = int(input())
for l in range(kl):
	p = [int(i) for i in input().split()]
	print((24 - p[0]) * 60 - p[1])


n = int(input())
while n:
	(h, m) = list(map(int, input().split(' ')))
	ho = 0
	ho = 24 - h
	ho = ho * 60
	d = ho - m
	print(d)
	n = n - 1


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	a1 = 23 - a
	b1 = 60 - b
	print(a1 * 60 + b1)


num = int(input())
list1 = []
for i in range(num):
	list1.append(input().split())
for i in range(num):
	print((23 - int(list1[i][0])) * 60 + (60 - int(list1[i][1])))


n = eval(input())
i = 0
while i < n:
	(h, m) = input().split()
	(h, m) = (eval(h), eval(m))
	s = (23 - h) * 60 + (60 - m)
	print(s)
	i += 1


t = int(input())
lis = []
for i in range(t):
	n = []
	(a, b) = map(int, input().split())
	a = 23 - a
	b = 60 - b
	print(a * 60 + b)


tc = int(input())
for _ in range(tc):
	(x, y) = list(map(int, input().split(' ')))
	print(24 * 60 - (x * 60 + y))