#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, x, m;
  cin >> n >> x >> m;
  long long cmin, cmax;
  cmin = cmax = x;
  for (long long i = 1; i <= m; i++) {
    long long l, r;
    cin >> l >> r;
    if (l > cmax || r < cmin) {
    } else {
      cmin = min(l, cmin);
      cmax = max(r, cmax);
    }
  }
  cout << cmax - cmin + 1;
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
