#include <bits/stdc++.h>
using namespace std;
int a[4010];
int main() {
  int T, n, x, i, j, infected, sum;
  scanf("%d", &T);
  while (T--) {
    infected = 0;
    sum = 0;
    scanf("%d %d", &n, &x);
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == x) infected++;
      sum += a[i];
    }
    if (infected == n) {
      printf("0\n");
      continue;
    }
    if (sum == x * n)
      printf("1");
    else if (sum != x * n) {
      if (infected == 0)
        printf("2");
      else
        printf("1");
    }
    printf("\n");
  }
  return 0;
}
