#include <bits/stdc++.h>
using namespace std;
int n, m, mx;
int s[100001];
int c[100001];
int a[100001];
bool dfs(int x, int pre) {
  if (x == mx + 1) return pre;
  if (a[x] != -1) return dfs(x + 1, pre | a[x]);
  if (pre) {
    a[x] = 0;
    return dfs(x + 1, pre);
  } else {
    a[x] = 1;
    return dfs(x + 1, 1);
  }
}
signed main() {
  scanf("%d%d", &n, &m);
  memset(a, -1, sizeof(a));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &s[i], &c[i]);
    mx = max(s[i], mx);
    if (a[s[i]] != -1 && a[s[i]] != c[i]) {
      printf("-1");
      return 0;
    }
    a[s[i]] = c[i];
  }
  if (!dfs(1, 0))
    printf("-1");
  else
    for (int i = 1; i <= n; i++) printf("%d", a[i]);
  return 0;
}
