#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  string final(n, '#');
  bool ans = true;
  for (long long i = 0; i < m; ++i) {
    long long u;
    char c;
    cin >> u >> c;
    --u;
    if (u < n && final[u] == '#') {
      final[u] = c;
    }
  }
  if (n > 1 && final[0] == '0') {
    cout << -1;
    return 0;
  }
  if (final[0] == '#') final[0] = '1';
  for (long long i = 1; i < n; ++i) {
    if (final[i] == '#') final[i] = '0';
  }
  cout << final;
}
