#include <bits/stdc++.h>
using namespace std;
void solver() {
  long long int n, x;
  cin >> n >> x;
  long long int temp;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    ans.push_back(temp);
  }
  long long int isoneinfected = 0;
  long long int isallinfected = 1;
  long long int issum = 0;
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    if (ans[i] == x) {
      isoneinfected = 1;
    }
    if (ans[i] != x) {
      isallinfected = 0;
    }
    sum += x - ans[i];
  }
  if (isallinfected) {
    cout << "0" << endl;
    return;
  }
  if (isoneinfected) {
    cout << "1" << endl;
    return;
  }
  if (sum == 0) {
    cout << "1" << endl;
    return;
  }
  cout << "2" << endl;
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solver();
  }
}
