#include <bits/stdc++.h>
using namespace std;
vector<long long> prime() {
  vector<long long> v;
  for (int i = 0; i < 1000001; i++) {
    if (i % 2)
      v.push_back(1);
    else
      v.push_back(0);
  }
  for (long long i = 3; i < 1000001; i++) {
    if (v[i] == 1) {
      for (long long j = i * i; j < 1000001; j += i) v[j] = 0;
    }
  }
  v[1] = 0;
  v[2] = 1;
  return v;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, x, m, s, e, f = 0;
    cin >> n >> x >> m;
    s = x, e = x;
    for (int i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      if (((s >= a) && (s <= b)) || ((e >= a) && (e <= b))) {
        f = 1;
        if (a <= s) s = a;
        if (e <= b) e = b;
      }
    }
    cout << e - s + 1 << endl;
  }
  return 0;
}
