#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5.1e5;
void Run() {
  int n, x, m;
  cin >> n >> x >> m;
  pair<int, int> seg{x, x};
  for (int i = 0; i < m; i++) {
    int L, R;
    cin >> L >> R;
    if ((L <= seg.first && R >= seg.first) ||
        (L <= seg.second && R >= seg.second)) {
      seg = make_pair(min(seg.first, L), max(seg.second, R));
    }
  }
  cout << seg.second - seg.first + 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) Run();
  return 0;
}
