#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, x, m;
    cin >> n >> x >> m;
    long long int l = -1, r = -1;
    for (long long int i = 0; i < m; ++i) {
      long long int left, right;
      cin >> left >> right;
      if (l == -1) {
        if ((left <= x) && (right >= x)) {
          l = left;
          r = right;
        }
      } else {
        if ((l <= right) && (r >= left)) {
          l = min(l, left);
          r = max(r, right);
        }
      }
    }
    cout << r - l + 1 << endl;
  }
  return 0;
}
