#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-10;
const int inf = 2000000000;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
inline bool checkBit(long long int n, long long int i) {
  return n & (1LL << i);
}
inline long long int setBit(long long int n, long long int i) {
  return n | (1LL << i);
  ;
}
inline long long int resetBit(long long int n, long long int i) {
  return n & (~(1LL << i));
}
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long int year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long int &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long int modMul(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long int modAdd(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long int modSub(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long int modPow(long long int b, long long int p) {
  long long int r = 1LL;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1LL;
  }
  return r;
}
inline long long int modDiv(long long int a, long long int b) {
  return modMul(a, modPow(b, 1000000007 - 2));
}
bool comp(const pair<pair<long long int, long long int>, long long int> &p1,
          const pair<pair<long long int, long long int>, long long int> &p2) {
  if (p1.first.second == p2.first.second) {
    return p1.first.first < p2.first.first;
  }
  return p1.first.second > p2.first.second;
}
bool comp2(const pair<pair<long long int, long long int>, long long int> &p1,
           const pair<pair<long long int, long long int>, long long int> &p2) {
  if (p1.first.second == p2.first.second) {
    return p1.first.first > p2.first.first;
  }
  return p1.first.second > p2.first.second;
}
long long int converter(string a) {
  long long int i, mul = 1, r, t, ans = 0LL;
  if (a.length() == 0) return 0;
  for (i = a.length() - 1; i >= 0; i--) {
    t = a[i] - '0';
    r = t % 10;
    ans += (mul * r);
    mul = mul * 10;
  }
  return ans;
}
pair<pair<long long int, long long int>, long long int> store[100005];
vector<pair<long long int, pair<long long int, long long int> > > ans;
vector<pair<long long int, long long int> > ed;
long long int got[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m, i, w, mxima = 0;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    long long int w, taken;
    cin >> w >> taken;
    store[i] = make_pair(make_pair(w, taken), i);
  }
  sort(store + 1, store + m + 1, comp);
  long long int x = 1;
  long long int y = 2;
  for (i = 1; i <= n - 1; i++) {
    w = store[i].first.first;
    ans.push_back(make_pair(store[i].second, make_pair(x, y)));
    got[y] = w;
    x = y;
    y++;
  }
  long long int cnt = 0;
  long long int tempx, tempy = 3;
  while (cnt < (m - (n - 1))) {
    tempx = 1;
    while ((tempy - tempx) >= 2 && cnt < (m - (n - 1))) {
      ed.push_back(make_pair(tempx, tempy));
      tempx++;
      cnt++;
    }
    tempy++;
  }
  long long int j = 0;
  for (i = n; i <= m; i++) {
    if (j >= ed.size()) continue;
    x = ed[j].first;
    y = ed[j].second;
    w = store[i].first.first;
    if (got[y] <= w) ans.push_back(make_pair(store[i].second, make_pair(x, y)));
    j++;
  }
  if (ans.size() < m) {
    cout << "-1";
    return 0;
  }
  sort(ans.begin(), ans.end());
  for (i = 0; i < m; i++) {
    cout << ans[i].second.first << " " << ans[i].second.second << '\n';
  }
  return 0;
}
