#include <bits/stdc++.h>
using namespace std;
long long oll = 0;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, x, arr[10009];
    cin >> n >> x;
    for (long long i = 0; i < n; i++) cin >> arr[i];
    int net = 0, count = 0, flag = 1, take = 0;
    for (long long i = 0; i < n; i++) {
      if (arr[i] != x) flag = 0;
      if (arr[i] == x) take = 1;
      net += (x - arr[i]);
    }
    if (flag)
      cout << 0 << "\n";
    else if (net == 0 || take)
      cout << 1 << "\n";
    else
      cout << 2 << "\n";
  }
  return 0;
}
