#include <bits/stdc++.h>
using namespace std;
int n, m;
struct edge {
  int u, v;
  int weight;
  int index;
  int mini;
  edge();
  edge(int a, int b, int c) : weight(a), index(c), mini(b) {}
};
bool comp1(edge& a1, edge& a2) {
  return a1.weight < a2.weight || (a1.weight == a2.weight && a1.mini > a2.mini);
}
bool comp2(edge& a1, edge& a2) { return a1.index < a2.index; }
vector<edge> vec;
int cur = 1;
int cnt[100010];
int main() {
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    vec.push_back(edge(a, b, i));
  }
  sort(vec.begin(), vec.end(), comp1);
  for (int i = 1; i <= n; i++) {
    cnt[i] = i;
  }
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i].mini) {
      vec[i].u = 0;
      vec[i].v = cur++;
    } else {
      bool ok = false;
      for (int j = 1; j < cur; j++) {
        if (cnt[j] < cur - 1) {
          cnt[j]++;
          vec[i].u = j;
          vec[i].v = cnt[j];
          ok = true;
          break;
        }
      }
      if (!ok) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  sort(vec.begin(), vec.end(), comp2);
  for (int i = 0; i < vec.size(); i++) {
    printf("%d %d\n", vec[i].u + 1, vec[i].v + 1);
  }
  return 0;
}
