#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const int MXS = 2e5 + 5;
const int MXI = 1e9 + 5;
const long long MXL = 1e15 + 5;
const int INF = 1e9 + 5;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long comb(long long a, long long b) {
  long long x = max(a - b, b), ans = 1;
  for (long long K = a, L = 1; K >= x + 1; K--, L++) {
    ans *= K;
    ans /= L;
  }
  return ans;
}
void task() {
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    int ara[n];
    int tot = 0;
    bool ok = 1, not_ok = 0;
    for (int K = 0; K < n; K++) {
      cin >> ara[K];
      tot += ara[K];
      if (ara[K] != x) ok = 0;
      if (ara[K] == x) not_ok = 1;
    }
    if (ok) {
      cout << 0 << "\n";
      continue;
    }
    if (not_ok) {
      cout << 1 << "\n";
    } else if (tot == n * x) {
      cout << 1 << "\n";
    } else
      cout << 2 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  task();
  return 0;
}
