#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
string ans;
int main(){
	ll n, m; cin >> n >> m;
	for (ll i = 0; i<n; i++) ans.pb(' ');
	for (ll i = 0; i<m; i++){
		ll pos, val; cin >> pos >> val;
		if (pos == 1 && val == 0 && n > 1){
			cout << -1; return 0;
		}
		else if (ans[pos - 1] != ' ' && ans[pos - 1] != val + '0'){
			cout << -1; return 0;
		}
		else ans[pos - 1] = val + '0'; 
	}
	for (ll i = 0; i<n; i++){
		if (ans[i] == ' '){
			if (i != 0) ans[i] = '0';
			else ans[i] = '1';
		}
	}
	cout << ans << endl;
}