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