#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, x, m, a, b, mx, mi;
  cin >> n >> x >> m;
  mx = x;
  mi = x;
  int ans = 1;
  for (long long i = (0); i < (m); ++i) {
    cin >> a >> b;
    if (a <= mi && b >= mx) {
      ans = b - a + 1;
      mi = a;
      mx = b;
    } else if (a <= mi && b >= mi) {
      ans = max(mx, b) - min(a, mi) + 1;
      mi = min(a, mi);
      mx = max(mx, b);
    } else if (a <= mx && b >= mx) {
      ans = max(mx, b) - min(a, mi) + 1;
      mi = min(a, mi);
      mx = max(mx, b);
    }
  }
  cout << ans;
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  cin >> test;
  while (test--) solve();
}
