#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n, x;
    cin >> n >> x;
    long long a[n], sum = 0;
    long long cnt = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == x) {
        cnt++;
      }
      sum += (a[i] - x);
    }
    if (cnt == n) {
      cout << 0 << endl;
    } else if (cnt > 0 || sum == 0) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  }
  return 0;
}
