#include <bits/stdc++.h>
using namespace std;
int calc(set<pair<int, int> > intervals) {
  set<pair<int, int> >::iterator it;
  int l, r;
  l = r = -1;
  int ret = 0;
  int c = 0;
  for (it = intervals.begin(); it != intervals.end(); it++) {
    if (l == -1) {
      l = it->first;
      r = it->second;
    } else {
      if (it->first <= r)
        r = max(r, it->second);
      else {
        ret += r - l + 1;
        l = it->first;
        r = it->second;
      }
    }
  }
  ret += r - l + 1;
  return ret;
}
int main() {
  int t, n, m, x, l, r;
  cin >> t;
  while (t--) {
    cin >> n >> x >> m;
    int curl, curr;
    curl = curr = -1;
    set<pair<int, int> > s;
    for (int i = 1; i <= m; i++) {
      cin >> l >> r;
      if (curl != -1) {
        if (max(curl, l) <= min(curr, r)) {
          curl = min(curl, l);
          curr = max(curr, r);
        }
      } else {
        if (x >= l && x <= r) {
          curl = l;
          curr = r;
        }
      }
    }
    cout << curr - curl + 1 << "\n";
  }
  return 0;
}
