#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, m1;
    cin >> n >> x >> m1;
    int res = 0;
    int flag = 0;
    int s = -1;
    int e = -1;
    for (int i = 0; i < m1; i++) {
      int a, b;
      cin >> a >> b;
      if ((x >= a && x <= b) && flag == 0) {
        res += b - a + 1;
        flag = 1;
        s = a;
        e = b;
      } else {
        if (a < s && b > e) {
          s = a;
          e = b;
        } else if (s <= a && b > e && e >= a) {
          e = b;
        } else if (s > a && s <= b && e >= b) {
          s = a;
        }
      }
    }
    if (s == -1) {
      cout << 1 << endl;
    } else
      cout << e - s + 1 << endl;
  }
}
