#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, x, m;
    cin >> n >> x >> m;
    long long int l0 = x, r0 = x, r, l;
    long long int c = 1;
    for (long long int i = 0; i < m; i++) {
      cin >> l >> r;
      if (l <= l0 && r >= l0) {
        l0 = min(l, l0);
      }
      if (l <= r0 && r0 <= r) r0 = max(r0, r);
    }
    cout << (r0 - l0 + 1) << '\n';
  }
}
