#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
int read() {
  int a = 0, b = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') a = a * 10 + c - 48, c = getchar();
  return a * b;
}
int a[10005];
int main() {
  int t = read();
  while (t--) {
    long long n = read(), k = read(), s = 0, ag = 0, g2 = 0;
    for (int i = 1; i <= n; i++) {
      a[i] = read(), s += a[i] - k;
      if (a[i] != k) ag = 1;
      if (a[i] == k) g2 = 1;
    }
    if (ag == 0) {
      puts("0");
    } else if (s == 0) {
      puts("1");
    } else {
      if (g2 == 0)
        puts("2");
      else
        puts("1");
    }
  }
  return 0;
}
