#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long ML = 4e18;
void solve() {
  int n, x, m;
  cin >> n >> x >> m;
  vector<vector<int>> v(m, vector<int>(2));
  for (int i = (0); i < (m); ++i) cin >> v[i][0] >> v[i][1];
  int ans = 0;
  int l = x, r = x;
  for (int i = (0); i < (m); ++i) {
    if (v[i][0] <= l && v[i][1] >= l || v[i][0] <= r && v[i][1] >= r) {
      l = min(l, v[i][0]);
      r = max(r, v[i][1]);
    }
  }
  cout << r - l + 1 << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  for (int kase = 1; kase <= T; ++kase) {
    solve();
  }
  return 0;
}
