#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int& ai : a) cin >> ai;
    bool eq = true;
    for (int ai : a) eq &= (ai == x);
    if (eq) {
      cout << 0 << '\n';
      continue;
    }
    long long need = 0;
    bool ok = false;
    for (int ai : a) {
      if (ai == x) ok = true;
      need += x - ai;
    }
    if (need == 0 or ok)
      cout << 1 << '\n';
    else
      cout << 2 << '\n';
  }
  return (0);
}
