#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int n , k ;
	cin >> n >> k ;
	vi ans(n,-1) ;
	for(int i = 0 ; i < k ; i++){
		int x,y ;
		cin >> x >> y ;
		--x ;
		if(ans[x] == -1){
			ans[x] = y ;
		}
		else if(ans[x] != -1){
			if(ans[x] == y){

			}
			else{
				cout << -1 << endl ;
				return ;
			}
		}
	}	
	if(ans.size() > 1 && ans[0] == 0){
		cout << -1 << endl ;
		return ;
	}
	for(int i = 0 ; i < n ; i++){
		if(ans[i] == -1) ans[i]++ ;
	}
	bool all = 0 ;
	for(int i = 0 ; i < n ; i++){
		if(ans[i] > 0){
			all =  1 ;
			break ;
		}
	}
	if(all == 0){
		a[0]++ ;
	}
	for(auto x : ans) cout << x ;
	cout << endl ;
	
}


int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}
