#include <bits/stdc++.h>
using namespace std;
bool vowel(char che) {
  if (che == 'A' || che == 'E' || che == 'I' || che == 'O' || che == 'U' ||
      che == 'Y')
    return true;
  else
    return false;
}
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
long long a[N], l[N], r[N], b[N], c[N], d, dp[N], dis, pr[N];
pair<long long, long long> p[N];
char o;
bool mark[N], h;
string s, s1;
stack<int> st;
set<long long> st1, st2;
deque<int> dq;
vector<int> vt, vs, vm;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 0, n, m = 0, k = 0, f = 0, sum = 0, ans = 0, n1 = 0;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    h = true;
    ans = 0, f = 0;
    for (int i = 0; i < n; i++) {
      cin >> m;
      if (m != k) h = false;
      if (m == k) {
        f++;
      }
      ans += (m - k);
    }
    if (h)
      cout << 0 << endl;
    else if (ans == 0 || f > 0)
      cout << 1 << endl;
    else
      cout << 2 << endl;
  }
}
