#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  string ans = "";
  for (int i = 0; i < n; i++) {
    ans += "-";
  }
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] != '-' && ans[s] != c) {
      cout << "-1\n";
      return 0;
    }
    ans[s] = c;
  }
  if (n != 1 && ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (ans[0] == '-') ans[0] = '1';
  for (int i = 1; i < n; i++) {
    if (ans[i] == '-') ans[i] = '0';
  }
  cout << ans << endl;
}
