#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, x, m;
    cin >> n >> x >> m;
    long long l = x, r = x, a, b, i;
    for (i = 0; i < m; i++) {
      cin >> a >> b;
      if (a <= l && b >= l) l = a;
      if (a <= r && b >= r) r = b;
    }
    cout << r - l + 1 << endl;
  }
}
