#include <iostream>
#include <vector>
using namespace std;
vector<string> name;
vector<int> chosen;//标记选到第几个
vector<string> ans;
int n,m;
void calc(int x)
{
if(chosen.size()>m||chosen.size()+(n-x+1)<m)
return;//已选择的数超过m或者已选择的数加上没选的数都不到m返回
if (x == n + 1)
{ //选够了m个数输出
string ansTem = "";
for (int i = 0; i < chosen.size(); i++)
ansTem += name[chosen[i] - 1] + " ";
ans.push_back(ansTem);
return;
}
calc(x+1);
chosen.push_back(x);//选
calc(x+1);
chosen.pop_back();//不选
}
int main()
{
cin>>n>>m;
int k=n;
while(k--)
{
string nam;
cin>>nam;
name.push_back(nam);
}
calc(1);
for (int i = ans.size() - 1; i >= 0; i--)
cout << ans[i] << endl;
return 0;
}