#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] == x && a[n - 1] == x) {
      cout << 0 << endl;
      continue;
    }
    int i = 0, j = n - 1;
    int flag = 0;
    while (i <= j) {
      if (a[i] + a[j] == 2 * x) {
        i++;
        j--;
      } else {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      for (int i = 0; i < n; ++i) {
        if (a[i] == x) {
          flag = 0;
          break;
        }
      }
      if (flag == 0) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}
