#include <bits/stdc++.h>
using namespace std;
int a[1001];
int main(void) {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int n, k, sum = 0, mi = 0, pl = 0;
    bool alleq = true, eq = false;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
      if (a[i] != k) alleq = false;
      if (a[i] == k) eq = true;
    }
    if (alleq)
      printf("0\n");
    else if (n * k == sum || eq)
      printf("1\n");
    else
      printf("2\n");
  }
  return 0;
}
