#include <bits/stdc++.h>
using namespace std;
template <typename a>
void SWAP(a &b, a &c) {
  a d = b;
  b = c;
  c = d;
}
long long power(long long a, long long b) {
  long long result = 1;
  while (b) {
    if (b & 1) result = a * result;
    a *= a;
    b >>= 1;
  }
  return result;
}
long long gcd(long long a, long long b) {
  while (b) {
    a = a % b;
    SWAP(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
long long check_double_equality(double a, double b) {
  double c = (((a - b) > 0) ? (a - b) : (-(a - b)));
  if (c < 1e-9)
    return true;
  else
    return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, x, m;
    cin >> n >> x >> m;
    long long l, r;
    long long left = 1, right = 1;
    bool one_found = false;
    for (long long i = 0; i < m; i++) {
      cin >> l >> r;
      if (l <= x && x <= r && !one_found) {
        left = l;
        right = r;
        one_found = true;
      }
      if (one_found) {
        if ((left <= l && l <= right) || (left <= r && r <= right) ||
            (l <= left && left <= r) || (l <= right && right <= r)) {
          left = (((left) < (l)) ? (left) : (l));
          right = (((right) > (r)) ? (right) : (r));
        }
      }
    }
    long long ans = right - left + 1;
    cout << (ans) << '\n';
  }
  return 0;
}
