#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > edges;
int u[100007];
int v[100007];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    pair<pair<int, int>, int> t;
    cin >> t.first.first;
    cin >> t.first.second;
    t.first.second ^= 1;
    t.second = i;
    edges.push_back(t);
  }
  sort(edges.begin(), edges.end());
  if (edges[0].first.second == 1) {
    cout << "-1" << endl;
    return 0;
  }
  u[edges[0].second] = 1;
  v[edges[0].second] = 2;
  int formed = 2;
  int p = 2;
  int q = 3;
  for (int i = 1; i < m; i++) {
    if (edges[i].first.second == 1) {
      if (q > formed) {
        cout << "-1\n";
        return 0;
      } else {
        u[edges[i].second] = p;
        v[edges[i].second] = q;
        p++;
        if (p == q) {
          p = 2;
          q++;
        }
      }
    } else {
      u[edges[i].second] = 1;
      formed++;
      v[edges[i].second] = formed;
    }
  }
  for (int i = 0; i < m; i++) cout << u[i] << " " << v[i] << endl;
  return 0;
}
