#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>>K(M, vector<int>(2));
  for(int i = 0; i < M; i++){
    for(int j = 0; j < 2; j++){
    cin >> K.at(i).at(j);
    }
  }
  

  
  
  int a = 0;
  bool finished = false;
  for(int i = 0; i < M; i++){
    for(int j = i; j < M; j++){
      if(K.at(i).at(0) == K.at(j).at(0) && 
         K.at(i).at(1) != K.at(j).at(1)){
        int a = -1;
        cout << a << endl;
         finished = true;
        break;
      }
    }
    if (finished){
      break;
    }
  }
  
  if(a == 0){
 	 for(int i = 0; i < M; i++){
  	  if(K.at(i).at(0) == 1 && 
        K.at(i).at(1) == 0){
        a = -1;
        cout << a << endl;
        break;
      }
    }
  }
  if(a == 0){
    vector<int>A(N);
    A.at(0) = 1;
    for(int i = 1; i < N; i++){
      A.at(i) = 0;
    }
    for(int i = 0; i < N; i++){
      for(int j = 0; j < M; j++){
	     if(i+1 == K.at(j).at(0)){
            A.at(i) = K.at(j).at(1);
         }
      }
    }
  
      
    for(int i = 0; i < N; i++){
      cout << A.at(i);
    }
  }
}