#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
#pragma GCC optimize(3)
const int mod = 998244353;
const double PI = 4 * atan2(1.0, 1.0);
int n, t, x;
string s;
int a[5100];
long long sum, sum1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> t;
  while (t--) {
    cin >> n >> x;
    sum = sum1 = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
      if (a[i] == x) {
        sum1++;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (a[i] != x) {
        goto nxt;
      }
    }
    cout << 0 << '\n';
    continue;
  nxt:
    if (sum == 1LL * x * n || sum1) {
      cout << 1 << '\n';
    } else {
      cout << 2 << '\n';
    }
  }
  return 0;
}
