#include <bits/stdc++.h>
int main() {
  int T;
  scanf("%d", &T);
  while (T > 0) {
    long n, x, m, i, j, BI = 0, BS = 0, R, L;
    scanf("%ld%ld%ld", &n, &x, &m);
    j = 0;
    do {
      scanf("%ld%ld", &L, &R);
      j++;
    } while (!((x >= L) && (x <= R)) && (j < m));
    if ((x >= L) && (x <= R)) {
      BI = L;
      BS = R;
    }
    for (i = j; i < m; i++) {
      scanf("%ld%ld", &L, &R);
      if ((L < BI) && (R >= BI)) BI = L;
      if ((R > BS) && (L <= BS)) BS = R;
    }
    printf("%ld\n", BS - BI + 1);
    T--;
  }
  return 0;
}
