                #include<bits/stdc++.h>
                using namespace std;
                #define lli long long int
                #define fr(i,a,b) for(int i=a;i<b;i++)
                #define bfr(i,a,b) for(int i=a;i>=b;i--)
                #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
                #define tc int t;cin>>t;while(t--)
                #define mod 1000000007 
                #define all(vec) vec.begin(),vec.end()  
                #define ld long double


               
        int main()
                {
                       
                        
                    
                     fio
                     
                     lli n,m,x,y;
                     map<lli,set<lli>> z;
                     cin>>n>>m;

                     fr(i,0,m)
                     {
                        cin>>x>>y;
                        z[x].insert(y);

                     }

                     for(auto x:z)
                        if(x.second.size()>1){cout<<-1;return 0;}

                   vector<lli> num;
                   fr(i,1,n+1)
                   if(z.count(i)==0 && i==1)num.push_back(1);
                   else if(z.count(i)==0 )num.push_back(0);
                   else num.push_back((*(z[i].begin())));

                   if(num[0]==0){cout<<-1;return 0;}
                   else for(auto l:num)cout<<l;





                     







                     


                     

                     

                     


return 0;}