A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1... n. For example, the square of q = [4, 5, 1, 2, 3] is p = q2 = [2, 3, 4, 5, 1].

This problem is about the inverse operation: given the permutation p you task is to find such permutation q that q2 = p. If there are several such q find any of them.

Input

The first line contains integer n (1 ≤ n ≤ 106) — the number of elements in permutation p.

The second line contains n distinct integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the elements of permutation p.

Output

If there is no permutation q such that q2 = p print the number "-1".

If the answer exists print it. The only line should contain n different integers qi (1 ≤ qi ≤ n) — the elements of the permutation q. If there are several solutions print any of them.

Examples

Input

4
2 1 4 3


Output

3 4 2 1


Input

4
2 1 3 4


Output

-1


Input

5
2 3 4 5 1


Output

4 5 1 2 3
!function(r){function __webpack_require__(t){if(e[t])return e[t].exports;var a=e[t]={exports:{},id:t,loaded:!1};return r[t].call(a.exports,a,a.exports,__webpack_require__),a.loaded=!0,a.exports}var e={};return __webpack_require__.m=r,__webpack_require__.c=e,__webpack_require__.p="",__webpack_require__(0)}([function(r,e,t){r.exports=t(1)},function(r,e){"use strict";function solve(r,e){function calculate(r,e){for(var t=[],a=[],n=0;r>n;n++)if(void 0===a[n]){var o=t.length;a[n]=o;var _=1,i=n,u=!0;t.push({});for(var s=0,c=n;r>s;s++){if(c=e[c]-1,u=!u,u&&(i=e[i]-1),void 0!==a[c]){t[o]=u?{l:_,s:n}:{l:_,s:n,h:i};break}++_,a[c]=o}}t.sort(function(r,e){return r.l-e.l});for(var l=[],s=0,f=t.length;f>s;s++){var p=t[s].l;if(0===p%2){if(!(f-1>s&&p===t[s+1].l))return-1;for(var n=0,v=t[s].s,d=t[s+1].s;p>n;n++){var b=e[v],k=e[d];l[v]=d+1,l[d]=b,v=b-1,d=k-1}s+=1}else{var v=t[s].s,d=t[s].h,q=(p-1)/2;l[d]=v+1;for(var n=0;q>n;n++){var b=e[v],k=e[d];l[v]=k,l[k-1]=b,v=b-1,d=k-1}}}return l}function resout(r){print(-1===r?"-1":r.join(" "))}var t=calculate(r,e);resout(t)}var t=parseInt(readline()),a=readline().split(" ").map(function(r){return parseInt(r)});solve(t,a)}]);