#include <bits/stdc++.h>
using namespace std;
const int maxnn = 1e5 + 7;
int a[maxnn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, x;
    scanf("%d %d", &n, &x);
    int sum = 0;
    int flag = 0;
    int jsq = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      sum += a[i] - x;
      if (a[i] == x) {
        jsq++;
      }
      if (a[i] != x) {
        flag = 1;
      }
    }
    int ans = 2;
    if (flag == 0) {
      ans = min(ans, 0);
    }
    if (sum == 0 || jsq) {
      ans = min(ans, 1);
    }
    printf("%d\n", ans);
  }
  return 0;
}
