#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, equalsCount = 0;
    cin >> n >> x;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      int r;
      cin >> r;
      sum += x - r;
      if (r == x) {
        equalsCount++;
      }
    }
    if (equalsCount == n) {
      cout << 0 << endl;
    } else {
      if (equalsCount || sum == 0) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    }
  }
}
