#include <bits/stdc++.h>
const long long int mod = 1e9 + 7;
using namespace std;
long long int a[4100], n, m;
int main() {
  ios::sync_with_stdio(false);
  long long int t, i, j, k, sum, ans, flat = 0, ap, bp;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (i = 0; i < n; i++) cin >> a[i];
    flat = 0;
    sum = 0;
    ap = 0;
    for (i = 0; i < n; i++) {
      if (a[i] != m) flat = 1;
      if (a[i] == m) ap = 1;
      sum += m - a[i];
    }
    if (!flat)
      cout << flat << endl;
    else {
      if (sum == 0 || ap == 1)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
  return 0;
}
