#include <bits/stdc++.h>
using namespace std;
int a[100];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1, x1, x2; i <= m; i++) {
    cin >> x1 >> x2;
    if (!a[x1])
      a[x1] = x2;
    else
      a[x1] = min(a[x1], x2);
  }
  if (!a[1])
    cout << -1 << '\n';
  else {
    for (int i = 1; i <= n; i++) {
      cout << a[i];
    }
  }
}
