#include <bits/stdc++.h>
using namespace std;
int xx[] = {0, 0, -1, 1, -1, 1, -1, 1}, yy[] = {-1, 1, 0, 0, -1, -1, 1, 1};
using ll = long long;
using ppi = pair<int, int>;
using ppl = pair<ll, ll>;
template <typename T>
using vi = vector<T>;
template <typename T>
using vvi = vector<vector<T>>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int N, x;
    cin >> N >> x;
    vi<int> v(N);
    bool allsame = true;
    bool existX = false;
    for (long long i = (0); i < (N); ++i) {
      cin >> v[i];
      if (x != v[i]) allsame = false;
      if (x == v[i]) existX = true;
    }
    if (allsame) {
      cout << 0 << ((char)10);
      continue;
    }
    int need = 0;
    for (auto i : v) {
      need += x - i;
    }
    cout << (need && !existX ? 2 : 1) << ((char)10);
  }
  return 0;
}
