#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long long int RUN = 32;
void pend(long long int x) { cout << x << endl; }
void pr1(long long int x) { cout << x; }
void pr2(long long int x) { cout << x << " "; }
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int max(long long int a, long long int b) {
  if (a > b)
    return a;
  else
    return b;
}
long long int min(long long int a, long long int b) {
  if (a < b)
    return a;
  else
    return b;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, x, m;
    cin >> n >> x >> m;
    long long int a[m], b[m];
    long long int l = x, r = x;
    for (long long int i = 0; i < m; i++) {
      cin >> a[i] >> b[i];
    }
    for (long long int i = 0; i < m; i++) {
      if (a[i] > r || b[i] < l) continue;
      if (a[i] < l && b[i] > r) {
        r = b[i];
        l = a[i];
        continue;
      }
      if (a[i] < l && b[i] <= r) {
        l = a[i];
        continue;
      }
      if (a[i] >= l && b[i] > r) {
        r = b[i];
        continue;
      }
    }
    cout << r - l + 1 << endl;
  }
}
