#include <bits/stdc++.h>
using namespace std;
struct abc {
  int val, key, s, e, ind;
} z[100005];
bool cmp(abc a, abc b) {
  if (a.key == b.key) return a.val < b.val;
  return a.key > b.key;
}
bool cmp1(abc a, abc b) { return a.ind < b.ind; }
int main() {
  int n, m, i, j, k, a[100005], l;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &z[i].val);
    scanf("%d", &z[i].key);
    z[i].ind = i;
  }
  sort(z, z + m, cmp);
  for (i = 0; i < n - 1; i++) {
    z[i].s = i + 1;
    z[i].e = i + 2;
  }
  l = 1;
  j = 1;
  k = 3;
  for (i = n - 1; i < m; i++) {
    if (z[i].val >= z[k - 2].val) {
      z[i].s = j;
      z[i].e = k;
      j++;
      if (j == k - 1) {
        j = 1;
        k++;
      }
    } else {
      l = 0;
      break;
    }
  }
  if (l == 0)
    printf("-1\n");
  else {
    sort(z, z + m, cmp1);
    for (i = 0; i < m; i++) printf("%d %d\n", z[i].s, z[i].e);
  }
  return 0;
}
