#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e+3 + 10;
bool cmp(int a, int b) { return a < b; }
int minn(int a, int b) { return a < b ? a : b; }
int abss(int a) {
  if (a < 0)
    return -a;
  else
    return a;
}
int n, r, c, t;
int a[MAXN];
int main() {
  cin >> t;
  while (t--) {
    memset(a, 0, sizeof(a));
    cin >> n >> r >> c;
    for (int i = 1; i <= c; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + 1 + c, cmp);
    int nows = 1, min1 = 0x7fffffff;
    for (int i = 1; i <= n; i++) {
      if (a[nows] == i) {
        nows++;
        continue;
      }
      min1 = minn(min1, abss(i - r));
      if (abss(i - r) > min1) break;
    }
    cout << min1 << endl;
  }
  return 0;
}
