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