#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int MAXK = -1;
const int MAXN = 602;
const int MOD = 1;
int n;
int pc[MAXN];
int c[MAXN];
int nxt[MAXN];
void read(int &x) {
  string s;
  cin >> s;
  if (s == "?") {
    x = -1;
    return;
  }
  stringstream ss;
  ss << s;
  ss >> x;
}
vector<pair<int, int> > o;
bool eq(int x, int y) { return x == y || y == -1; }
vector<int> e[MAXN];
int mt[MAXN], ttm[MAXN];
int vis[MAXN], tmr;
bool dfs(int v) {
  if (vis[v] == tmr) return 0;
  vis[v] = tmr;
  for (int to : e[v]) {
    if (mt[to] == -1) {
      mt[to] = v;
      ttm[v] = to;
      return 1;
    }
  }
  for (int to : e[v]) {
    if (dfs(mt[to])) {
      mt[to] = v;
      ttm[v] = to;
      return 1;
    }
  }
  return 0;
}
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      read(pc[i]);
      read(c[i]);
      nxt[i] = -1;
    }
    map<int, map<int, vector<int> > > mp;
    for (int i = 0; i < n; i++) {
      mp[c[i]][pc[i]].push_back(i);
    }
    bool ok = 0;
    int nmx = 0;
    if (mp.count(-1)) {
      nmx = max(0, mp[-1].rbegin()->first);
    }
    vector<int> mx(n + 1, -1);
    for (int i = 1; i <= n; i++) {
      if (!mp.count(i)) continue;
      mx[i] = mp[i].rbegin()->first;
    }
    for (int nc = 1; nc <= n; nc++) {
      bool wasnt = !mp.count(nc);
      mp[nc];
      int old = mx[nc];
      mx[nc] = max(mx[nc], nmx);
      o.clear();
      for (int cc = 1; cc <= n; cc++) {
        if (!mp.count(cc)) continue;
        vector<int> vct = mp[cc][0];
        vector<int> vv;
        vector<vector<int> > cycles;
        for (int x : vct) {
          if (vv.size() == cc) {
            for (int i = 0; i < (int)vv.size(); i++)
              nxt[vv[i]] = vv[(i + 1) % vv.size()];
            cycles.push_back(vv);
            vv.clear();
          }
          vv.push_back(x);
        }
        for (int i = 0; i < cc - (int)vv.size(); i++) {
          o.push_back(make_pair(0, cc));
        }
        for (int i = 1; i <= mx[cc]; i++) {
          if (!mp[cc].count(i)) {
            o.push_back(make_pair(i, cc));
          }
        }
      }
      int m = o.size();
      for (int i = 0; i < m; i++) {
        e[i].clear();
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if ((pc[i] == -1 || c[i] == -1) && eq(o[j].first, pc[i]) &&
              eq(o[j].second, c[i])) {
            e[j].push_back(i);
          }
        }
      }
      for (int i = 0; i < n; i++) {
        mt[i] = -1;
      }
      for (int i = 0; i < m; i++) {
        ttm[i] = -1;
      }
      for (int run = 1; run;) {
        run = 0;
        tmr++;
        for (int i = 0; i < m; i++) {
          if (ttm[i] == -1 && dfs(i)) {
            run = 1;
          }
        }
      }
      bool cok = 1;
      for (int i = 0; i < m; i++) cok &= ttm[i] != -1;
      if (cok) {
        for (int i = 0; i < n; i++) {
          if (mt[i] != -1) {
            pc[i] = o[mt[i]].first;
            c[i] = o[mt[i]].second;
          }
        }
        ok = 1;
        break;
      }
      mx[nc] = old;
      if (wasnt) mp.erase(nc);
    }
    if (ok) {
      vector<vector<int> > vv(n + 1);
      for (int i = 0; i < n; i++) {
        if (nxt[i] == -1 && pc[i] == 0 && c[i] != -1) {
          vv[c[i]].push_back(i);
        }
      }
      for (int i = 0; i <= n; i++) {
        for (int j = 0; j < (int)vv[i].size(); j++) {
          nxt[vv[i][j]] = vv[i][(j + 1) % vv[i].size()];
        }
      }
      int mxc = 0;
      for (int i = 0; i <= n; i++)
        if (mx[i] > mx[mxc]) mxc = i;
      for (int i = 0; i < n; i++) {
        if (nxt[i] != -1) continue;
        if ((c[i] == -1 || c[i] == 1) && pc[i] == 0) {
          nxt[i] = i;
          continue;
        }
        if (pc[i] == -1) pc[i] = 1;
        if (c[i] == -1) {
          c[i] = mxc;
        }
        for (int j = 0; j < n; j++) {
          if (c[j] == c[i] && pc[j] + 1 == pc[i]) {
            nxt[i] = j;
            break;
          }
        }
        assert(nxt[i] != -1);
      }
      for (int i = 0; i < n; i++) cout << nxt[i] + 1 << " \n"[i + 1 == n];
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
