#include <bits/stdc++.h>
using namespace std;
int n, m, tot, x, y, ans[100100][2];
struct edge {
  int w, flag, id;
  inline bool operator<(const edge &x) const {
    return w < x.w || w == x.w && flag > x.flag;
  }
} e[100100];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &e[i].w, &e[i].flag), e[i].id = i;
  sort(e + 1, e + 1 + m), tot = x = 1, y = 2;
  for (int i = 1; i <= m; ++i)
    if (e[i].flag)
      ans[e[i].id][0] = 1, ans[e[i].id][1] = ++tot;
    else {
      if (++x == y) x = 2, ++y;
      if (y > tot) {
        printf("-1\n");
        return 0;
      }
      ans[e[i].id][0] = x, ans[e[i].id][1] = y;
    }
  if (tot != n)
    printf("-1\n");
  else
    for (int i = 1; i <= m; ++i) printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
