func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long ti;     cin >> ti;     for (long long io = 0; io < ti; io++) {       long long n, m;       cin >> n >> m;       vector<long long> a, ao, b;       for (long long i = 0; i < m; i++) {         long long x, y;         cin >> x >> y;         a.push_back(x);         ao.push_back(x);         b.push_back(y);       }       sort(a.begin(), a.end());       long long sf[m + 1];       long long sm = 0;       for (long long i = m - 1; i >= 0; i--) {         sm += a[i];         sf[m - i] = sm;       }       long long ans = 0;       if (n <= m) ans = sf[n];       for (long long i = 0; i < m; i++) {         long long v = b[i];         long long idx = upper_bound(a.begin(), a.end(), v) - a.begin() + 1;         long long avl = m - idx + 1;         if (idx > m) {           ans = max(ans, ao[i] + (n - 1) * b[i]);         } else if (avl < n) {           long long as = 0;           as = as + sf[avl];           long long rm = n - avl;           if (ao[i] <= b[i]) {             as += ao[i];             rm--;           }           as += rm * b[i];           ans = max(ans, as);         }       }       cout << ans << endl;     }     return 0;   }   