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
#include <bits/stdc++.h>
volatile bool isLocalTestEnabled = 0;
bool g_isLocalPrintEnabled = (bool)(0);
template <typename T>
void UpdateMin(T& a, const T b) {
  a = std::min(a, b);
}
template <typename T>
void UpdateMax(T& a, const T b) {
  a = std::max(a, b);
}
const long double Pi = std::atan(1.0L) * 4.0L;
static const long double Eps = 1.0e-09;
template <typename T>
bool IsEqual(const T a, const T b) {
  return std::abs(a - b) < Eps;
}
template <typename T>
bool IsGreater(const T a, const T b) {
  return a > b + Eps;
}
template <typename T>
bool IsLess(const T a, const T b) {
  return a + Eps < b;
}
template <typename T>
bool IsGreaterEqual(const T a, const T b) {
  return !IsLess(a, b);
}
template <typename T>
bool IsLessEqual(const T a, const T b) {
  return !IsGreater(a, b);
}
template <typename T>
std::string ToStr(const T& val) {
  std::ostringstream ostr;
  ostr << val;
  return ostr.str();
}
template <typename T>
bool FromStr(const std::string& str, T& val) {
  std::istringstream istr(str);
  istr >> val;
  return !!istr;
}
template <typename T>
std::istream& operator>>(std::istream& ist, std::vector<T>& data) {
  ;
  for (size_t i = 0; i < data.size(); i++) {
    ist >> data[i];
  }
  return ist;
}
template <typename T>
T Read(std::istream& ist) {
  ;
  T val;
  ist >> val;
  return val;
}
template <typename T>
std::ostream& operator<<(std::ostream& ost, const std::vector<T>& data) {
  for (size_t i = 0; i < data.size(); i++) {
    if (i != 0) {
      ost << ' ';
    }
    ost << data[i];
  }
  return ost;
}
template <size_t id>
class StopWatch {};
typedef std::pair<std::multimap<size_t, std::vector<size_t> >::const_iterator,
                  std::multimap<size_t, std::vector<size_t> >::const_iterator>
    range_map_size_vector_t;
void AddLoop(std::vector<size_t>& b, const std::vector<size_t>& loop) {
  size_t curr = loop[0];
  for (size_t i = 0; i < loop.size(); i++) {
    b[loop[i]] = loop[(i + 1) % loop.size()];
  }
}
std::vector<size_t> TransformLoop(const std::vector<size_t>& loop) {
  ;
  if (loop.size() == 1) return loop;
  std::vector<size_t> tl(loop.size());
  const size_t d = (loop.size() + 1) / 2;
  size_t p = 0;
  for (size_t i = 0; i < loop.size(); i++) {
    tl[i] = loop[p];
    p += d;
    p %= loop.size();
  }
  return tl;
}
void Apply(std::vector<size_t>& a, const std::vector<size_t>& b) {
  std::vector<size_t> c(a.size());
  for (size_t i = 0; i < b.size(); i++) {
    c[i] = a[b[i]];
  }
  c.swap(a);
}
bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode) {
  StopWatch<1> sw;
  (void)sw;
  size_t n;
  ist >> n;
  if (multipleTestMode && !ist) return false;
  if (!g_isLocalPrintEnabled) {
  } else
    std::cout << std::endl << "Next test" << std::endl;
  std::vector<size_t> a(n);
  ist >> a;
  if (!g_isLocalPrintEnabled) {
  } else
    std::cout << a << std::endl;
  for (size_t i = 0; i < n; i++) {
    a[i]--;
  }
  std::multimap<size_t, std::vector<size_t> > loops;
  std::vector<size_t> isVisited(n);
  for (size_t i = 0; i < n; i++) {
    if (isVisited[i]) continue;
    size_t start = i;
    std::vector<size_t> loop;
    size_t curr = start;
    loop.push_back(curr);
    while (a[curr] != start) {
      curr = a[curr];
      loop.push_back(curr);
      isVisited[curr] = 1;
    }
    loops.insert(std::multimap<size_t, std::vector<size_t> >::value_type(
        loop.size(), loop));
  }
  for (size_t i2 = 2; i2 <= n; i2 += 2) {
    if (loops.count(i2) % 2 == 1) {
      ost << "-1" << std::endl;
      return multipleTestMode;
    }
  }
  std::vector<size_t> b(n);
  for (std::multimap<size_t, std::vector<size_t> >::const_iterator p =
           loops.begin();
       p != loops.end();) {
    const std::vector<size_t>& l = p->second;
    const bool isOdd = (l.size() % 2 == 1);
    if (isOdd) {
      const std::vector<size_t> t = TransformLoop(l);
      AddLoop(b, t);
      ++p;
    } else {
      const std::vector<size_t>& la = p->second;
      ++p;
      const std::vector<size_t>& lb = p->second;
      ++p;
      std::vector<size_t> nl;
      ;
      ;
      for (size_t i = 0; i < la.size(); i++) {
        nl.push_back(la[i]);
        nl.push_back(lb[i]);
      }
      AddLoop(b, nl);
    }
  }
  std::vector<size_t> t(n);
  for (size_t i = 0; i < n; i++) {
    t[i] = i;
  }
  Apply(t, b);
  Apply(t, b);
  ;
  for (size_t i = 0; i < n; i++) {
    b[i]++;
  }
  ost << b << std::endl;
  return multipleTestMode;
}
int main(int argc, const char* argv[]) {
  std::ios_base::sync_with_stdio(false);
  std::istream* ist = &std::cin;
  std::ostream* ost = &std::cout;
  std::unique_ptr<std::istream> fileInput;
  if (argc > 1) {
    fileInput.reset(new std::ifstream(argv[1]));
    if (!(*fileInput)) {
      std::cout << "File not found: " << argv[1] << std::endl;
    }
    ist = fileInput.get();
  }
  Solve(*ist, *ost, false);
}
