#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
void solve() {
  long long n, x, m;
  cin >> n >> x >> m;
  vector<pair<long long, long long> > a(m);
  for (long long i = 0; i < m; i++) {
    cin >> a[i].first;
    cin >> a[i].second;
  }
  long long i = 0;
  while (i < m && (x < a[i].first || x > a[i].second)) {
    i++;
  }
  if (i == m) {
    cout << 1 << "\n";
    return;
  }
  long long lo = a[i].first, hi = a[i].second;
  i++;
  for (; i < m; i++) {
    if (a[i].first >= lo && a[i].second <= hi) {
      continue;
    } else if (a[i].first <= lo && a[i].second >= hi) {
      lo = a[i].first, hi = a[i].second;
    } else if (a[i].first <= lo && a[i].second <= hi && a[i].second >= lo) {
      lo = a[i].first;
    } else if (a[i].first >= lo && a[i].first <= hi && a[i].second >= hi)
      hi = a[i].second;
    else {
      continue;
    }
  }
  cout << max(1ll, hi - lo + 1) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
