#include using namespace std; const int N = 100010; int n, k; vector path; bool st[N]; void dfs(int step) { if (step == k + 1) { cout << "("; for (int i = 0; i < path.size() - 1; ++i) { cout << path[i] << ","; } cout << path.back() << ")"; return; } for (int i = 1; i <= n; i++) { if (!st[i]) { path.push_back(i); st[i] = true; dfs(step + 1); st[i] = false; path.pop_back(); } } } int main() { cin >> n >> k; dfs(1); return 0; }