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