#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  memset(a, -1, sizeof(a));
  bool flag = false;
  for (int i = 1; i <= m; i++) {
    int c, b;
    cin >> c >> b;
    if (a[c] != -1 && a[c] != b)
      flag = true;
    else
      a[c] = b;
  }
  if (m == 0) {
    cout << 1;
    for (int i = 1; i <= n - 1; i++) cout << 0;
    return 0;
  }
  if (a[1] == 0 || flag) {
    cout << -1;
    return 0;
  }
  if (a[1] == -1) a[1] = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1)
      cout << 0;
    else
      cout << a[i];
  }
  return 0;
}
