#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> s;
  int keta = 0;
  for (int i = 0; i < (int)(m); i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    if (auto iter = s.find(tmp1); iter != end(s)) {
      cout << -1 << endl;
      return 0;
    }
    s[tmp1] = tmp2;
    keta = max(keta, tmp1);
    if (tmp1 == 1 && tmp2 == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (const auto& [key, value] : s) {
    if (value != 0) {
      int tmp = 1;
      for (int i = 0; i < (int)(keta - key); i++) {
        tmp *= 10;
      }
      ans += value * tmp;
      cout << value << endl;
    }
  }
  cout << ans << endl;
}
