#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, x, m;
    cin >> n >> x >> m;
    int s = x, e = x;
    while (m--) {
      int a, b;
      cin >> a >> b;
      if (a <= s && s <= b || a <= e && e <= b) {
        s = min(s, a);
        e = max(e, b);
      }
    }
    cout << e - s + 1 << "\n";
  }
  return 0;
}
