#include <bits/stdc++.h>
using namespace std;
int t, n, x, a[1005];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> x;
    bool flag = 1, flag2 = 0;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
      if (a[i] != x) flag = 0;
      if (a[i] == x) flag2 = 1;
    }
    if (flag == 1)
      cout << 0 << endl;
    else if (sum == x * n || flag2 == 1)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
