#include <bits/stdc++.h>
using namespace std;
long long int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  cin >> T;
  while (T--) {
    long long int i = 0, j = 0, k, sm = 0, val;
    cin >> n >> k;
    vector<long long int> a(n);
    for (i = 0; i < n; cin >> a[i++])
      ;
    for (i = 0; i < n; i++) {
      if (a[i] != k) break;
    }
    if (i == n) {
      cout << '0' << endl;
      continue;
    }
    for (i = 0; i < n; i++) {
      sm += (a[i] - k);
      if (a[i] == k) {
        sm = 0;
        break;
      }
    }
    if (sm == 0) {
      cout << '1' << endl;
      continue;
    }
    cout << '2' << endl;
  }
  return 0;
}
