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