#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250005;
using lint = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lint tt;
  cin >> tt;
  while (tt--) {
    lint n, x, m, ans = 0;
    cin >> n >> x >> m;
    lint l = x, h = x;
    while (m--) {
      lint a, b;
      cin >> a >> b;
      if (b < l || a > h) {
        continue;
      } else {
        h = max(h, b);
        l = min(l, a);
      }
    }
    cout << h - l + 1 << endl;
  }
  return 0;
}
