#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t, n, x;
  cin >> t;
  int sum = 0;
  int cnt = 0;
  int item = 0;
  int s = 0;
  while (t--) {
    cin >> n >> x;
    cnt = 0;
    s = 0;
    for (int i = 0; i < n; ++i) {
      cin >> item;
      if (item == x) {
        ++cnt;
      }
      s += item;
      sum += (x - item);
    }
    if (cnt == n) {
      cout << 0 << '\n';
    } else if (cnt > 0 or s == n * x or sum == 0) {
      cout << 1 << '\n';
    } else {
      cout << 2 << '\n';
    }
  }
  return 0;
}
