func_code_string: #include <bits/stdc++.h>   using namespace std;   int t;   long long b[3000000];   pair<long long, long long> a[3000000];   int main() {     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 0; i < n; ++i) {         scanf( %lld%lld , &a[i].first, &a[i].second);       }       for (int i = 0; i < n; ++i) {         b[(i + 1) % n] = a[(i + 1) % n].first - a[i].second;       }       long long ans = a[0].first, anw = 1e18;       for (int i = 1; i < n; ++i) {         if (b[i] > 0) {           ans += b[i];         }       }       anw = min(ans, anw);       for (int i = 1; i < n; ++i) {         ans -= a[i - 1].first;         if (b[i] > 0) {           ans -= b[i];         }         ans += a[i].first;         if (b[i - 1] > 0) {           ans += b[i - 1];         }         anw = min(ans, anw);       }       printf( %lld n , anw);     }     return 0;   }   