#include<bits/stdc++.h>

using namespace std;

long long soma(long long x){
    return x*(x+1)/2;
}

void solve(){
    int n;
    cin >> n;
    long long res =0 ;

    for(int i = 0; i < n; ++i){
        long long a, b;
        cin >> a >> b;
        res += soma(b) - soma(a-1);
    }
    cout << res;
}

int main(){
    cin.tie(0)->sync_with_stdio(false);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    //cin >> t;
    while(t--) solve();

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;

int int_min = -2147483648;
int int_max = 2147483647;

int n;
char s1[N], s2[N], s3[N];

void solve() {
  cin >> n;
  scanf("%s", s1), scanf("%s", s2), scanf("%s", s3);
  for(int i = 0; i < n; i++) putchar('1');
  for(int i = 0; i < n; i++) putchar('0');
  puts("1");
}

int main() {
    int t;
    cin >> t;
    while (t--) solve();
  return 0;
}