#include <bits/stdc++.h>
using namespace std;
long long mmod(long long x, long long y) {
  if (x >= 0LL)
    return x % y;
  else
    return (y - (-x) % y) % y;
}
long long ddiv(long long x, long long y) {
  x -= mmod(x, y);
  return x / y;
}
void solve() {
  int n;
  cin >> n;
  int x;
  cin >> x;
  vector<long long> a(n);
  int cnt = 0;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
    if (a[i] == x) ++cnt;
  }
  if (cnt == n) {
    cout << "0\n";
    return;
  }
  if (cnt > 0 || x * n == sum) {
    cout << "1\n";
    return;
  }
  cout << "2\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  for (int k = 0; k < t; ++k) solve();
  return 0;
}
