#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) x.begin(), x.end()
#define inf 1e9
#define INF 1e15
#define fastio ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
#define for_n(i,n) for(int i=0;i<n;i++)

////////////////////////////////////////////////////////////
using namespace std;
 
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<ii> vii;

int di[5];
int main() {
	int n, m; cin >> n >> m;
	fill(di,di+5, -1);
	bool sh = false;
	for_n(i,m) {
		int s, c; cin >> s >> c;
		s--;
		if(di[s] == -1)
			di[s] = c;
		else sh = true;
	}
	if(di[0] == 0 && n > 1) sh = true;
	if(di[0] == -1) di[0] = 1;
	for(int i=1;i<n;i++) {
		if(di[i] == -1) di[i] = 0;
	}
	if(sh) {
		cout << -1;
		return;
	}
	for_n(i,m) cout << di[i];
}