#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int *a = new int[n];
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    if (mp.size() == 1 && a[0] == x) {
      cout << 0 << endl;
      continue;
    }
    sort(a, a + n);
    int w = lower_bound(a, a + n, x) - a;
    if (w >= 0 && w < n && a[w] == x) {
      cout << 1 << endl;
      continue;
    }
    int l_s = 0, r_s = 0;
    for (int i = w - 1; i >= 0; i--) l_s += (abs(a[i] - x));
    for (int i = w; i < n; i++) r_s += abs(a[i] - x);
    if (l_s == r_s)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
