#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
long long read(void) {
  char ch = getchar();
  long long sum = 0;
  bool f = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  if (f) sum = -sum;
  return sum;
}
int T, n;
int a[N], X;
void solve(void) {
  n = read();
  X = read();
  bool fl1 = 0, fl2 = 0;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    sum += a[i];
    if (a[i] == X) fl1 = 1;
    if (a[i] != X) fl2 = 1;
  }
  if (fl1 && !fl2)
    printf("0\n");
  else if (fl1 && fl2)
    printf("1\n");
  else if (!fl1) {
    if (sum == X * n)
      printf("1\n");
    else
      printf("2\n");
  }
  return;
}
int main() {
  T = read();
  while (T--) solve();
  return 0;
}
