#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x, a, sum = 0, flag = 1, cnt = 0;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      sum = sum + a - x;
      if (a != x) flag = 0;
      if (a == x) cnt = 1;
    }
    if (flag)
      cout << 0 << endl;
    else if (!sum || cnt)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
  return 0;
}
