#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  long long n, x, m;
  cin >> n >> x >> m;
  long long l, r;
  long long a = x;
  long long b = x;
  for (long long i = 0; i < m; i++) {
    cin >> l >> r;
    if ((l <= a and a <= r) or (l <= b and b <= r)) {
      a = min(a, l);
      b = max(b, r);
    } else {
    }
  }
  cout << b - a + 1 << "\n";
  return;
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
