#include #include #include #include #include #include #include #include using namespace std; struct BipartiteMatching { int V; vector > G; vector match; vector used; BipartiteMatching(int v) { V = v; G = vector >(v, vector(v)); match = vector(v); used = vector(v); } void add_edge(int v, int u) { G[v][u] = G[u][v] = true; } bool dfs(int v) { used[v] = true; for(int i = 0; i < V; i++) { if(!G[v][i]) continue; int u = i, w = match[u]; if(w < 0 || (!used[w] && dfs(w))) { match[v] = u; match[u] = v; return true; } } return false; } int calc() { int res = 0; fill(match.begin(), match.end(), -1); for(int v = 0; v < V; v++) { if(match[v] < 0) { fill(used.begin(), used.end(), false); if(dfs(v)) { res++; } } } return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; BipartiteMatching bp(2 * 50); for(int i = 0; i < N; i++) { int a; cin >> a; for(int j = 0; j < N; j++) { if(a == j) continue; bp.add_edge(i, 50 + j); } } if(bp.calc() != N) { cout << -1 << endl; } else { for(int i = 0; i < N; i++) { cout << bp.match[i] - 50 << endl; } } }