#include <bits/stdc++.h>
using namespace std;
const int N = 600010, mod = 1e9 + 7, P = 19260817;
long long n, m, T, k, x, cnt, y, b[N], vis[N], a[N], ans, t, sum;
string s;
int main() {
  scanf("%lld", &T);
  while (T--) {
    scanf("%lld%lld", &n, &k);
    sum = cnt = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &x);
      sum += x;
      if (x == k) cnt++;
    }
    if (cnt == n)
      puts("0");
    else if (sum == k * n || cnt)
      puts("1");
    else
      puts("2");
  }
}
