#include <bits/stdc++.h>
using namespace std;
const long long MOD = round(1e9 + 7);
int main() {
  int N, M;
  cin >> N >> M;
  vector<char> S(N, '.');
  vector<int> s(M);
  vector<char> c(M);
  for (long long i = 0; i < M; i++) cin >> s[i] >> c[i];
  bool flag = true;
  for (long long i = 0; i < M; i++) {
    if (S[s[i] - 1] == '.' || S[s[i] - 1] == c[i]) {
      S[s[i] - 1] = c[i];
    } else {
      flag = false;
    }
  }
  if (S[0] == '0') flag = false;
  for (long long i = 0; i < N; i++) {
    if (S[i] == '.') {
      if (0 == i)
        S[i] = '1';
      else
        S[i] = '0';
    }
  }
  if (flag)
    for (long long i = 0; i < N; i++) cout << S[i];
  else
    cout << -1;
  return 0;
}
