#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, x, m, mx, mn;
    cin >> n >> x >> m;
    mx = mn = x;
    while (m--) {
      int l, r;
      cin >> l >> r;
      if ((l <= mn and mn <= r) or (l <= mx and mx <= r))
        mn = min(mn, l), mx = max(mx, r);
    }
    cout << mx - mn + 1 << '\n';
  }
  return 0;
}
