#include <bits/stdc++.h>
long long int m = 998244353;
using namespace std;
struct obj {
  int l;
  int r;
  bool pres;
};
bool compare(obj a, obj b) { return a.l <= b.l; }
void solve() {
  long long int n, x, m, li, ri;
  cin >> n >> x >> m;
  vector<obj> arr;
  long long int count = 0;
  for (int i = 0; i < m; i++) {
    cin >> li >> ri;
    obj o;
    o.l = li;
    o.r = ri;
    o.pres = false;
    if (x >= li && x <= ri) o.pres = true;
    for (int j = 0; j < i; j++) {
      if (arr[j].pres) {
        if (!(ri < arr[j].l || arr[j].r < li)) {
          o.pres = true;
          break;
        }
      }
    }
    arr.push_back(o);
  }
  sort(arr.begin(), arr.end(), compare);
  long long int l = -1, r = -1;
  for (int i = 0; i < m; i++) {
    if (!arr[i].pres) continue;
    if (arr[i].l > r)
      count += arr[i].r - arr[i].l + 1;
    else if (arr[i].r <= r)
      count += 0;
    else
      count += arr[i].r - r;
    l = arr[i].l;
    if (arr[i].r > r) r = arr[i].r;
  }
  if (count == 0) count = 1;
  cout << count << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
