#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t, n, x, m;
  cin >> t;
  while (t--) {
    cin >> n >> x >> m;
    long long idx = x, low = INT_MAX, high = INT_MIN, idx2 = x;
    while (m--) {
      long long l, r;
      cin >> l >> r;
      if ((idx >= l && idx <= r) || (idx2 >= l && idx2 <= r)) {
        low = min(low, l);
        high = max(high, r);
        idx = low;
        idx2 = high;
      }
    }
    if (high == INT_MIN && low == INT_MAX) {
      cout << 1 << endl;
      continue;
    }
    cout << high - low + 1 << endl;
  }
  return 0;
}
