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