#include <bits/stdc++.h>
using namespace std;
const long long int inf = (long long int)2e18;
const int mod = 1e9 + 7;
bool overflow(long long int a, long long int b) {
  if (a <= (inf + b - 1) / b) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int a[n], sum = 0;
    set<int> s;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
      s.insert(a[i]);
    }
    if (s.find(x) == s.end()) {
      if (!(sum % n) && (sum / n) == x)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    } else {
      if (s.size() == 1) {
        cout << 0 << "\n";
      } else
        cout << 1 << "\n";
    }
  }
}
