#include <bits/stdc++.h>
using namespace std;
long long oo = 1000000000000000000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  int q;
  cin >> q;
  while (q--) {
    int n, x, m;
    cin >> n >> x >> m;
    int cL = x, cr = x;
    while (m--) {
      int L, r;
      cin >> L >> r;
      if (L > cr || r < cL) continue;
      cr = max(cr, r);
      cL = min(cL, L);
    }
    cout << cr - cL + 1 << endl;
  }
  return 0;
}
