#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
const int INF = 2e9 + 10;
void solve() {
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
    x %= k;
    mp[x]++;
  }
  long long ans = -1;
  for (auto x : mp) {
    if (x.first == 0) continue;
    ans = max(ans, k - x.first + (x.second - 1) * (long long)k);
  }
  cout << ans + 1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
