#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
const long long inf = (1ll << 60);
const double PI = acos(-1);
const long long maxn = 1e5 + 5;
const long long iinf = 2147483647;
const long long mod = 100000000000;
long long pw(long long x, long long p, long long m = mod) {
  long long ret = 1;
  while (p > 0) {
    if (p & 1) {
      ret *= x;
      ret %= m;
    }
    x *= x;
    x %= m;
    p >>= 1;
  }
  return ret;
}
long long inv(long long a, long long m = mod) { return pw(a, m - 2); }
signed main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ;
  long long T;
  cin >> T;
  while (T--) {
    long long n, x;
    cin >> n >> x;
    vector<long long> vc(n);
    for (long long i = (0); i < (n); i++) {
      cin >> vc[i];
    }
    long long cnt = 0, sum = 0;
    for (long long i = (0); i < (n); i++) {
      if (vc[i] == x) cnt++;
      sum += vc[i];
    }
    if (cnt == n) {
      cout << 0 << endl;
    } else if ((sum % n == 0 && sum / n == x) || cnt > 0) {
      cout << 1 << endl;
    } else
      cout << 2 << endl;
  }
}
