#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m], c[m], ans[n];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  if (m >= n) {
    for (int i = 0; i < n; i++) {
      ans[i] = 0;
      for (int j = 0; j < m; j++) {
        int temp = s[j];
        if (ans[temp - 1] == 0) ans[temp - 1] = c[j];
      }
      cout << ans[i];
    }
  } else
    cout << "-1";
}
