#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e18;
const long long int mod = 1e9 + 7;
const long long int MOD = 998244353;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
vector<char *> tokenizer(const char *args) {
  char *token = new char[111];
  strcpy(token, args);
  token = strtok(token, ", ");
  vector<char *> v({token});
  while ((token = strtok(NULL, ", "))) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void debugg(vector<char *> args) { cerr << "\b\b "; }
#pragma clang diagnostic pop
template <typename Head, typename... Tail>
void debugg(vector<char *> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back();
  debugg(args, T...);
}
template <typename T>
bool asc(pair<T, T> &a, pair<T, T> &b) {
  if (a.first == b.first) {
    return a.second < b.second;
  }
  return a.first < b.first;
}
template <typename T>
bool desc(pair<T, T> &a, pair<T, T> &b) {
  if (a.first == b.first) {
    return a.second > b.second;
  }
  return a.first > b.first;
}
template <typename T>
T power(T a, T b) {
  if (b == 0) return 1;
  if (b == 1)
    return a;
  else {
    T res = (power(a, b / 2));
    if (b % 2) {
      return (res * res * a);
    } else {
      return res * res;
    }
  }
}
template <typename T>
T power(T a, T b, T modulo) {
  if (b == 0) return 1;
  if (b == 1)
    return a;
  else {
    T res = (power(a, b / 2, modulo) % modulo);
    if (b % 2) {
      return ((((res % modulo) * (res % modulo)) % modulo) * (a % modulo)) %
             modulo;
    } else {
      return ((res % modulo) * (res % modulo)) % modulo;
    }
  }
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
template <typename T>
void primefactorise(T n, vector<T> &vec) {
  while (n % 2 == 0) {
    vec.emplace_back(2);
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      vec.emplace_back(i);
      n = n / i;
    }
  }
  if (n > 2) {
    vec.emplace_back(n);
  }
}
template <typename T>
void all_factor(T n, vector<T> &vec) {
  for (auto i = 1; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      vec.emplace_back(i);
      if (i != (n / i)) {
        vec.emplace_back(n / i);
      }
    }
  }
}
long long mod_inv(long long a) {
  return (power<long long>(a, mod - 2, mod)) % mod;
}
void factorial(vector<long long int> &fact, long long n) {
  fact.resize(n + 1, 1);
  fact[0] = 1;
  fact[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fact[i] = ((fact[i - 1] % mod) * (i % mod)) % mod;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    long long n, x;
    cin >> n >> x;
    vector<long long int> v(n - 1 + 1);
    for (auto i = 0; i <= n - 1; i++) {
      cin >> v[i];
    };
    long long c = count((v).begin(), (v).end(), x);
    if (c == n) {
      cout << ((0)) << "\n";
      ;
      continue;
    }
    long long d = 0;
    for (int i = 0; i < n; ++i) {
      d += (x - v[i]);
    }
    if (d == 0 or c != 0) {
      cout << ((1)) << "\n";
      ;
    } else {
      cout << ((2)) << "\n";
      ;
    }
  }
  return 0;
}
