#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string ans(n, 'a');
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] != 'a' && ans[s - 1] != '0' + c) {
      cout << -1 << endl;
      return 0;
    }
    ans[s - 1] = '0' + c;
  }
  if (ans[0] == '0' && n > 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i] == 'a') ans[i] = (i == 0 ? '1' : '0');
  }
  cout << ans << endl;
  return 0;
}
