#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, start, p, save;
  cin >> n;
  while (n--) {
    long long int a, b, c = 0, x[8001], w;
    for (long long int i = 0; i < 8001; i++) x[i] = 0;
    cin >> a >> b;
    x[b + 4000]++;
    for (long long int i = 0; i < a; i++) {
      cin >> w;
      c += w;
      x[w + 4000]++;
    }
    if (x[b + 4000] == a + 1)
      cout << 0 << "\n";
    else if ((c % a == 0 && c / a == b) || x[b + 4000] > 1)
      cout << 1 << "\n";
    else
      cout << 2 << "\n";
  }
  return 0;
}
