#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> S(M);
  vector<char> C(M);
  for (int i = (int)0; i < (int)M; ++i) {
    cin >> S[i] >> C[i];
  }
  string ans(N, '*');
  for (int i = (int)0; i < (int)M; ++i) {
    if (ans[S[i] - 1] != '*' && ans[S[i] - 1] != C[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans[S[i] - 1] = C[i];
  }
  if (N > 1 && ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (int i = (int)0; i < (int)N; ++i) {
    if (ans[i] == '*') {
      if (i == 0) {
        ans[i] = '1';
      } else {
        ans[i] = '0';
      }
    }
  }
  cout << ans << endl;
  return 0;
}
