#include <bits/stdc++.h>
using namespace std;
int solve(vector<int>& a, int n, int s) {
  int idx = -1;
  int k = a.size();
  for (int i = 0; i < k; i++) {
    if (a[i] == s) idx = i;
  }
  if (idx == -1) return 0;
  int r = idx, l = idx;
  while (r + 1 < k && a[r + 1] == a[r] + 1) r++;
  while (l - 1 >= 0 && a[l - 1] == a[l] - 1) l--;
  int upSteps = a[r] - a[idx] + 1;
  int dSteps = a[idx] - a[l] + 1;
  if (a[idx] - dSteps <= 0) {
    dSteps = -1;
  }
  if (a[idx] + upSteps > n) upSteps = -1;
  if (dSteps == -1)
    return upSteps;
  else if (upSteps == -1)
    return dSteps;
  return min(upSteps, dSteps);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, s, k;
    cin >> n >> s >> k;
    vector<int> a(k, 0);
    for (int i = 0; i < k; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << solve(a, n, s) << endl;
  }
  return 0;
}
