#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int maxn = 1e2 + 10;
const double eps = 1e-6;
int di[8][2] = {{-1, 0},  {1, 0},  {0, -1}, {0, 1},
                {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
inline long long rd() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int n;
int x[maxn];
int c[maxn];
int l[maxn];
int r[maxn];
int find1(int p) {
  int ans = 1000;
  for (int i = 1; i < p; i++) {
    if (x[i] > x[p] && x[i] < ans) ans = x[i];
  }
  if (ans == 1000) ans = 0;
  return ans;
}
int find2(int p) {
  int ans = 0;
  for (int i = p + 1; i <= n; i++) {
    if (x[i] < x[p] && x[i] > ans) ans = x[i];
  }
  return ans;
}
bool check() {
  for (int i = 1; i <= n; i++) x[i] = c[i];
  for (int i = 1; i <= n; i++) {
    l[i] = find1(i);
    r[i] = find2(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (l[i] == 0 || r[j] == 0) continue;
      if (l[i] < r[j]) return 1;
    }
  }
  for (int i = 1; i <= n; i++) x[i] = c[n - i + 1];
  for (int i = 1; i <= n; i++) {
    l[i] = find1(i);
    r[i] = find2(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (l[i] == 0 || r[j] == 0) continue;
      if (l[i] < r[j]) return 1;
    }
  }
  return 0;
}
long long fac[maxn] = {1};
unordered_map<long long, long long> mp;
signed main() {
  long long t = rd();
  while (t--) {
    mp.clear();
    long long n = rd(), s = rd(), k = rd();
    while (k--) {
      mp[rd()] = 1;
    }
    long long ans = INF;
    for (long long i = s; i >= max(s - 1100, 1ll); i--) {
      if (!mp.count(i)) {
        ans = min(ans, abs(s - i));
      }
    }
    for (long long i = s; i <= min(s + 1100, n); i++) {
      if (!mp.count(i)) {
        ans = min(ans, abs(s - i));
      }
    }
    printf("%lld\n", ans);
  }
}
