https://www.lanqiao.cn/courses/31016/learning/?id=1896801&compatibility=false
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef vector<long long> VI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define pb(i) push_back(i)
#define int long long
#define INF 0x3f3f3f3f
#define oz 998244353
#define endl '\n'
#define N 200010
const int mod = 1e9 + 7;
int p[N], si[N];
int find(int x) {
if (x != p[x]) p[x] = find(p[x]);
return p[x];
}
//size[find(b)] += size[find(a)];
//p[find(a)] = find(b);
string a[N]; //存人数
vector<string> res; //存每次选取的合法方案
int n, m;
void dfs(int x, int y) {
if (res.size() > m || res.size() + n - x + 1 < m)return ;
if (y == m + 1) { // 组合型枚举只要考虑到 y > m就可结束递归
for (auto t : res) {
cout << t << " ";
}
cout << endl;
return ;
}
res.push_back(a[x]);
dfs(x + 1, y + 1);
res.pop_back();
dfs(x + 1, y);
}
void solve() {
cin >> n >> m;
rep(i, 1, n)cin >> a[i];
dfs(1, 1);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}