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