#include <bits/stdc++.h>
using namespace std;
const int MX = 300300;
int t, n, m, i, k[MX], c[MX];
long long r;
int main() {
  cin >> t;
  while (t--) {
    int n, x, sum = 0, ctr = 0;
    cin >> n >> x;
    int arr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      sum += arr[i];
      ctr += (arr[i] == x);
    }
    if (ctr == n)
      cout << 0 << "\n";
    else if (ctr >= 1 || sum == n * x)
      cout << 1 << "\n";
    else
      cout << 2 << "\n";
  }
  return 0;
}
