#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long long MOD = 1e9 + 7;
const long long mxN = 2e5 + 3;
const double EPS = 1e-9;
void solve() {
  long long n, x;
  cin >> n >> x;
  long long numeq = 0;
  long long a[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] == x) numeq++;
  }
  if (numeq == n)
    cout << "0"
         << "\n";
  else if (numeq == 0) {
    long long sum = 0;
    for (long long i = 0; i < n; ++i) sum += a[i];
    long long t1 = x * n;
    if (t1 == sum)
      cout << "1"
           << "\n";
    else
      cout << "2"
           << "\n";
  } else
    cout << "1"
         << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long nT = 1;
  cin >> nT;
  for (long long i = 1; i <= nT; ++i) solve();
  return 0;
}
