#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
int f(char c) { return (int)c - 48; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long int n, x;
    cin >> n >> x;
    long long int a[1005];
    long long int sum = 0;
    long long int count = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += (a[i] - x);
      if (a[i] == x) {
        count++;
      }
    }
    if (count == n) {
      cout << 0 << endl;
    } else if (count > 0) {
      cout << 1 << endl;
    } else if (sum == 0) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  }
  return 0;
}
