#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int maxN = 1 << 17;
bool vis[maxN];
char out[maxN];
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  out[n] = 0;
  bool fail = false;
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    if (vis[a] and (out[a] - '0') != b)
      fail = true;
    else
      out[a] = ('0' + b), vis[a] = true;
  }
  if (n != 1 and vis[0] and out[0] == '0') fail = true;
  for (int i = (0); i < (int)(n); i++)
    if (!vis[i]) out[i] = i == 0 ? '1' : '0';
  if (fail)
    printf("-1\n");
  else
    printf("%s\n", out);
}
int main() {
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
