#include <bits/stdc++.h>
using namespace std;
double const pi = 3.1415926536;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, x, m;
    cin >> n >> x >> m;
    int l[m], r[m], a = x, b = x;
    for (int i = 0; i < m; i++) cin >> l[i] >> r[i];
    for (int i = 0; i < m; i++) {
      if (l[i] <= a && r[i] >= a) {
        if (a == 0)
          a = l[i];
        else
          a = min(l[i], a);
      }
      if (l[i] <= b && r[i] >= b) {
        b = max(r[i], b);
      }
    }
    cout << b - a + 1 << endl;
  }
}
