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