#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  long long n, m;
  cin >> n >> m;
  string ans;
  ans.resize(n);
  for (long long i = 0; i < (n); ++i) {
    ans[i] = '.';
  }
  for (long long i = 0; i < (m); ++i) {
    long long s, c;
    cin >> s >> c;
    --s;
    if (ans[s] != '.' && (ans[s] != ('0' + c))) {
      cout << -1;
      return 0;
    }
    ans[s] = ('0' + c);
  }
  if (ans[0] == '0' && (n > 1)) {
    cout << -1;
    return 0;
  }
  if (ans[0] == '.') ans[0] = '1';
  for (long long i = 1; i < n; ++i) {
    if (ans[i] == '.') ans[i] = '0';
  }
  cout << ans;
}
