#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int h, m;     cin >> h >> m;     long long int t = h * 60 + m;     long long int a = 1440 - t;     cout << a << endl;   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     long long int t = 1;     cin >> t;     while (t--) solve();     return 0;   }   