#include <bits/stdc++.h>
using namespace std;
void FIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  FIO();
  long long t;
  cin >> t;
  while (t--) {
    long long n, x;
    cin >> n >> x;
    vector<long long> a(n);
    bool alreadyInfec = 0;
    bool toBeInfec = 0;
    long long diffAlreadyzero = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] != x)
        toBeInfec = 1;
      else
        alreadyInfec = 1;
      diffAlreadyzero += (x - a[i]);
    }
    if (toBeInfec == 0) {
      cout << 0 << '\n';
    } else if (alreadyInfec or !diffAlreadyzero) {
      cout << 1 << '\n';
    } else {
      cout << 2 << '\n';
    }
  }
  return 0;
}
