#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, x, m;
    cin >> n >> x >> m;
    long long c, d;
    long long l = x, r = x;
    while (m--) {
      cin >> c >> d;
      if (c <= l && d >= r) {
        l = c;
        r = d;
      } else if (c <= l && d <= r && d >= l)
        l = c;
      else if (l <= c && c <= r && d >= r)
        r = d;
    }
    cout << (r - l + 1) << '\n';
  }
  return 0;
}
