#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const int Base = 131;
const long long INF = 1ll << 62;
const double eps = 1e-7;
const int mod = 1e9 + 9;
int a[maxn], t, n, x;
int main() {
  {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  cin >> t;
  while (t--) {
    cin >> n >> x;
    long long sum = 0;
    int flag = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == x) {
        i--;
        n--;
        flag = 1;
      }
      sum += a[i];
    }
    if (n == 0)
      cout << "0" << endl;
    else if (sum == n * x || flag == 1)
      cout << "1" << endl;
    else
      cout << "2" << endl;
  }
  return 0;
}
