#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
void split(char *input, char *tokens, vector<string> &v) {
  v.clear();
  char *p;
  p = strtok(input, tokens);
  while (p != NULL) {
    v.push_back(p);
    p = strtok(NULL, tokens);
  }
}
double dabs(double a) { return (a < 0) ? (a * -1) : a; }
int dcomp(double a, double b) {
  if (a - b > 1e-9)
    return 1;
  else if (b - a > 1e-9)
    return -1;
  return 0;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > vec;
  vector<pair<int, pair<int, int> > > vt, ans;
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    vec.push_back(pair<int, int>(a, b));
    vt.push_back(pair<int, pair<int, int> >(a, pair<int, int>(b * -1, i)));
  }
  sort(vt.begin(), vt.end());
  long long nodCon = 1;
  long long arDis = 0;
  long long arCon = 0;
  int sz = vt.size();
  bool mal = false;
  int aux = 2;
  a = 2;
  b = 3;
  for (int i = 0; (i < sz) && !mal; i++) {
    pair<int, pair<int, int> > temp = vt[i];
    if (temp.second.first != 0) {
      nodCon++;
      arDis = ((nodCon - 1) * nodCon) / 2;
      ans.push_back(pair<int, pair<int, int> >(temp.second.second,
                                               pair<int, int>(1, aux)));
      aux++;
    } else {
      ans.push_back(
          pair<int, pair<int, int> >(temp.second.second, pair<int, int>(a, b)));
      a++;
      if (a == b) {
        b++;
        a = 2;
      }
    }
    arCon++;
    if (arDis < arCon) mal = true;
  }
  if (mal) {
    printf("-1");
  } else {
    sort(ans.begin(), ans.end());
    sz = ans.size();
    for (int i = 0; i < sz; i++) {
      printf("%d %d\n", ans[i].second.first, ans[i].second.second);
    }
  }
  return 0;
}
