#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int n, x, m;
pair<int, int> p[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int Q;
  cin >> Q;
  while (Q--) {
    cin >> n >> x >> m;
    for (int i = 1; i <= m; i++) cin >> p[i].first >> p[i].second;
    int l = x, r = x;
    for (int i = 1; i <= m; i++) {
      if (p[i].second >= l) l = min(l, p[i].first);
      if (p[i].first <= r) r = max(r, p[i].second);
    }
    cout << max(0, r - l + 1) << '\n';
  }
  return 0;
}
