#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll N,M;
    cin >> N >> M;
    ll a=1;
    ll s,c;
    ll i,j;
    bool flag;
    for(i=pow(10,N-1);i<pow(10,N);i++){
        for(j=0;j<M;j++){
            cin >> s >> c;
            flag=true;
            if(i%pow(10,N-s+1)/pow(10,N-s)!=c){
                flag=false;
            }
            if(flag)cout << i,return 0;
        }
    }
    cout << -1;
    return 0;
}
