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