#include <bits/stdc++.h>
using namespace std;
int numOfDigits;
int numOfQueries;
int myIndex;
int foo;
int lowestIndex;
char* myNumber;
char value;
bool isPossible;
int main() {
  scanf("%d %d", &numOfDigits, &numOfQueries);
  myNumber = (char*)malloc(numOfDigits * sizeof(char));
  for (int i = 0; i < numOfDigits; i++) {
    myNumber[i] = 'a';
  }
  isPossible = true;
  for (int i = 0; i < numOfQueries; i++) {
    scanf("%d %d", &myIndex, &foo);
    value = foo + '0';
    myIndex--;
    lowestIndex = min(myIndex, lowestIndex);
    if (myNumber[myIndex] != 'a') {
      isPossible = (myNumber[myIndex] == value);
    }
    myNumber[myIndex] = value;
    if (!isPossible) break;
  }
  if (isPossible && myNumber[0] != '0') {
    if (lowestIndex != 0) {
      myNumber[0] = '1';
    }
    for (int i = 1; i < numOfDigits; i++) {
      if (myNumber[i] == 'a') {
        myNumber[i] = '0';
      }
    }
    printf("%s\n", myNumber);
  } else {
    printf("-1\n");
  }
}
