#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long t, n, i, j, k, l, r, minn, maxx, ans, x, y;     cin >> t;     while (t--) {       cin >> n;       cin >> maxx >> minn;       for (i = 1; i < n; i++) {         cin >> x >> y;         maxx = max(maxx, x);         minn = min(minn, y);       }       if (maxx <= minn)         ans = 0;       else         ans = maxx - minn;       cout << ans <<   n ;     }     return 0;   }   