#include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = 1010;
int T;
int n, x;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) {
    cin >> n >> x;
    int sum = 0;
    bool same = true, flag = false;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += x - a[i];
      if (a[i] != x)
        same = false;
      else
        flag = true;
    }
    if (same)
      cout << "0\n";
    else if (flag || !sum)
      cout << "1\n";
    else
      cout << "2\n";
  }
  return 0;
}
