#include <bits/stdc++.h>
using namespace std;
template <class Type_a, class Type_b>
bool chmax(Type_a &a, const Type_b &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class Type_a, class Type_b>
bool chmin(Type_a &a, const Type_b &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class Type>
void line(const Type &a) {
  int cnt = 0;
  for (const auto &elem : a) {
    if (cnt++) cout << ' ';
    cout << elem;
  }
  cout << endl;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  string ans = "nnn";
  for (int i = 0; i < (m); ++i) {
    int p = s[i] - 1;
    if (ans[p] == 'n') {
      ans[p] = '0' + c[i];
    } else {
      if (ans[p] - '0' == c[i]) {
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  } else {
    if (ans[0] == 'n') ans[0] = '1';
  }
  for (int i = 1; i < n; ++i) {
    if (ans[i] == 'n') ans[i] = '0';
  }
  for (int i = 0; i < (n); ++i) cout << ans[i];
  cout << endl;
}
