#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int N, X;
    cin >> N >> X;
    int S = 0, ctnotx = 0;
    for (int i = 1; i <= N; i++) {
      int f;
      cin >> f;
      if (f != X) S += f, ctnotx++;
    }
    if (ctnotx == 0) {
      cout << 0 << '\n';
      continue;
    } else if (ctnotx != N || (ctnotx == N && S == N * X)) {
      cout << 1 << '\n';
      continue;
    } else
      cout << 2 << '\n';
  }
  return 0;
}
