#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 9;
const int MaxM = 100005;
void solveA() {
  string s;
  cin >> s;
  s += 'c';
  int n = s.size();
  vector<int> v;
  int d = 0, e = 0, s1 = 0, s2 = 0, s3 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'b') {
      d++;
      s1 = max(s1, d);
    } else {
      d = 0;
    }
    if (s[i] == 'a') {
      e++;
      s2 = max(s2, e);
    } else {
      v.push_back(e);
      e = 0;
    }
  }
  sort(v.begin(), v.end());
  if (v.size() >= 2) {
    s3 = v[v.size() - 2];
  }
  cout << s1 + s2 + s3;
}
void solve() {
  int n;
  cin >> n;
  int m, x;
  cin >> x >> m;
  int ans, a = x, b = x;
  vector<pair<int, int>> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i].first;
    cin >> v[i].second;
  }
  for (int i = 0; i < m; i++) {
    if (v[i].first <= a && v[i].second >= a) {
      a = v[i].first;
    }
    if (v[i].second >= b && v[i].first <= b) {
      b = v[i].second;
    }
  }
  ans = b - a + 1;
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<pair<int, int>> v;
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
