#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
double eps = 1e-12;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  for (long long it = 0; it < t; it++) {
    int n, x;
    cin >> n >> x;
    vector<int> v1(n);
    long long sum = 0;
    bool ab = false;
    unordered_set<int> s1;
    for (long long i = 0; i < n; i++) {
      cin >> v1[i];
      sum += (v1[i] - x);
      if (x == v1[i]) ab = true;
      s1.insert(v1[i]);
    };
    ;
    ;
    ;
    if (s1.size() == 1) {
      if (*s1.begin() == x)
        cout << 0 << "\n";
      else
        cout << 2 << "\n";
    } else {
      if (sum == 0)
        cout << 1 << "\n";
      else if (ab)
        cout << 1 << "\n";
      else
        cout << 2 << "\n";
    }
  }
  return 0;
}
