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