func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int INFi = 2e9;   const int maxN = 1e5 + 5;   const int md = 998244353;   const int md2 = 1e9 + 7;   double getTime() { return clock() / (double)CLOCKS_PER_SEC; };   void solve() {     int m, n;     cin >> m >> n;     vector<pair<int, int>> a(n);     for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;     sort((a).begin(), (a).end());     vector<long long> suf(n + 1);     suf[n] = 0;     suf[n - 1] = a[n - 1].first;     for (int i = n - 2; i >= 0; --i) suf[i] = suf[i + 1] + a[i].first;     long long ans = 0;     for (int i = 0; i < n; ++i) {       long long res = 0;       pair<int, int> kek = {a[i].second, -1};       int l = lower_bound((a).begin(), (a).end(), kek) - a.begin();       l = max(l, n - m);       int cnt = n - l;       res += suf[l];       if (i < l && cnt < m) {         cnt++;         res += a[i].first;       }       res += 1ll * a[i].second * (m - cnt);       ans = max(ans, res);     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int tests = 1;     cin >> tests;     for (int _ = 0; _ < tests; ++_) {       solve();     }     return 0;   }   