#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, r;
  cin >> n >> r;
  long long igual = 0;
  vector<long long> a(n);
  long long soma = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    long long at = a[i] - r;
    igual += (at == 0);
    soma += at;
  }
  if (soma == 0 && igual == n) {
    cout << 0 << endl;
    return;
  }
  if ((soma == 0) || (igual) >= 1) {
    cout << 1 << endl;
    return;
  }
  cout << 2 << endl;
}
int32_t main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long tc = 1;
  cin >> tc;
  while (tc--) solve();
}
