#include <iostream>
#include <string>
using namespace std;
int n, m;
string arr;
void solution(int position)
{
if (position == m)
{
for (int i = 0; i < m; i++)
cout << arr[i] << " ";
cout << "\n";
return;
}
for (int i = 1; i <= n; i++)
{
arr.push_back(i + '0');
solution(position + 1);
arr.pop_back();
}
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
solution(0);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sIG07CnN0cmluZyBhcnI7Cgp2b2lkIHNvbHV0aW9uKGludCBwb3NpdGlvbikKewoJaWYgKHBvc2l0aW9uID09IG0pCgl7CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBtOyBpKyspCgkJCWNvdXQgPDwgYXJyW2ldIDw8ICIgIjsKCQljb3V0IDw8ICJcbiI7CgkJcmV0dXJuOwoJfQoKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykKCXsKCQlhcnIucHVzaF9iYWNrKGkgKyAnMCcpOwoJCXNvbHV0aW9uKHBvc2l0aW9uICsgMSk7CgkJYXJyLnBvcF9iYWNrKCk7Cgl9Cn0KaW50IG1haW4odm9pZCkKewoJaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoJY2luLnRpZShOVUxMKTsKCgljaW4gPj4gbiA+PiBtOwoJc29sdXRpb24oMCk7CglyZXR1cm4gMDsKfQ==