#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t, n, l, r, x, m, L, R;
  cin >> t;
  while (t--) {
    cin >> n >> x >> m;
    L = x;
    R = x;
    for (auto i = 0; i < m; ++i) {
      cin >> l >> r;
      if (max(l, L) <= min(r, R)) {
        L = min(L, l);
        R = max(R, r);
      }
    }
    cout << R - L + 1 << '\n';
  }
  return 0;
}
