#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  string ans;
  for (auto i = 0LL; i < N; i++) {
    ans.push_back('o');
  }
  for (auto i = 0LL; i < M; i++) {
    long long s, c;
    cin >> s >> c;
    if (s > N) {
      cout << -1 << endl;
      return 0;
    } else if (ans[s - 1] == 'o') {
      ans[s - 1] = '0' + c;
    } else if (ans[s - 1] != '0' + c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (ans[0] == 'o') {
    if (N == 1) {
      cout << 0 << endl;
      return 0;
    }
    ans[0] = '1';
  }
  for (auto i = 1LL; i < N; i++) {
    if (ans[i] == 'o') {
      ans[i] = '0';
    }
  }
  cout << ans << endl;
  return 0;
}
