#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> s, c;
int main() {
  cin >> N >> M;
  s.resize(M);
  c.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  string digits(N, 'a');
  for (int i = 0; i < M; i++) {
    if (digits[s[i]] == 'a') {
      digits[s[i]] = c[i] + '0';
    }
    if (digits[s[i]] != c[i] + '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  if (digits[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (digits[0] == 'a') {
    digits[0] = '1';
  }
  for (int i = 1; i < N; i++) {
    if (digits[i] == 'a') {
      digits[i] = '0';
    }
  }
  cout << digits << endl;
}
