#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int sum = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
      int y;
      cin >> y;
      sum += y;
      if (y == x) {
        cnt++;
      }
    }
    if (cnt == n) {
      cout << 0 << '\n';
    } else if (sum == n * x or cnt > 0) {
      cout << 1 << '\n';
    } else {
      cout << 2 << '\n';
    }
  }
  return 0;
}
