#include <bits/stdc++.h>
using namespace std;
void no() { cout << "No\n"; }
void yes() { cout << "Yes\n"; }
void solve() {
  int n, m, x;
  cin >> n >> x >> m;
  int l, r;
  x--;
  int mn = x, mx = x;
  for (long long i = 0; i < m; i++) {
    cin >> l >> r;
    l--, r--;
    if (l <= mn && r >= mn) {
      mn = l;
    }
    if (l <= mx && r >= mx) {
      mx = r;
    }
  }
  cout << mx - mn + 1 << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  ;
  while (T--) solve();
  return 0;
}
