#include <bits/stdc++.h>
using namespace std;
struct pt {
  int l, r;
};
bool cmp(pt a, pt b) { return a.l < b.l; }
pt a[200001];
int q, n, m, x, i, l, r, kq, L, R;
bool giao(int l1, int r1, int l2, int r2) {
  return (l1 <= r2 && r2 <= r1) || (l2 <= r1 && r1 <= r2) ||
         (l1 <= l2 && r2 <= r1) || (l2 <= l1 && r1 <= r2);
}
int main() {
  cin >> q;
  while (q--) {
    cin >> n >> x >> m;
    L = R = x;
    for (i = 1; i <= m; i++) {
      cin >> l >> r;
      if (giao(L, R, l, r)) {
        L = min(L, l);
        R = max(R, r);
      }
    }
    cout << R - L + 1 << '\n';
  }
}
