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