#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
int a[100005];
int main() {
  long long T;
  cin >> T;
  while (T--) {
    cin >> n >> m;
    int z = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == m) z++;
    }
    if (z == n) {
      cout << 0 << endl;
      continue;
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i] - m;
    }
    if (!sum || z) {
      cout << 1 << endl;
      continue;
    }
    cout << 2 << endl;
  }
}
