#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int up = 0, down = 0;
    int flag = 0;
    for (int i = 0; i < n; i++) {
      int k;
      cin >> k;
      if (k > x)
        up += k - x;
      else
        down += x - k;
      if (k == x) flag++;
    }
    if (!up && !down)
      cout << 0;
    else if (up == down || flag)
      cout << 1;
    else
      cout << 2;
    cout << endl;
  }
}
