#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(random_device{}());
vector<pair<int, int>> generate_tree(unsigned int n) {
vector<pair<int, int>> edges;
vector<int> available_nodes, connected_nodes;
for (int i = 2; i <= n; ++i) {
available_nodes.push_back(i);
}
connected_nodes.push_back(1);
while (!available_nodes.empty()) {
int u = connected_nodes[rnd() % connected_nodes.size()];
int v = available_nodes.back();
available_nodes.pop_back();
edges.emplace_back(u, v);
connected_nodes.push_back(v);
}
return edges;
}
vector<pair<int, int>> generate_paths(unsigned int f,unsigned int n) {
vector<pair<int, int>> paths;
for (int i = 0; i < f; ++i) {
unsigned int a = rnd() % n + 1;
unsigned int b = rnd() % n + 1;
while (a == b) {
b = rnd() % n + 1;
}
paths.emplace_back(a, b);
}
return paths;
}
void write_to_file(unsigned int n,unsigned int f, const vector<pair<int, int>> &edges, const vector<pair<int, int>> &paths,
const string &filename) {
ofstream outfile(filename);
outfile << n << " " << f << endl;
for (const auto &edge: edges) {
outfile << edge.first << " " << edge.second << endl;
}
for (const auto &path: paths) {
outfile << path.first << " " << path.second << endl;
}
outfile.close();
}
int main() {
unsigned int n = 10;
unsigned int f = rnd() % 10 + 1;
vector<pair<int, int>> edges = generate_tree(n);
vector<pair<int, int>> paths = generate_paths(f, n);
write_to_file(n, f, edges, paths, "input.txt");
cout << "Input data generated and written to input.txt" << endl;
return 0;
}