#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
inline long long mul(long long a, long long b, long long p) {
  return (a * b) % p;
}
inline long long add(long long a, long long b, long long p) {
  return (a + b) % p;
}
long long powmod(long long x, long long y, long long p) {
  long long t = y, ret = 1;
  while (y--) {
    ret = (ret * x) % p;
  }
  return ret;
}
long long probmod(long long p, long long q, long long m) {
  long long expo = m - 2;
  while (expo) {
    if (expo & 1) {
      p = (p * q) % m;
    }
    q = (q * q) % m;
    expo >>= 1;
  }
  return p;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int x;
    cin >> x;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long sum = 0;
    bool flg = false, flg2 = false;
    for (int i = 0; i < n; i++) {
      if (a[i] != x) {
        flg = true;
      } else {
        flg2 = true;
      }
      sum += (a[i] - x);
    }
    if (!flg)
      cout << (0) << endl;
    else {
      if (flg2)
        cout << (1) << endl;
      else {
        if (sum == 0)
          cout << (1) << endl;
        else
          cout << (2) << endl;
      }
    }
  }
  return 0;
}
