#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  string ans(n, '0');
  for (long long i = 0; i < m; i++) {
    long long s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] != '0') {
      if (ans[s] != c) {
        cout << -1 << '\n';
        return 0;
      }
    } else {
      if (s == 0) {
        if (c == '0') {
          cout << -1 << '\n';
          return 0;
        }
      }
      ans[s] = c;
    }
  }
  if (m == 0) {
    cout << 0 << '\n';
    return 0;
  }
  if (ans[0] == '0') ans[0] = '1';
  cout << ans << '\n';
  return 0;
}
