#include <bits/stdc++.h>
using namespace std;
using st = size_t;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ull = unsigned long long;
#define inf 0x40000000
#define all(v) v.begin(), v.end()
#define alld(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
template <typename T> using mptr = T*;
using mp = pair<int, int>;
auto des = [](auto a, auto b) { return a > b; };

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,m,t,t2;
	cin>>n>>m;
	map<int,int>a;
	vector<int>b(n);
	bool yes=true;
	rep(i,m){
		cin>>t>>t2;
		if(!a.count(t-1)){
			a[t-1]=t2;
			b.at(t-1)=t2;
		}
		else if(a.at(t-1)!=t2){
			yes=false;
			break;
		}
	}
	if(!a.count(0))b.at(0)=1;
	else if(b.at(0)==0)yes=false;
	if(!a.count(1))b.at(1)=0;
	if(!a.count(2))b.at(0)=0;
		if(yes)rep(i,n)cout<<b.at(i);
		else cout<<"-1\n"s;
}