#include <bits/stdc++.h>
using namespace std;
bool isOK(long long a, long long b, long long l, long long r) {
  long long total = max(b, r) - min(a, l) + 1;
  long long sh = (b - a + 1) + (r - l + 1);
  return sh > total;
}
int main() {
  long long cs;
  scanf("%lld", &cs);
  while (cs--) {
    long long n, x, m;
    scanf("%lld", &n);
    scanf("%lld", &x);
    scanf("%lld", &m);
    long long l = x, r = x;
    while (m--) {
      long long a, b;
      scanf("%lld", &a);
      scanf("%lld", &b);
      if (isOK(a, b, l, r)) {
        l = min(a, l);
        r = max(b, r);
      }
    }
    printf("%lld\n", r - l + 1);
  }
  return 0;
}
