#include <bits/stdc++.h>
const long long N = 2e5 + 5;
using namespace std;
long long a[N], b[N];
bool cmp(long long a, long long b) { return a > b; }
void solve() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] = a[i] % k;
  }
  sort(a + 1, a + n + 1, cmp);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (!a[i]) {
      break;
    } else if (a[i] != a[i - 1]) {
      b[i] = k - a[i];
    } else {
      b[i] = b[i - 1] + k;
    }
    ans = max(ans, b[i] + 1);
  }
  cout << ans << "\n";
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
