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