#include <bits/stdc++.h>
using namespace std;
const int intinf = numeric_limits<int>::max();
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
void solve() {
  int N, M;
  vector<int> s(M), c(M);
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  vector<int> ans(N + 1, -1);
  bool is_exist = true;
  for (int i = 0; i < M; i++) {
    if (ans[s[i]] == -1) {
      ans[s[i]] = c[i];
    } else if (ans[s[i]] != c[i]) {
      is_exist = false;
    }
  }
  if (N > 1 && ans[1] == 0) {
    is_exist = false;
  }
  if (is_exist) {
    for (int j = 1; j <= N; j++) {
      if (ans[j] == -1) {
        if (N > 1 && j == 1) {
          ans[j] = 1;
        } else {
          ans[j] = 0;
        }
      }
    }
    for (int j = 1; j <= N; j++) {
      cout << ans[j];
    }
    cout << endl;
  } else {
    cout << "-1" << endl;
  }
  return;
}
int main() {
  solve();
  return 0;
}
