#include <bits/stdc++.h>
using namespace std;
struct nod {
  int a, b, hao, zhi;
};
nod ans[110000], shu[110000], num[110000];
int now, l, i, n, m;
bool cmp(nod a, nod b) {
  if (a.b != b.b) return (a.b > b.b);
  return (a.a < b.a);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) scanf("%d%d", &num[i].a, &num[i].b), num[i].hao = i;
  sort(num + 1, num + 1 + m, cmp);
  for (i = 1; i < n; i++) {
    ans[i].a = i;
    ans[i].b = i + 1;
    ans[i].zhi = num[i].a;
    shu[num[i].hao].a = i;
    shu[num[i].hao].b = i + 1;
  }
  i = n;
  now = 2;
  l = 1;
  while (i <= m) {
    if (l >= now) {
      l = 1;
      now++;
    }
    if (num[i].a < ans[now].zhi) {
      printf("-1\n");
      return 0;
    }
    shu[num[i].hao].a = l;
    shu[num[i].hao].b = now + 1;
    i++;
    l++;
  }
  for (i = 1; i <= m; i++) printf("%d %d\n", shu[i].a, shu[i].b);
}
