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