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

int main(){
    int N, M, T, X;
    cin >> N >> M;
    vector<vector<int>> vec_a(M, vector<int>(2));
    vector<int> vec_b(N, 0);
    T =0;

    for(int i = 0; i < M; i++){
    for (int j = 0; j < 2; j++){
        cin >> vec_a[i][j];
    }
}

for(int i = 0; i < M-1; i++){
        for(int j = i+1; j < M; j++){
            if(vec_a[i][0] == vec_a[j][0] && vec_a[i][1] != vec_a[j][1]){
                T = 1; 
            }
    }
}


   for(int i = 0; i < M; i++){
     X = vec_a[i][0] - 1;
       vec_b[X] = vec_a[i][1];
     if(vec_a[i][0] == 1 && vec_b[i][1] && N != 1){
     T =1
     }
   } 

   if(N != 1 && vec_b[0] == 0){
       vec_b[0] == 1 ;
   }

   if(T == 0){
   for (int i = 0; i < M; i++){  
    cout << vec_b[i];
    }
   }
   if(T == 1){
    cout << "-1" << endl;
    }

}