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