#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (long long i = 0; i < (long long)(m); ++i) cin >> s[i] >> c[i];
  string ans = "";
  for (long long i = 0; i < (long long)(n); ++i) ans += "_";
  for (long long i = 0; i < (long long)(m); ++i) {
    if (ans[s[i] - 1] == '_' || ans[s[i] - 1] - '0' == c[i]) {
      ans[s[i] - 1] = to_string(c[i])[0];
    } else {
      cout << -1 << endl;
      return 0;
    }
    if (s[i] == 1 && n > 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < (long long)(n); ++i) {
    if (ans[i] == '_') {
      if (i == 0)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
  }
  cout << ans << endl;
  return 0;
}
