#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ok(n + 1, false);
  vi ans(n + 1);
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ok[s] && ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    ok[s] = true;
    ans[s] = c;
  }
  for (int i = 1; i <= n; i++) {
    if (ok[i]) continue;
    if (i == 1)
      ans[1] = 1;
    else
      ans[i] = 0;
  }
  for (int i = 0; i < (int)(n); i++) cout << ans[i + 1];
}
