#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll LINF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < (m); i++) cin >> s[i] >> c[i];
  vector<int> r(n, -1);
  for (int i = 0; i < (m); i++) {
    if (r[s[i] - 1] == c[i]) {
      ;
    } else if (r[s[i] - 1] != -1) {
      cout << -1 << endl;
      return 0;
    } else {
      r[s[i] - 1] = c[i];
    }
  }
  if (r[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (r[0] == -1) {
    r[0] = 1;
  }
  for (int i = (1); i < (n); i++) {
    if (r[i] == -1) {
      r[i] = 0;
    }
  }
  for (int i = 0; i < (n); i++) {
    cout << r[i];
  }
  cout << endl;
  return 0;
}
