#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
int n, k, x, a[N], b[N], c[N];
string s;
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    int sum = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      sum += a[i];
      if (a[i] == x) cnt++;
    }
    if (cnt == n)
      cout << 0 << endl;
    else if (sum == n * x)
      cout << 1 << endl;
    else if (cnt != 0)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
