#include <bits/stdc++.h>
using namespace std;
using pi = pair<long, long>;
signed main() {
  long n, m;
  cin >> n >> m;
  vector<pi> s(m);
  string res(n, 'x');
  for (long i = 0; i < m; ++i) cin >> s[i].first >> s[i].second, --s[i].first;
  if (m) {
    for (long i = 0; i < m; ++i) {
      if (res[s[i].first] != 'x' && res[s[i].first] != '0' + s[i].second)
        return cout << -1, 0;
      res[s[i].first] = '0' + s[i].second;
    }
  }
  if (res[0] == '0') return cout << -1, 0;
  for (long i = 0; i < n; ++i)
    if (res[i] == 'x') res[i] = (i || n == 1 ? '0' : '1');
  cout << res;
}
