#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] == x) {
        ans++;
      }
    }
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += v[i];
    }
    if (ans == n) {
      cout << 0 << endl;
    } else {
      if (sum == n * x || ans > 0) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    }
  }
}
