#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > A;
vector<pair<pair<int, int>, int> > B;
int counti = 0;
bool mysort(pair<pair<int, int>, int>& A, pair<pair<int, int>, int>& B) {
  if (A.first.first == B.first.first) return A.first.second > B.first.second;
  return A.first.first < B.first.first;
}
bool mysort1(pair<pair<int, int>, int>& A, pair<pair<int, int>, int>& B) {
  return A.second < B.second;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    A.push_back(make_pair(make_pair(x, y), i));
  }
  sort(A.begin(), A.end(), mysort);
  int a = 3;
  int b = 2;
  int c = 1;
  for (int i = 0; i < m; i++) {
    if (A[i].first.second == 1) {
      B.push_back(make_pair(make_pair(++c, 1), A[i].second));
    } else {
      if (a == b) {
        b = 2;
        a++;
        B.push_back(make_pair(make_pair(a, b++), A[i].second));
      } else
        B.push_back(make_pair(make_pair(a, b++), A[i].second));
      if (a > c) {
        cout << -1;
        return 0;
      }
    }
  }
  sort(B.begin(), B.end(), mysort1);
  for (int i = 0; i < B.size(); i++)
    cout << B[i].first.first << " " << B[i].first.second << "\n";
}
