#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
bool visited[100005] = {false};
void solve() {
  int n, x, m;
  cin >> n >> x >> m;
  int left = -1, right = -1;
  while (m--) {
    int l, r;
    cin >> l >> r;
    if (l <= x && r >= x) {
      if (left == -1 && right == -1) {
        left = l;
        right = r;
      } else {
        if (left > l) {
          left = l;
        }
        if (right < r) {
          right = r;
        }
      }
    } else if (left != -1 && right != -1) {
      if (left <= r && l < left) {
        left = l;
      } else if (right >= l && right < r) {
        right = r;
      }
    }
  }
  cout << right - left + 1 << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
