#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int a[maxn], n, x;
int main() {
  int k;
  cin >> k;
  while (k--) {
    cin >> n >> x;
    int sum = 0;
    bool f = 1, f1 = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
      if (a[i] != x) f = 0;
      if (a[i] == x) f1 = 1;
    }
    if (f == 1)
      cout << 0 << endl;
    else if (sum == n * x || f1 == 1)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
