#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  char ch = getchar();
  bool flag = false;
  x = 0;
  while (!isdigit(ch)) flag |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  if (flag) x = -x;
}
const int Mod = 1e9 + 7;
const int N = 1e5 + 5, M = 4e6 + 1e4;
long long T, n, x;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  cin >> T;
  while (T--) {
    cin >> n >> x;
    int ans = 0;
    long long sum = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      int k;
      cin >> k;
      if (k == x) continue;
      sum += k - x;
      cnt++;
    }
    if (!cnt)
      cout << 0 << endl;
    else if (sum == 0 || cnt < n)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
