#include <bits/stdc++.h>
using namespace std;
int a[1001], ans[101];
int main() {
  int t, n, x;
  cin >> t;
  for (int i = 0, j; i < t; i++) {
    int sum = 0, k1 = 0, k2 = 0;
    cin >> n >> x;
    for (j = 1; j <= n; j++) {
      cin >> a[j];
      sum += a[j];
    }
    for (j = 1; j <= n; j++) {
      if (a[j] == x)
        k1 = 1;
      else
        k2 = 1;
    }
    if (k1) {
      if (k2)
        ans[i] = 1;
      else
        ans[i] = 0;
    } else if (sum * 1.0 / n != x * 1.0)
      ans[i] = 2;
    else
      ans[i] = 1;
  }
  for (int i = 0; i < t; i++) cout << ans[i] << endl;
  return 0;
}
