#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  string ans(N, '_');
  while (M--) {
    int s, c;
    cin >> s >> c;
    --s;
    if (ans[s] == '_') {
      ans[s] = '0' + c;
    } else if (ans[s] != '0' + c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans.front() == '_') {
    ans.front() = '1';
  }
  for (int i = 1; i < ans.size(); i++) {
    if (ans[i] == '_') {
      ans[i] = '0';
    }
  }
  if (ans.size() > 1 && ans[0] == '0') {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
