#include <bits/stdc++.h>
using namespace std;
long long solve() {
  long long n, x;
  cin >> n >> x;
  long long second = 0;
  vector<long long> a(n);
  bool boo = true;
  bool f1 = false;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    second += a[i];
    if (a[i] != x)
      boo = false;
    else
      f1 = true;
  }
  if (boo) return 0;
  if (second % n == 0 && second / n == x) return 1;
  if (f1) return 1;
  return 2;
}
signed main() {
  long long q;
  cin >> q;
  for (long long i = 0; i < q; ++i) cout << solve() << '\n';
}
