#include <bits/stdc++.h>
using namespace std;
int n, m, act;
vector<pair<int, pair<int, int> > > edge, ans;
int viz[100005];
int first, last;
bool srt(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  if (a.first != b.first) return a.first < b.first;
  if (a.second.first != b.second.first) return a.second.first > b.second.first;
  return a.second.second < b.second.second;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    edge.push_back({x, {y, i}});
  }
  sort(edge.begin(), edge.end(), srt);
  first = 2, last = 3;
  act = 2;
  for (int i = 0; i < edge.size(); ++i) {
    if (edge[i].second.first) {
      ans.push_back({edge[i].second.second, {1, act}});
      viz[act] = 1;
      act++;
    } else {
      if (!viz[first] || !viz[last]) {
        cout << -1;
        return 0;
      }
      ans.push_back({edge[i].second.second, {first, last}});
      first++;
      if (first == last) {
        last++;
        first = 2;
      }
    }
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); ++i)
    cout << ans[i].second.first << ' ' << ans[i].second.second << '\n';
  return 0;
}
