#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, m;
  cin >> n >> m;
  string ans = "";
  for (long long i = 0; i < n; ++i) ans += " ";
  vector<pair<long long, char>> p(m);
  for (long long i = 0; i < m; ++i) {
    cin >> p[i].first >> p[i].second;
    --p[i].first;
  }
  sort(p.begin(), p.end());
  for (long long i = 0; i < m; ++i) {
    long long s = p[i].first;
    char c = p[i].second;
    if (s == 0 && c == '0') {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s] == ' ')
      ans[s] = c;
    else if (ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < n; ++i) {
    if (ans[i] == ' ') {
      if (i == 0) {
        ans[i] = '1';
      } else {
        ans[i] = '0';
      }
    }
  }
  for (long long i = 0; i < n; ++i) cout << ans[i];
}
