#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m, x, l, r, L = -1, R = -1;
  cin >> n >> x >> m;
  for (long long i = 0; i < m; i++) {
    cin >> l >> r;
    if ((l <= x && x <= r) || !(r < L || l > R)) {
      if (L == -1)
        L = l;
      else
        L = min(L, l);
      if (R == -1)
        R = r;
      else
        R = max(R, r);
    }
  }
  printf("%lld\n", R - L + 1);
}
int main() {
  long long t;
  cin >> t;
  while (t--) solve();
}
