#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e9 + 10;
const ll N = 1e5 + 3;
const ll MOD = 1e9 + 7;
int main() {
  int t;
  cin >> t;
  while (t--) {
    ll n, x;
    cin >> n >> x;
    ll arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    ll left = 0, right = 0, same = 0, l = 0, m = 0, r = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] < x)
        left += (x - arr[i]), l++;
      else if (x == arr[i])
        same += arr[i], m++;
      else
        right += (arr[i] - x), r++;
    }
    int ans;
    if (right == left) {
      if (right == 0)
        ans = 0;
      else
        ans = 1;
    } else {
      if (left == 0) {
        if (m >= 1)
          ans = 1;
        else
          ans = 2;
      } else if (right == 0) {
        if (m >= 1)
          ans = 1;
        else
          ans = 2;
      } else {
        if (m >= 1)
          ans = 1;
        else
          ans = 2;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
