#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define ALL(a) (a).begin(),(a).end() using namespace std; typedef long long ll; class BipartiteMatching { int max_v; vector> *G; bool *used; public: int *match; BipartiteMatching(int n) : max_v(n) { G = new vector>(max_v); match = new int[max_v]; used = new bool[max_v]; } ~BipartiteMatching() { delete match; delete used; delete G; } void AddEdge(int u, int v) { (*G)[u].push_back(v); (*G)[v].push_back(u); } bool Dfs(int v) { used[v] = true; for (int u : (*G)[v]) { int w = match[u]; if (w < 0 || (!used[w] && Dfs(w))) { match[v] = u; match[u] = v; return true; } } return false; } int DoMatching() { int res = 0; memset(match, -1, sizeof(match[0]) * max_v); for (int v = 0; v < max_v; v++) { if (match[v] < 0) { memset(used, false, sizeof(used[0]) * max_v); if (Dfs(v)) res++; } } return res; } }; int main(int argc, char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; BipartiteMatching bm = BipartiteMatching(N+N); REP(i,N){ int x; cin >> x; REP(j,N) if(j!=x) bm.AddEdge(i+N,j); } if (bm.DoMatching() < N) { cout << -1 << endl; return 0; } REP(i,N) cout << bm.match[i+N] << '\n'; cout << flush; return 0; }