#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const int dx[] = {0, -1, 1, 0, 1, -1, 1, -1};
const int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const ll inf = 1e18L + 7;
const int N = 2e5 + 50;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n, x;
    cin >> n >> x;
    bool flag = 0;
    vector<int> a(n);
    int sum = 0;
    for (auto &i : a) {
      cin >> i;
      flag |= (i == x);
      sum += (x - i);
    }
    sort(a.begin(), a.end());
    if (count(a.begin(), a.end(), x) == n) {
      puts("0");
      continue;
    }
    if (flag || sum == 0) {
      puts("1");
      continue;
    }
    puts("2");
  }
  return 0;
}
