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
[{"code": "a = int(input())\nfor i in range(a):\n    x, y = map(int, input().split())\n    t = x * 60 + y\n    print(24*60 - t)", "passed": true, "time": 0.28, "memory": 14148.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\ndef getInt(): return int(input())\ndef getVars(): return list(map(int, input().split()))\ndef getList(): return list(map(int, input().split()))\ndef getStr(): return input().strip()\n## -------------------------------\n\nt= getInt()\nfor _ in range(t):\n    h, m = getVars()\n    print(60*24 - h*60 - m)\n\n", "passed": true, "time": 0.2, "memory": 14216.0, "status": "done"}, {"code": "q = int(input())\nfor z in range(q):\n     a, b = map(int, input().split())\n     s = (23 - a) * 60 + (60 - b)\n     print(s)", "passed": true, "time": 0.29, "memory": 14032.0, "status": "done"}, {"code": "n = int(input())\nfor i in range(n):\n    a, b = map(int, input().split())\n    print(24 * 60 - a * 60 - b)", "passed": true, "time": 0.16, "memory": 14288.0, "status": "done"}, {"code": "import math\nfrom decimal import Decimal\nimport heapq\nfrom collections import deque\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn n,b\n \n \ndef nab():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tc = [int(x) for x in input().split()]\n\treturn n,b,c\n \n \ndef dv():\n\tn, m = list(map(int, input().split()))\n\treturn n,m\n \n \ndef da():\n\tn, m = list(map(int, input().split()))\n\ta = list(map(int, input().split()))\n\treturn n,m, a \n \n \ndef dva():\n\tn, m = list(map(int, input().split()))\n\ta = [int(x) for x in input().split()]\n\tb = [int(x) for x in input().split()]\n\treturn n,m,b\n \n \ndef eratosthenes(n): \n\tsieve = list(range(n + 1))\n\tfor i in sieve:\n\t\tif i > 1:\n\t\t\tfor j in range(i + i, len(sieve), i):\n\t\t\t\tsieve[j] = 0\n\treturn sorted(set(sieve))\n \n \ndef lol(lst,k):\n\tk=k%len(lst)\n\tret=[0]*len(lst)\n\tfor i in range(len(lst)):\n\t\tif i+k<len(lst) and i+k>=0:\n\t\t\tret[i]=lst[i+k]\n\t\tif i+k>=len(lst):\n\t\t\tret[i]=lst[i+k-len(lst)]\n\t\tif i+k<0:\n\t\t\tret[i]=lst[i+k+len(lst)]\n\treturn(ret)\ndef nm():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tm = int(input())\n\tc = [int(x) for x in input().split()]\n\treturn n,b,m,c\n \n \ndef dvs():\n\tn = int(input())\n\tm = int(input())\n\treturn n, m \n \n\ndef fact(a, b):\n\tc = []\n\tans = 0\n\tf = int(math.sqrt(a))\n\tfor i in range(1, f + 1):\n\t\tif a % i == 0:\n\t\t\tc.append(i)\n\tl = len(c)\n\tfor i in range(l):\n\t\tc.append(a // c[i])\n\tfor i in range(len(c)):\n\t\tif c[i] <= b:\n\t\t\tans += 1\n\tif a / f == f and b >= f:\n\t\treturn ans - 1\n\treturn ans\n\n\nimport math\nfrom decimal import Decimal\nimport heapq\nfrom collections import deque\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn n,b\n \n \ndef nab():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tc = [int(x) for x in input().split()]\n\treturn n,b,c\n \n \ndef dv():\n\tn, m = list(map(int, input().split()))\n\treturn n,m\n \n \ndef da():\n\tn, m = list(map(int, input().split()))\n\ta = list(map(int, input().split()))\n\treturn n,m, a \n \n \ndef dva():\n\tn, m = list(map(int, input().split()))\n\ta = [int(x) for x in input().split()]\n\tb = [int(x) for x in input().split()]\n\treturn n,m,b\n \n \ndef eratosthenes(n): \n\tsieve = list(range(n + 1))\n\tfor i in sieve:\n\t\tif i > 1:\n\t\t\tfor j in range(i + i, len(sieve), i):\n\t\t\t\tsieve[j] = 0\n\treturn sorted(set(sieve))\n \n \ndef lol(lst,k):\n\tk=k%len(lst)\n\tret=[0]*len(lst)\n\tfor i in range(len(lst)):\n\t\tif i+k<len(lst) and i+k>=0:\n\t\t\tret[i]=lst[i+k]\n\t\tif i+k>=len(lst):\n\t\t\tret[i]=lst[i+k-len(lst)]\n\t\tif i+k<0:\n\t\t\tret[i]=lst[i+k+len(lst)]\n\treturn(ret)\ndef nm():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tm = int(input())\n\tc = [int(x) for x in input().split()]\n\treturn n,b,m,c\n \n \ndef dvs():\n\tn = int(input())\n\tm = int(input())\n\treturn n, m \n \n \ndef fact(a, b):\n\tc = []\n\tans = 0\n\tf = int(math.sqrt(a))\n\tfor i in range(1, f + 1):\n\t\tif a % i == 0:\n\t\t\tc.append(i)\n\tl = len(c)\n\tfor i in range(l):\n\t\tc.append(a // c[i])\n\tfor i in range(len(c)):\n\t\tif c[i] <= b:\n\t\t\tans += 1\n\tif a / f == f and b >= f:\n\t\treturn ans - 1\n\treturn ans\n \n \nfor i in range(int(input())):\n\tj, m = list(map(int, input().split()))\n\tprint(60 * 24 - j * 60 - m)\n", "passed": true, "time": 0.15, "memory": 14748.0, "status": "done"}, {"code": "q=int(input())\nfor i in range(q):\n    w,e=map(int,input().split())\n    print((23-w)*60+60-e)", "passed": true, "time": 0.2, "memory": 14288.0, "status": "done"}, {"code": "#!/usr/bin/env python3\n# coding: utf-8\n# Last Modified: 28/Dec/19 10:36:05 PM\n\n\nimport sys\n\n\ndef main():\n    x = 24 * 60\n    for tc in range(int(input())):\n        h, m = get_ints()\n        y = h * 60 + m\n        print(x - y)\n\n\nget_array = lambda: list(map(int, sys.stdin.readline().split()))\n\n\nget_ints = lambda: list(map(int, sys.stdin.readline().split()))\n\n\ninput = lambda: sys.stdin.readline().strip()\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.29, "memory": 14204.0, "status": "done"}, {"code": "for __ in range(int(input())):\n    a, b = list(map(int, input().split()))\n    print(24 * 60 - a * 60 - b)", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "s = int(input())\nfor i in range(s):\n    hh,mm = list(map(int, input().split()))\n    ms = hh*60+mm\n    print(24*60-ms)\n", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "def ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi()) \n\nimport math\n\n\nfor i in range(ii()):\n    h,m=mi()\n    ans=1440-(h*60+m)\n    print(ans)", "passed": true, "time": 0.14, "memory": 14300.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    h, m = list(map(int,input().split()))\n    print(1440 - (h*60 + m))", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "#list(map(int, input().split()))\nfor _ in range(int(input())):\n\th, m = list(map(int, input().split()))\n\tprint(24 * 60 - h * 60 - m)", "passed": true, "time": 0.19, "memory": 14236.0, "status": "done"}, {"code": "t = int(input())\nfor i in range(t):\n\tn, s = list(map(int, input().split()))\n\tprint(24 * 60 - n * 60 - s)\n", "passed": true, "time": 0.26, "memory": 14288.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\nt=int(input())\nfor test in range(t):\n    h,w=list(map(int,input().split()))\n\n    print(24*60-h*60-w)\n\n", "passed": true, "time": 0.28, "memory": 14104.0, "status": "done"}, {"code": "t = int(input())\nfor i in range(t):\n\thh = 23\n\tmm = 60\n\th, m = list(map(int, input().split()))\n\tprint((hh - h) * 60 + mm - m)\n", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    h, m = tuple(map(int, input().split()))\n    print(1440 - h*60 - m)", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn list(map(int, minp().split()))\n\ndef solve():\n\ta, b = mints()\n\tprint(24*60-a*60-b)\n\nfor i in range(mint()):\n\tsolve()\n", "passed": true, "time": 0.21, "memory": 14300.0, "status": "done"}, {"code": "\n\nfor _ in range(int(input())):\n\th,m=map(int,input().split())\n\n\th=60*h+m\n\n\tprint(1440-h)", "passed": true, "time": 0.96, "memory": 14184.0, "status": "done"}, {"code": "for nt in range(int(input())):\n\th,m=map(int,input().split())\n\tprint ((23-h)*60+(60-m))", "passed": true, "time": 0.31, "memory": 14060.0, "status": "done"}, {"code": "import sys\n# from collections import defaultdict\nt=1\nt=int(input())\nfor i in range(t):\n    n,m=list(map(int,sys.stdin.readline().strip().split()))\n    # a=list(map(int,sys.stdin.readline().strip().split()))\n    # b=list(map(int,sys.stdin.readline().strip().split()))\n    # d = defaultdict(int)\n    print((24-n-1)*60+60-m)\n    \n", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "q = int(input())\nfor i in range(q):\n    h, m = list(map(int, input().split()))\n    print(24 * 60 - h * 60 - m)\n", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "for i in range(int(input())):\n    h, m = [int(a) for a in input().split()]\n    print(24*60 - h*60 - m)\n", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "from sys import stdin,stdout\nn=int(stdin.readline().strip())\nfor t in range(n):\n    h,c=list(map(int,stdin.readline().strip().split()))\n    ans=0\n    if c!=0:\n        ans+=60-c\n        h+=1\n    ans+=(24-h)*60\n    print(ans)\n        \n\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "t = int(input())\nfor i in range(t):\n    h, m = list(map(int, input().split()))\n    print(24 * 60 - h * 60 - m)\n", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "t = int(input())\n\nfor i in range(t):\n    h , m = map(int , input().split())\n    \n    total = 24*60 - h*60 - m\n    \n    print(total)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "t = int(input())\n\nfor i in range(t):\n\ta, b = list(map(int, input().split()))\n\tans = (23  - a) * 60 + (60 - b)\n\tprint(ans)\n", "passed": true, "time": 0.2, "memory": 14104.0, "status": "done"}, {"code": "N = int(input())\n\n\nfor _ in range(N):\n\th, m = [int(x) for x in input().split()]\n\n\tprint(24*60- (h*60+m))", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}]