#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, '0');
  res[0] = '1';
  for (long i = 0; i < m; ++i) cin >> s[i].first >> s[i].second;
  sort(s.begin(), s.end());
  if (s[0].first == 1 && s[0].second == 0) return cout << -1, 0;
  for (long i = 0; i < m; ++i) {
    if (i && s[i].first == s[i - 1].first && s[i].second != s[i - 1].second)
      return cout << -1, 0;
    res[s[i].first - 1] = '0' + s[i].second;
  }
  cout << res;
}
