#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string ans(N, '?');
  bool isok = true;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != '?' && ans[s] != '0' + c) {
      isok = false;
    }
    ans[s] = '0' + c;
  }
  if (!isok || (N > 1 && ans[0] == '0')) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < N; i++)
      if (ans[i] == '?') {
        ans[i] = '0' + (i ? 0 : 1);
      }
    cout << ans << endl;
  }
  return 0;
}
