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