#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long powmod(long long a, long long b, long long m) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return (b > 0 ? gcd(b, a % b) : a); }
const int N = (int)5e5 + 5;
const int mod = (int)1e9 + 7;
const long long inf = (long long)1e18 + 18;
int n, x, a[N];
void solve() {
  cin >> n >> x;
  bool ok = true, atleast = false;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != x) ok = false;
    if (a[i] == x) atleast = true;
    sum += a[i];
  }
  if (ok) {
    cout << 0 << endl;
    return;
  }
  if ((sum % n == 0 && sum / n == x) || atleast == true) {
    cout << 1 << endl;
    return;
  }
  cout << 2 << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tt = 1;
  cin >> tt;
  while (tt--) solve();
  return 0;
}
