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