#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, x, ans = 2;
  cin >> n >> x;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> res;
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] != x) res.push_back(a[i]);
    sum += a[i] - x;
  }
  if (sum == 0)
    ans = 1;
  else if (res.size() != n)
    ans = 1;
  if (res.size() == 0) ans = 0;
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
