#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, x, m, i, high, low, a, b;
    cin >> n >> x >> m;
    low = x;
    high = x;
    for (i = 0; i < m; i++) {
      cin >> a >> b;
      if (a <= low && b >= low) low = a;
      if (a <= high && b >= high) high = b;
    }
    cout << high - low + 1 << endl;
  }
  return 0;
}
