#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using vvi = vector<vi>;
using mii = map<long long, long long>;
using vmii = vector<mii>;
using pii = pair<long long, long long>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
template <typename T, typename U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& o, const map<T, U>& m) {
  o << "{";
  for (const pair<T, U>& p : m) o << p.first << ": " << p.second << ",";
  return o << "}";
}
template <typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v) o << x << ",";
  return o << "]";
}
template <typename T>
ostream& operator<<(ostream& o, const vector<vector<T>>& v) {
  o << "[";
  for (const vector<T>& x : v) o << x << ",\n";
  return o << "]";
}
constexpr long long INF = 1e18;
long long solve() {
  long long n, x;
  cin >> n >> x;
  vi as(n);
  for (long long& ai : as) cin >> ai;
  bool allequal = true;
  bool someequal = false;
  long long sum = 0;
  for (long long ai : as) {
    if (ai != x)
      allequal = false;
    else
      someequal = true;
    sum += ai;
  }
  if (allequal) return 0;
  if (sum == n * x || someequal) return 1;
  return 2;
}
signed main() {
  long long t;
  cin >> t;
  for (long long tc = 1; tc <= t; ++tc) {
    cout << solve() << "\n";
  }
}
