Problem: In the Kingdom of Wakanda, the 2020 economic crisis has made a great impact on each city and its surrounding area. Cities have made a plan to build a fast train rail between them to boost the economy, but because of the insufficient funds, each city can only build a rail with one other city, and they want to do it together.

Cities which are paired up in the plan will share the cost of building the rail between them, and one city might need to pay more than the other. Each city knows the estimated cost of building their part of the rail to every other city. One city can not have the same cost of building the rail with two different cities.

If in a plan, there are two cities that are not connected, but the cost to create a rail between them is lower for each of them than the cost to build the rail with their current pairs, then that plan is not acceptable and the collaboration won't go on. Your task is to create a suitable plan for the cities (pairing of the cities) or say that such plan doesn't exist.

Input

First line contains one integer N \;(2 ≤ N ≤ 10^3)   — the number of cities.

Each of the next N lines contains N-1 integers A_{i,1}, A_{i,2}, ..., A_{i,i-1}, A_{i,i+1}, ..., A_{i,N-1}\; (1 ≤ A_{i,j} ≤ 10^9)   — where A_{i,j} represents the cost for city i to build the rail to city j. Note that in each line A_{i,i} is skipped.

Output

Output should contain N integers O_{1}, O_{2}, ..., O_N, where O_i represents the city with which city i should build the rail with, or -1 if it is not possible to find the stable pairing.

Examples

Input


4
35 19 20
76 14 75
23 43 78
14 76 98


Output


3
4
1
2


Input


4
2 5 8
7 1 12
4 6 7
8 4 5


Output


-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct City {
  list<int> conns;
  vector<list<int>::iterator> connRanks;
  int outAccN = -1;
  int inAccN = -1;
  int inAccRank = INT32_MAX;
  list<int>::iterator toPropose;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  vector<City> cities;
  int n;
  cin >> n;
  cities.reserve(n + 1);
  cities.emplace_back();
  set<pair<int, int>> temp;
  for (int i = 1; i <= n; i++) {
    City ct;
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        continue;
      }
      int x;
      cin >> x;
      temp.emplace(x, j);
    }
    ct.connRanks.resize(n + 1);
    for (auto &p : temp) {
      ct.conns.push_back(p.second);
      ct.connRanks[p.second] = std::next(ct.conns.end(), -1);
    }
    ct.toPropose = ct.conns.begin();
    temp.clear();
    cities.push_back(std::move(ct));
  }
  while (true) {
    bool changed = false;
    for (int i = 1; i <= n; i++) {
      auto &c = cities[i];
      if (c.outAccN == -1) {
        if (c.toPropose == c.conns.end()) {
          cout << -1 << endl;
          exit(EXIT_SUCCESS);
        }
        changed = true;
        auto &proposed = cities[*c.toPropose];
        auto limit =
            proposed.inAccN == -1
                ? proposed.conns.end()
                : (std::next(proposed.conns.begin(), proposed.inAccRank));
        auto it = std::find(proposed.conns.begin(), limit, i);
        if (it != limit) {
          if (proposed.inAccN != -1) {
            auto &left = cities[proposed.inAccN];
            left.outAccN = -1;
          }
          proposed.inAccN = i;
          proposed.inAccRank = std::distance(proposed.conns.begin(), it);
          c.outAccN = *c.toPropose;
        }
        c.toPropose++;
      }
    }
    if (!changed) break;
  }
  for (int i = 1; i <= n; i++) {
    auto &c = cities[i];
    auto it = c.conns.begin();
    while (it != c.conns.end() && *(it++) != c.inAccN)
      ;
    while (it != c.conns.end()) {
      auto &oth = cities[*it];
      oth.conns.erase(oth.connRanks[i]);
      it = c.conns.erase(it);
    }
  }
  bool rotation = true;
  while (rotation) {
    rotation = false;
    for (int i = 1; i <= n; i++) {
      if (cities[i].conns.size() < 2) continue;
      rotation = true;
      list<pair<int, int>> h;
      set<pair<int, int>> h_set;
      int cur = i;
      h.emplace_back(cur, *cities[cur].conns.begin());
      auto prev = h.begin();
      while (true) {
        int y = *std::next(cities[prev->first].conns.begin(), 1);
        int x = *cities[y].conns.rbegin();
        auto p = make_pair(x, y);
        if (h_set.count(p) != 0) {
          auto it = h.begin();
          while (*it != p) it = h.erase(it);
          break;
        }
        h.push_back(p);
        h_set.insert(p);
        prev++;
      }
      prev = h.end();
      prev--;
      for (auto it = h.begin(); it != h.end(); it++) {
        auto &yc = cities[it->second];
        auto &px = prev->first;
        auto rit = std::find(yc.conns.begin(), yc.conns.end(), px);
        if (rit == yc.conns.end()) {
          if (++prev == h.end()) {
            prev = h.begin();
          }
          continue;
        }
        rit++;
        while (rit != yc.conns.end()) {
          auto &oth = cities[*rit];
          oth.conns.erase(oth.connRanks[it->second]);
          rit = yc.conns.erase(rit);
        }
        if (++prev == h.end()) {
          prev = h.begin();
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (cities[i].conns.size() != 1) {
      cout << -1 << endl;
      exit(EXIT_SUCCESS);
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << *cities[i].conns.begin() << endl;
  }
  return 0;
}