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

int main() {
	int n,m;
	cin>>n>>m;
	string str;
	set<int> s;
	map<int,int> ma;
	if(n==1)
	{
	  str="0";
	  for(int i=0;i<m;++i)
	    {
	        int temp1,temp2;
	        cin>>temp1>>temp2;
	       
	        
	        else if(s.find(temp1)!=s.end())
	        {
	            if(ma[temp1]!=temp2)
	            {
	            cout<<-1<<endl;
	            return 0;
	            }
	        }
	        else
	        {
	            s.insert(temp1);
	            ma[temp1] = temp2;
	            str[temp1-1]=(temp2+'0');
	        }
	        //cout<<"fdvfdv"<<endl;
	        
	        //cout<<str<<endl;
	    }
	    cout<<str<<endl;
	  
	}
	else
	{
	    str="1";
	    for(int i=0;i<n-1;++i)
	    {
	        str+="0";
	    }
	    
	    for(int i=0;i<m;++i)
	    {
	        int temp1,temp2;
	        cin>>temp1>>temp2;
	        if(temp1==1&&temp2==0)
	        {
	            cout<<-1<<endl;
	            return 0;
	        }
	        
	        else if(s.find(temp1)!=s.end())
	        {
	            if(ma[temp1]!=temp2)
	            {
	            cout<<-1<<endl;
	            return 0;
	            }
	        }
	        else
	        {
	            s.insert(temp1);
	            ma[temp1] = temp2;
	            str[temp1-1]=(temp2+'0');
	        }
	        //cout<<"fdvfdv"<<endl;
	        
	        //cout<<str<<endl;
	    }
	    cout<<str<<endl;
	}
}
