#include <bits/stdc++.h>
using namespace std;
template <typename T>
void Read(T& x) {
  x = 0;
  T f = 1;
  char a = getchar();
  for (; a < '0' || '9' < a; a = getchar())
    if (a == '-') f = -f;
  for (; '0' <= a && a <= '9'; a = getchar())
    x = (x << 1) + (x << 3) + (a ^ 48);
  x *= f;
}
const int MAXN = 100010;
int T, n, x;
int ai[10010];
int main() {
  Read(T);
  while (T--) {
    cin >> n >> x;
    int cnt = 0, sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> ai[i];
      if (ai[i] != x) sum += ai[i], cnt++;
    }
    int ans = 2;
    if (!cnt) ans = min(ans, 0);
    if (cnt && sum % cnt == 0 && sum / cnt == x) ans = min(ans, 1);
    if (n - cnt) ans = min(ans, 1);
    cout << ans << endl;
  }
  return 0;
}
