#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
int n, m, a[N];
int main(int argc, char **argv) {
int t;
scanf("%d", &t);
while (t-- != 0) {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i)
scanf("%d", &a[i]);
int at = -1;
for (int i = 0; i < n; ++i)
if (a[i] != -1) {
at = i;
break;
}
assert(at != -1);
for (int i = at + 1; i < n; ++i)
a[i] = (a[i - 1] + 1) % m;
for (int i = at - 1; i >= 0; --i)
a[i] = ((a[i + 1] - 1) % m + m) % m;
for (int i = 0; i < n; ++i)
printf("%s%d", i ? " " : "", a[i]);
puts("");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTiA9IDFlMzsKaW50IG4sIG0sIGFbTl07CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqKmFyZ3YpIHsKCWludCB0OwoJc2NhbmYoIiVkIiwgJnQpOwoJd2hpbGUgKHQtLSAhPSAwKSB7CgkJc2NhbmYoIiVkJWQiLCAmbiwgJm0pOwoJCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKQoJCQlzY2FuZigiJWQiLCAmYVtpXSk7CgkJaW50IGF0ID0gLTE7CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpCgkJCWlmIChhW2ldICE9IC0xKSB7CgkJCQlhdCA9IGk7CgkJCQlicmVhazsKCQkJfQoJCWFzc2VydChhdCAhPSAtMSk7CgkJZm9yIChpbnQgaSA9IGF0ICsgMTsgaSA8IG47ICsraSkKCQkJYVtpXSA9IChhW2kgLSAxXSArIDEpICUgbTsKCQlmb3IgKGludCBpID0gYXQgLSAxOyBpID49IDA7IC0taSkKCQkJYVtpXSA9ICgoYVtpICsgMV0gLSAxKSAlIG0gKyBtKSAlIG07CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpCgkJCXByaW50ZigiJXMlZCIsIGkgPyAiICIgOiAiIiwgYVtpXSk7CgkJcHV0cygiIik7Cgl9CglyZXR1cm4gMDsKfQ==