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

Difficulty: introductory

Starter code:

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

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)



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

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

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 = list(map(int, input().split()))
	return n,m
 
 
def da():
	n, m = list(map(int, input().split()))
	a = list(map(int, input().split()))
	return n,m, a 
 
 
def dva():
	n, m = list(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 = list(map(int, input().split()))
	return n,m
 
 
def da():
	n, m = list(map(int, input().split()))
	a = list(map(int, input().split()))
	return n,m, a 
 
 
def dva():
	n, m = list(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 = list(map(int, input().split()))
	print(60 * 24 - j * 60 - m)


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

#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 28/Dec/19 10:36:05 PM


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: list(map(int, sys.stdin.readline().split()))


input = lambda: sys.stdin.readline().strip()


def __starting_point():
    main()

__starting_point()

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

s = int(input())
for i in range(s):
    hh,mm = list(map(int, input().split()))
    ms = hh*60+mm
    print(24*60-ms)


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)

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

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

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


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)



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)


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

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




for _ in range(int(input())):
	h,m=map(int,input().split())

	h=60*h+m

	print(1440-h)

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

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


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


for i in range(int(input())):
    h, m = [int(a) for a in input().split()]
    print(24*60 - h*60 - 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 = list(map(int, input().split()))
    print(24 * 60 - h * 60 - m)


t = int(input())

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

t = int(input())

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


N = int(input())


for _ in range(N):
	h, m = [int(x) for x in input().split()]

	print(24*60- (h*60+m))