#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
int n, index = 0;
cin >> n;
vector <int> a(n);
vector <bool> e(n, false);
set <int> s;
for(int i = 0; i < n; i++){
s.insert(i+1);
}
for(int i = 0; i < n; i++){
cin >> a[i];
if(s.count(a[i])) s.erase(a[i]);
else e[i] = true;
}
auto temp = s.begin();
for(int i = 0; i < n; i++){
if(e[i]){
a[i] = *temp;
temp++;
}
cout << a[i] << " ";
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c2V0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBjaW4udGllKDApLT5zeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSkgewogICAgICAgIGludCBuLCBpbmRleCA9IDA7CiAgICAgICAgY2luID4+IG47CiAgICAgICAgdmVjdG9yIDxpbnQ+IGEobik7CiAgICAgICAgdmVjdG9yIDxib29sPiBlKG4sIGZhbHNlKTsKICAgICAgICBzZXQgPGludD4gczsKICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICAgICAgcy5pbnNlcnQoaSsxKTsKICAgICAgICB9CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgICAgIGNpbiA+PiBhW2ldOwogICAgICAgICAgICBpZihzLmNvdW50KGFbaV0pKSBzLmVyYXNlKGFbaV0pOwogICAgICAgICAgICBlbHNlIGVbaV0gPSB0cnVlOwogICAgICAgIH0KICAgICAgICBhdXRvIHRlbXAgPSBzLmJlZ2luKCk7CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgICAgIGlmKGVbaV0pewogICAgICAgICAgICAgICAgYVtpXSA9ICp0ZW1wOwogICAgICAgICAgICAgICAgdGVtcCsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvdXQgPDwgYVtpXSA8PCAiICI7CiAgICAgICAgfQoJCWNvdXQgPDwgZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9