#include <bits/stdc++.h>
using namespace std;
int arr[1003];
int main() {
  int n, x, ans, sum, t, ck;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr + 1, arr + n + 1);
    ck = 0;
    for (int i = 1; i <= n; i++) {
      if (arr[i] == x) ck = 1;
    }
    sum = 0;
    for (int i = 1; i <= n; i++) sum += (arr[i] - x);
    if (arr[1] == arr[n] && arr[n] == x)
      ans = 0;
    else if (sum == 0 || ck)
      ans = 1;
    else
      ans = 2;
    cout << ans << endl;
  }
  return 0;
}
