#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void inout() {}
int main() {
  fast();
  inout();
  int t;
  cin >> t;
  while (t--) {
    long long int n, x, m;
    cin >> n >> x >> m;
    int i = 0;
    long long int l = 0, r = 0;
    map<long long int, int> v;
    long long int ans = 0;
    while (m--) {
      long long int c, d;
      cin >> c >> d;
      if (i == 0) {
        l = c, r = d;
        if (c <= x && d >= x) v[l] = 1, v[r] = 1, ans += (r - l + 1);
      } else {
        if (v[l] == 1 && v[r] == 1) {
          if (c <= l && d >= l) ans += (l - c), l = min(l, c);
          if (d >= r && c <= r) ans += (d - r), r = max(d, r);
          v[l] = 1, v[r] = 1;
        } else if (c <= x && d >= x) {
          l = c, r = d;
          if (c <= x && d >= x) v[l] = 1, v[r] = 1, ans += (r - l + 1);
        }
      }
      i++;
    }
    if (!ans) ans = 1;
    cout << ans << "\n";
  }
}
