#include <iostream>
#include <vector>
int main() {
std::vector<int> v;
int k = 0, len = 0, num = 0;
std::cin >> k >> len;
for (int i = 0; i < len; i++)
{
std::cin >> num;
v.push_back (num);
}
for (i: v) std::cout << i << " ";
// reverse
for (int i = 0; i < len; i++)
{
if ((v[i] + k - 1) % len != 0)
v[i] = (v[i] + k - 1) % len;
else
v[i] = v[i] + k - 1;
}
std::cout << std::endl;
for (i: v) std::cout << i << " ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKaW50IG1haW4oKSB7CglzdGQ6OnZlY3RvcjxpbnQ+IHY7CglpbnQgayA9IDAsIGxlbiA9IDAsIG51bSA9IDA7CgkKCXN0ZDo6Y2luID4+IGsgPj4gbGVuOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBsZW47IGkrKykKCXsKCQlzdGQ6OmNpbiA+PiBudW07CgkJdi5wdXNoX2JhY2sgKG51bSk7Cgl9CgkKCWZvciAoaTogdikgc3RkOjpjb3V0IDw8IGkgPDwgIiAiOwoJCgkvLyByZXZlcnNlCglmb3IgKGludCBpID0gMDsgaSA8IGxlbjsgaSsrKQoJewoJCWlmICgodltpXSArIGsgLSAxKSAlIGxlbiAhPSAwKQoJCQl2W2ldID0gKHZbaV0gKyBrIC0gMSkgJSBsZW47CgkJZWxzZQoJCQl2W2ldID0gdltpXSArIGsgLSAxOwoJfQoJCglzdGQ6OmNvdXQgPDwgc3RkOjplbmRsOwoJZm9yIChpOiB2KSBzdGQ6OmNvdXQgPDwgaSA8PCAiICI7CglyZXR1cm4gMDsKfQ==