#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, r, c;
  int m;
  cin >> n >> m;
  int i = 0;
  vector<tuple<int, int, int>> v(m);
  while (i < m) {
    cin >> r >> c;
    v[i] = make_tuple(r, -c, i);
    i++;
  }
  sort(v.begin(), v.end());
  vector<tuple<int, int, int>> connected;
  vector<int> isolated_vertices(n + 1, 1);
  isolated_vertices[1] = 0;
  int from = 2, to = 3, node = 1;
  for (int i = 0; i < m; ++i) {
    if (get<1>(v[i]) == -1) {
      connected.push_back(make_tuple(get<2>(v[i]) + 1, 1, (int)node + 1));
      node++;
      isolated_vertices[node] = 0;
    } else {
      if (isolated_vertices[to] == 1) {
        cout << -1;
        return 0;
      }
      connected.push_back(make_tuple(get<2>(v[i]) + 1, from, to));
      from++;
      if (from == to) {
        to++;
        from = 2;
      }
    }
  }
  sort(connected.begin(), connected.end());
  for (auto e : connected) {
    cout << get<1>(e) << " " << get<2>(e);
    cout << '\n';
  }
  return 0;
}
