#include <bits/stdc++.h>
using namespace std;
double pie = 3.14159265358979323846;
long long int M = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T, n, i, j, k = 0, m, j1, co = 0, check, mi, l, sum;
  long long int ans = 0;
  cin >> T;
  for (i = 0; i < T; i++) {
    cin >> n >> k;
    long long int a[n];
    for (j = 0; j < n; j++) cin >> a[j];
    co = 0;
    for (j = 0; j < n; j++)
      if (a[j] == k) co++;
    ans = 0;
    if (co == n)
      cout << 0 << endl;
    else {
      for (j = 0; j < n; j++) ans += a[j];
      double x = ((double)ans) / n;
      if (x == k || co >= 1)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
}
