#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N, 0), B(N, 0);
  A[0] = 1;
  int s, c;
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (B[s - 1] && A[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    A[s - 1] = c;
    B[s - 1] = 1;
  }
  for (int i = 0; i < N; i++) {
    cout << A[i];
  }
  cout << endl;
}
