#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 69;
int a[N], x, n;
void solve() {
  cin >> n >> x;
  int allsame = 1;
  int cumsum = 0;
  int infected = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cumsum += (a[i] - x);
    infected += (a[i] == x);
    if (a[i] != x) {
      allsame = 0;
    }
  }
  if (allsame) {
    cout << 0 << endl;
  } else if (infected || cumsum == 0) {
    cout << 1 << endl;
  } else {
    cout << 2 << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
