#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, m, x;
    cin >> n >> x >> m;
    long long lowest = 0, highest = 0, ans = 0, flag = 0;
    for (int i = 0; i < m; i++) {
      long long l, d;
      cin >> l >> d;
      if (flag == 0) {
        if (l > x || d < x) {
        } else {
          lowest = l;
          highest = d;
          flag = 1;
        }
      } else {
        if (highest >= l && l >= lowest) {
          if (d > highest) {
            highest = d;
          }
        } else if (highest >= d && d >= lowest) {
          if (l < lowest) {
            lowest = l;
          }
        } else if (highest < d && lowest > l) {
          lowest = l;
          highest = d;
        }
      }
    }
    cout << highest - lowest + 1 << endl;
  }
}
