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