#include <bits/stdc++.h>
#ifdef LOCAL
#include "debuger.hpp"
#else
#define DUMP(...) 1145141919810
#define CHECK(...) (__VA_ARGS__)
#endif

const int kN = 200000 + 5;
int n, m, a, b;
int s[kN];

int solve() {
  std::sort(s, s + m);
  if (a > b) {
    a = n - a + 1;
    b = n - b + 1;
  }
  int w = std::min(m, b - a - 1);
  int t = b - 1;
  DUMP(std::vector<int>(s, s + w), t);
  int ret = 0;
  while (t > 0) {
    while (w > 0 && s[w - 1] + 1 > t) --w;
    if (w > 0) {
      --w;
      ++ret;
      --t;
    } else {
      break;
    }
  }
  return ret;
}

int main() {
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    scanf("%d%d%d%d", &n, &m, &a, &b);
    for (int i = 0; i < m; ++i) {
      scanf("%d", &s[i]);
    }
    printf("%d\n", solve());
  }
}
