#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, e, i, j, tc, l, k, x;
  cin >> tc;
  while (tc--) {
    cin >> n >> k;
    e = 0;
    j = 0;
    for (i = 0; i < n; i++) {
      cin >> x;
      if (x == k) e++;
      j += x;
    }
    if (e == n)
      cout << "0\n";
    else if (e || j == n * k)
      cout << "1\n";
    else
      cout << "2\n";
  }
}
