/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m;
    x = 0;

    for(i=1; i<=n; i++) x = x*10+9;

    int a[m+9], b[m+9];

    for(i=1; i<=m; i++)
    {
        cin>>a[i]>>b[i];
    }

    int ans = -1;

    for(v=0; v<=x; v++)
    {
        bool flag = true;

        stringstream sso; sso<<v;
        string s; sso>>s;
        if(s.size()==1 && s[0]=='0') s+="00";
       // cout<<s<<endl;
        for(j=1; j<=m; j++)
        {
           // cout<<"R";
            if((s[a[j]-1]-'0')!=b[j]){
                flag  = false; break;
            }
        }

        if(flag)
        {
            ans = v; break;
        }
    }

    if(ans==-1) cout<<-1<<endl;
    else
    {
        stringstream sso; sso<<ans;
        string s; sso>>s;

        if((int)s.size()==n) cout<<ans<<endl;
        else
            cout<<-1<<endl;
    }

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
