        #include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;

        signed main() {
        int n,m;
        cin>>n>>m;
        int x[n];for(int i=0;i<n;i++)x[i]=-1;
        int s,c;
        for(int i=0;i<m;i++){
                cin>>s>>c;s--;
                if(x[s]!=-1&&x[s]!=c){
                        cout<<-1;
                        return 0;
                }
                x[s]=c;
        }
        if(x[0]==0){
              if(n!=1)  cout<<-1;
              else cout<<0;
                return 0;
        }
        if(x[0]==-1){
                if(n!=1)x[0]=1;
                else x[0]=0;
        for(int i=1;i<n;i++)if(x[i]==-1)x[i]=0;
        for(int i=0;i<n;i++)cout<<x[i];

      }


        
