#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  string ans(N, 'p');
  bool f = true;
  int a;
  char c;
  for (int i = 0; i < (int)(M); i++) {
    cin >> a;
    cin >> c;
    a--;
    if (a == 0 && c == '0')
      f = false;
    else if (ans[a] == 'p' || ans[a] == c) {
      ans[a] = c;
    } else
      f = false;
  }
  if (ans[0] == 'p') ans[0] = '1';
  for (int i = 1; i < (int)(N); i++)
    if (ans[i] == 'p') ans[i] = '0';
  if (f)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
