#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string ans(n, '-');
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    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[0] == '-') ans[0] = '1';
  for (int i = 1; i < n; i++) {
    if (ans[i] == '-') ans[i] = '0';
  }
  if (ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}
