#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
long long int mod(long long int x) { return (x % MOD + MOD) % MOD; }
void solve() {
  long long int n, x;
  cin >> n >> x;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int lsum = 0, rsum = 0, check = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] < x)
      lsum += (a[i] - x);
    else
      rsum += (x - a[i]);
    if (a[i] == x) check += 1;
  }
  if (lsum == 0 and rsum == 0)
    cout << 0 << endl;
  else if (lsum == rsum or check > 0)
    cout << 1 << endl;
  else
    cout << 2 << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
