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