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