#include <bits/stdc++.h>
using namespace std;
double pi = acos(-1);
void OJ() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long tp;
  cin >> tp;
  while (tp--) {
    long long n, m, x, c = 0;
    cin >> n >> x >> m;
    long long l = x, r = x;
    while (m--) {
      long long a, b;
      cin >> a >> b;
      if ((a <= l and b >= l) or (r <= b and r >= a)) {
        l = min(l, a);
        r = max(r, b);
      }
    }
    cout << (r - l + 1) << endl;
  }
}
