#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, x, m, c, d, l, r;
  long long ans = 0;
  bool flag = false;
  cin >> n >> x >> m;
  l = x;
  r = x;
  while (m--) {
    cin >> c >> d;
    if (!flag) {
      if (x >= c && x <= d) {
        flag = true;
        ans += d - c + 1;
        l = c;
        r = d;
      }
    } else {
      if (c <= l && d >= r) {
        ans += l - c;
        ans += d - r;
        l = c;
        r = d;
      } else if (c >= l && c <= r && d >= r) {
        ans += d - r;
        r = d;
      } else if (c <= l && d <= r && d >= l) {
        ans += l - c;
        l = c;
      } else
        continue;
    }
  }
  if (!flag) ans = 1;
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
