text: Examples Input 7 11 2 4 7 3 Output 2 7 1 3 6 5 4 7 1 5 4 6 2 3 Input 1000 999 10 20 30 40 Output -1 Note In the first sample test, there should be 7 cities and at most 11 roads.The provided sample solution generates 10 roads, as in the drawing.You can also see a simple path of length n between 2 and 4, and a path between 7 and 3.<image> # Solution #include <bits/stdc++.h> using namespace std; template <typename T> std::ostream &operator<<(std::ostream &out, vector<T> &v) { for (typename vector<T>::size_type i = 0; i < v.size(); ++i) out << v[i] << " "; out << "\n"; return out; } template <typename T> std::ostream &operator<<(std::ostream &out, set<T> &s) { for (auto e : s) out << e << " "; out << "\n"; return out; } template <typename T, typename N> std::ostream &operator<<(std::ostream &out, pair<T, N> &p) { out << "(" << p.first << ", " << p.second << ") "; return out; } template <typename T, typename N> std::ostream &operator<<(std::ostream &out, vector<pair<T, N> > &v) { for (size_t i = 0; i < v.size(); ++i) cout << v[i]; out << "\n"; return out; } template <typename T> std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) { for (size_t i = 0; i < v.size(); ++i) { for (size_t j = 0; j < v[i].size(); ++j) { out << v[i][j] << " "; } out << "\n"; } return out; } template <typename T> std::ostream &operator<<(std::ostream &out, vector<set<T> > &v) { for (size_t i = 0; i < v.size(); ++i) { out << v[i]; } out << "\n"; return out; } void solve() { int n, k; cin >> n >> k; int a, b, c, d; cin >> a >> b >> c >> d; if (n == 4 || k < n + 1) { cout << "-1\n"; return; } cout << a << " " << c << " "; vector<int> middle_vertices; for (int i = 1; i <= n; ++i) { if (i != a && i != b && i != c && i != d) { cout << i << " "; } } cout << d << " " << b << "\n"; cout << c << " " << a << " "; for (int i = 1; i <= n; ++i) { if (i != a && i != b && i != c && i !