#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t, tt;
  cin >> tt;
  for (t = 1; t <= tt; t++) {
    int n, x;
    cin >> n >> x;
    int a[n];
    int pos = 0, neg = 0, sm = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] > x)
        pos += a[i] - x;
      else if (a[i] < x)
        neg += x - a[i];
      else
        sm++;
    }
    if (sm == n)
      cout << 0 << '\n';
    else if (pos == neg || sm >= 1)
      cout << 1 << '\n';
    else
      cout << 2 << '\n';
  }
}
