#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z, i, a[100000], sum, flag, eat;
  cin >> x;
  while (x--) {
    cin >> y >> z;
    sum = 0;
    flag = 0;
    eat = 0;
    for (i = 0; i < y; i++) {
      cin >> a[i];
      if (a[i] == z) flag = 1;
      if (a[i] != z) eat = 1;
    }
    if (flag == 1 && eat == 0)
      cout << 0 << endl;
    else if (flag == 1)
      cout << 1 << endl;
    else {
      for (i = 0; i < y; i++) {
        sum = sum + (z - a[i]);
      }
      if (sum == 0)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
  return 0;
}
