#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int dig[N + 1];
  for (int i = 0; i < N; i++) dig[i] = -1;
  int flag = 0;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (dig[s - 1] == -1)
      dig[s - 1] = c;
    else if (dig[s - 1] == c)
      continue;
    else
      flag = 1;
  }
  if (dig[0] == 0)
    flag = 1;
  else if (dig[0] == -1)
    dig[0] = 1;
  for (int i = 0; i < N; i++) {
    if (dig[i] == -1) dig[i] = 0;
  }
  if (flag)
    puts("-1");
  else {
    for (int i = 0; i < N; i++) {
      cout << dig[i];
    }
    cout << endl;
  }
}
