#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, m;
    cin >> n >> x >> m;
    int l = x, r = x;
    while (m--) {
      int a, b;
      cin >> a >> b;
      if ((l <= a && r >= a) || (l >= a && l <= b)) {
        l = min(a, l);
        r = max(b, r);
      }
    }
    int ans = r - l + 1;
    cout << ans << "\n";
  }
  return 0;
}
