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