#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int a[n];
    int sum = 0, cnt = 0;
    for (auto &y : a) {
      cin >> y;
      sum += y - x;
      if (y == x) cnt++;
    }
    if (cnt == n) {
      cout << "0\n";
    } else if (cnt >= 1 or sum == 0) {
      cout << "1\n";
    } else {
      cout << "2\n";
    }
  }
}
