#include <bits/stdc++.h>
using namespace std;
const int MX_SZ = 1e+5 + 42;
const int INF = 1e+9 + 42;
struct node {
  int nm, a, b;
  node() {}
  node(int nm, int a, int b) : nm(nm), a(a), b(b) {}
};
inline bool compare(const node n1, const node n2) {
  if (n1.a != n2.a) {
    return n1.a < n2.a;
  } else {
    return n1.b > n2.b;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  vector<node> g;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g.push_back(node(i, a, b));
  }
  sort(g.begin(), g.end(), compare);
  vector<pair<int, int>> ans(MX_SZ);
  bool used[MX_SZ];
  memset(used, false, sizeof(used));
  int frst = 2;
  int x = 2, y = 3;
  for (int i = 0; i < m; i++) {
    if (g[i].b == 1) {
      ans[g[i].nm] = {1, frst};
      used[frst] = true;
      frst++;
    } else {
      if (x == y) {
        x = 2;
        y++;
      }
      if (!used[y]) {
        cout << -1;
        return 0;
      }
      ans[g[i].nm] = {x, y};
      x++;
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i].first << " " << ans[i].second << '\n';
  }
}
