#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    bool k_a = true;
    bool any = false;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      sum += m - x;
      if (x != m) k_a = false;
      if (x == m) any = true;
    }
    cout << (k_a ? 0 : sum == 0 || any ? 1 : 2) << endl;
  }
  return 0;
}
