#include <bits/stdc++.h>
using namespace std;
void printVector(const vector<int>& vec) {
  for (int value : vec) {
    if (value == INT_MAX) value = 0;
    cout << value << "";
  }
  cout << endl;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m, 0);
  vector<int> c(m, 0);
  vector<int> ans(m, INT_MAX);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  for (int i = 0; i < m; i++) {
    if (c[i] < ans[s[i] - 1]) ans[s[i] - 1] = c[i];
  }
  if (ans[0] == 0 || ans[0] == INT_MAX)
    cout << -1 << endl;
  else {
    printVector(ans);
  }
  return 0;
}
