#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int INF = 0x3f3f3f3f;
int a[N];
bool vis[N];
int main() {
  int n, m, pos, val;
  scanf("%d%d", &n, &m);
  bool f = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &pos, &val);
    if (vis[pos]) {
      f = 0;
    }
    vis[pos] = 1;
    a[pos] = val;
  }
  if (f)
    printf("-1\n");
  else {
    bool f2 = 0, f3 = 0;
    for (int i = 1; i < n; ++i) {
      if (a[i]) f2 = 1;
      if (!f2 && !a[i]) {
        f3 = 1;
        break;
      }
    }
    if (f3)
      printf("-1\n");
    else {
      for (int i = 1; i <= n; ++i) printf("%d", a[i]);
    }
  }
  return 0;
}
