#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535897932384626;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, x, m;
    cin >> n >> x >> m;
    long long int l = x, r = x;
    while (m--) {
      long long int a, b;
      cin >> a >> b;
      if (a <= l && b >= r || (a <= l && (b <= r && b >= l)) ||
          ((a >= l && a <= r) && b >= r)) {
        l = min(l, a);
        r = max(r, b);
      }
    }
    cout << r - l + 1 << "\n";
  }
  return 0;
}
