#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n, x;
  cin >> n >> x;
  vector<int> inp(n, 0);
  for (int i = 0; i < n; i++) cin >> inp[i];
  for (int i = 0; i < n; i++) {
    if (inp[i] != x) break;
    if (i == (n - 1)) return 0;
  }
  for (int i = 0; i < n; i++) {
    if (inp[i] == x) return 1;
  }
  int dec = 0, inc = 0;
  for (int i = 0; i < n; i++) {
    if (inp[i] > x)
      inc += (inp[i] - x);
    else
      dec += (x - inp[i]);
  }
  if (inc == dec)
    return 1;
  else
    return 2;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) cout << solve() << "\n";
  return 0;
}
