#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, x, bg = 0, sml = 0, sm = 0, ar;
    cin >> n >> x;
    for (long long i = 0; i < n; i++) {
      cin >> ar;
      if (ar > x)
        bg += (ar - x);
      else if (ar < x)
        sml += (x - ar);
      else
        sm++;
    }
    if (sm == n)
      cout << 0 << endl;
    else if (bg == sml || sm > 0)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
