#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, x, a;
    cin >> n >> x;
    vector<long long> v, pos, neg;
    long long p = 0, j = 0, no = 0;
    for (int i = 0; i < n; i++) {
      cin >> a;
      if (x - a > 0) {
        pos.push_back(a);
        p += (x - a);
      } else if (x - a < 0) {
        neg.push_back(a);
        no += a - x;
      } else {
        j = 1;
      }
    }
    if ((pos.size() == 0 && neg.size() == 0)) {
      cout << 0 << endl;
    } else if (j == 1) {
      cout << 1 << endl;
    } else if (p > no || no > p) {
      cout << 2 << endl;
    } else if (p == no) {
      cout << 1 << endl;
    }
  }
}
