#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, mm, x;
    int l, r;
    cin >> n >> x >> mm;
    int m = x, M = x;
    for (int i = 0; i < mm; i++) {
      cin >> l >> r;
      if ((r >= m && r <= M) || (l >= m && l <= M) || (l <= m && r >= M)) {
        if (M < r) M = r;
        if (m > l) m = l;
      }
    }
    cout << M - m + 1 << endl;
  }
}
