#include<bits/stdc++.h>
int main(){
    int n,m;std::cin>>n>>m;
    std::vector<int>a(n,-1);
    for(int i=0;i<m;i++){
        int s,c;std::cin>>s>>c;
        s--;
        if(a.at(s)!=-1&&a.at(s)!=c||2<=n&&s==0&&c==0){
            std::cout<<-1<<std::endl;
            return 0;
        }
        a.at(s)=c;
    }
    for(int i=0;i<n;i++){
        std::cout<<(a.at(i)==-1?(2<=n&&i==0?1:0):a.at(i));
    }
    std::cout<<std::endl;
}

