#include <bits/stdc++.h>
using namespace std;
long long int mod1 = 998244353, mod2 = (long long int)1e9 + 7;
long long int power(long long int n, long long int k, long long int mod) {
  long long int ans = 1;
  n = n % mod;
  while (k > 0) {
    if (k & 1) ans = (ans * n) % mod;
    n = (n * n) % mod;
    k >>= 1;
  }
  return (ans + mod) % mod;
}
struct triplet {
  long long int a, b, c;
};
bool operator<(const triplet &t1, const triplet &t2) {
  if (t1.a < t2.a) return true;
  if (t1.a == t2.a && t1.b < t2.b) return true;
  if (t1.a == t2.a && t1.b == t2.b && t1.c < t2.c) return true;
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int testcases = 1;
  cin >> testcases;
  while (testcases--) {
    long long int n, x;
    cin >> n >> x;
    long long int a[n], s = 0, c = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      s += (a[i] - x);
      if (a[i] == x) c++;
    }
    if (c == n)
      cout << 0 << "\n";
    else if (s == 0 || c)
      cout << 1 << "\n";
    else
      cout << 2 << "\n";
  }
}
