#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, x, m;
    cin >> n >> x >> m;
    int l = x, r = x;
    while (m--) {
      int a, b;
      cin >> a >> b;
      if (l > b || r < a) continue;
      l = min(l, a);
      r = max(r, b);
    }
    cout << r - l + 1 << '\n';
  }
}
