#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> s(m), c(m);
  for (long long i = 0; i < m; i++) cin >> s[i] >> c[i];
  string ans = string(n, 'X');
  for (long long i = 0; i < m; i++) {
    if (ans[s[i] - 1] == 'X') {
      ans[s[i] - 1] = c[i] + '0';
    } else if (ans[s[i] - 1] != c[i] + '0') {
      ans = "-1";
      break;
    }
  }
  if (n > 1 && ans[0] == '0') ans = "-1";
  if (ans[0] == 'X') ans[0] = '1';
  for (auto &&i : ans) {
    if (i == 'X') i = '0';
  }
  cout << ans << endl;
}
