#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long t, n, x, z, sum;
  cin >> t;
  for (long i = 0; i < t; i++) {
    cin >> n >> x;
    sum = 0;
    bool ok = false, ok2 = true;
    for (long j = 0; j < n; j++) {
      cin >> z;
      if (z == x) {
        ok = true;
      } else {
        ok2 = false;
      }
      sum += z;
    }
    if (ok2) {
      cout << 0 << endl;
    } else if (ok) {
      cout << 1 << endl;
    } else {
      if (sum == n * x) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    }
  }
  return 0;
}
