#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, x;
    cin >> n >> x;
    int sum_diff = 0, sum_abs_diff = 0;
    bool has_x = false;
    for (int i = 0; i < n; ++i) {
      int a;
      cin >> a;
      if (a == x) has_x = true;
      sum_diff += a - x;
      sum_abs_diff += abs(a - x);
    }
    if (sum_abs_diff == 0)
      cout << 0 << '\n';
    else if (sum_diff == 0 || has_x)
      cout << 1 << '\n';
    else
      cout << 2 << '\n';
  }
  return 0;
}
