#include <bits/stdc++.h>
using namespace std;
const long long rem = (long long)1e9 + 7;
int t, n, c, k, a, b, x, m, l, r;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n >> x >> m;
    int minl = -1, maxr = -1;
    int ans;
    for (int i = 1; i <= m; i++) {
      cin >> l >> r;
      if (i == 1) {
        if (x >= l && x <= r) {
          minl = l, maxr = r;
        }
      } else {
        if (minl == -1) {
          if (l > x || r < x) continue;
          minl = l;
          maxr = r;
        } else {
          if (l > maxr || r < minl) continue;
          minl = min(minl, l);
          maxr = max(maxr, r);
        }
      }
    }
    cout << maxr - minl + 1 << "\n";
  }
  return 0;
}
