#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}
void solve(){
    int n,m;
    cin>>n>>m;
    string s="";
    for(int i=0;i<n;i++)
    s.pb('*');
    int a,b,f=1;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        if(s[a-1]!='*'&&s[a-1]!=(char)(b+48))
        {
            f=0;
        }
        s[a-1]=(char)(b+48);
    }
    if(s[0]=='*')
    s[0]='1';
    for(int i=1;i<n;i++)
    {
        if(s[i]=='*')
        s[i]='0';
    }
    if((n!=1&&s[0]=='0')||f==0){
    cout<<-1<<endl;return;}
    cout<<s<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}