#include<iostream>
#include<string>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){
    int n,m,x,y;
    string s;
  	map<int,set<int>> p;
    cin>>n>>m;
    rep(i,n) s+='0';
    rep(i,m){
        cin>>x>>y;
      	map[x].insert(y);
      	
        if(map[x].size()>1) {cout<<-1;return 0;}
        else s[x-1]=y+'0';
    }
  	if(m==0) {if(n!=1) s[0]='1';}
    if(s.size()>1&&s[0]=='0') {cout<<-1;return 0;}
    cout<<s;
}   
