#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = 1e18;
const long long N = 1e5 + 5;
bool cmp(const pair<long long, long long>& a,
         const pair<long long, long long>& b) {
  return a.second < b.second;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long f = 1, first = 0;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] != k) f = 0;
    if (a[i] == k) first = 1;
  }
  if (f) {
    cout << 0 << '\n';
    return;
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    long long g = a[i];
    if (g > k) {
      sum -= (g - k);
    } else if (g < k) {
      sum += (k - g);
    }
  }
  if (sum and first == 0) {
    cout << 2 << '\n';
  } else
    cout << 1 << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
