#include <bits/stdc++.h>
const long long base = 31;
const long long MOD = 1e9 + 9;
const long long maxN = 1e6 + 9;
using namespace std;
int a[101];
int32_t main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) a[i] = 1000;
  if (m == 0) cout << 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    a[x] = min(a[x], y);
  }
  if (a[1] == 1000 || a[1] == 0)
    cout << -1;
  else {
    for (int i = 1; i <= n; i++)
      if (a[i] == 1000)
        cout << 0;
      else
        cout << a[i];
  }
  return 0;
}
