#include <bits/stdc++.h>
using namespace std;
long long int fastpow(long long int base, long long int exp, long long int M) {
  long long int res = 1;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % M;
    base = (base * base) % M;
    exp >>= 1;
  }
  return res;
}
void solve() {
  long long int n, x;
  cin >> n >> x;
  long long int a[n];
  long long int cnt = 0, sum = 0;
  for (long long int i = 0; i <= n - 1; ++i) {
    cin >> a[i];
    sum += a[i];
    if (a[i] == x) cnt++;
  }
  if (cnt == n) {
    cout << 0 << "\n";
  } else if (sum == n * x) {
    cout << 1 << "\n";
  } else {
    if (cnt == 0)
      cout << 2 << "\n";
    else
      cout << 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  for (long long int i = 1; i <= t; ++i) {
    solve();
  }
  return 0;
}
