#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<int, int> > > temp;
vector<pair<int, int> > poss;
vector<pair<int, pair<int, int> > > res;
int size;
int size1;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int(i) = 0; (i) < (m); (i)++) {
    int a, b;
    cin >> a >> b;
    temp.push_back(make_pair(a, make_pair(-b, i)));
  }
  sort(temp.begin(), temp.end());
  int cur = 2;
  size = 0;
  size1 = 0;
  for (int(i) = 0; (i) < (m); (i)++) {
    if (temp[i].second.first == -1) {
      res.push_back(make_pair(temp[i].second.second, make_pair(1, cur)));
      for (int(j) = 0; (j) < (cur - 2); (j)++) {
        if (size == 100002) break;
        poss.push_back(make_pair(j + 2, cur));
        size++;
      }
      cur++;
    } else {
      if (size1 >= size) {
        cout << "-1\n";
        return 0;
      } else {
        res.push_back(
            make_pair(temp[i].second.second,
                      make_pair(poss[size1].first, poss[size1].second)));
        size1++;
      }
    }
  }
  sort(res.begin(), res.end());
  for (int(i) = 0; (i) < (m); (i)++) {
    cout << res[i].second.first << " " << res[i].second.second << endl;
  }
  return 0;
}
