#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll n,m,z,x,s,a[5],c[5];
int main()
{
    cin>>n;
    cin>>m;
    int ff=0;
    ll ans=0;
    if(m==0){
        cout<<1;
        for(int i=2;i<=n)cout<<0;
    }
    for(int i=1;i<=m;i++){
        cin>>z>>x;
        if(a[z]==0 && c[z]==0){
            c[z]++;
            a[z]=x;
        }
        else if(c[z]==1 && a[z]!=x)ans=-1;
    }
    if(ans==-1 || a[1]==0)cout<<-1<<endl;
    else for(int i=1;i<=n;i++)cout<<a[i];
}
