#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> S(m), C(m);
  for (int i = 0; i < m; ++i) {
    cin >> S[i] >> C[i];
  }
  string ans;
  for (int i = 0; i < n; ++i) {
    ans += "x";
  }
  for (int i = 0; i < m; ++i) {
    int ix = S[i] - 1;
    if (n != 1 && S[i] == 1 && C[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[ix] != 'x' && ans[ix] != '0' + C[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans[ix] = '0' + C[i];
  }
  for (int i = 0; i < ans.size(); ++i) {
    if (ans[i] == 'x') {
      if (i == 0) {
        ans[i] = '1';
      } else {
        ans[i] = '0';
      }
    }
  }
  cout << ans << endl;
  return 0;
}
