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