#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
const int N = 10010;
const int INF = 0x3f3f3f3f;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 10e-6;
const double PI = 3.14159265358979323;
priority_queue<int, vector<int>, less<int> > q;
priority_queue<int, vector<int>, greater<int> > qq;
int a[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    int cnt = 0;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
      if (a[i] == x) {
        cnt++;
      }
    }
    if (cnt == n) {
      cout << 0 << endl;
    } else if (n * x == sum) {
      cout << 1 << endl;
    } else if (cnt) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  }
  return 0;
}
