#include <bits/stdc++.h>
using namespace std;
using bigint = long long int;
using vi = vector<int>;
bigint arr[300011];
int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  bool flag = true;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    if (m.find(x) == m.end()) {
      m[x] = y;
    } else if (m[x] != y)
      flag = false;
  }
  if (flag == false) {
    cout << "-1"
         << "\n";
    return 0;
  }
  for (auto x : m) cout << x.first << " " << x.second << "\n";
  for (int i = 0; i < 10000; i++) {
    int digits = log10(i) + 1;
    if (i == 0) digits = 1;
    if (digits != N) continue;
    string str = to_string(i);
    bool f = true;
    for (auto x : m) {
      if (str[x.first] - '0' != x.second) {
        f = false;
      }
    }
    if (f == true) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << "-1"
       << "\n";
  return 0;
}
