#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, s, c, flag = 1, i;
    cin>>n>>m;
    vector<ll> num(n, -1);
    while(m--) {
    	cin>>s>>c;
    	s--;
    	if(num[s] == c || num[s] == -1) {
    		if(s == 0 && c == 0 && n != 1) {
    			flag = 0;
    		}
    		num[s] = c;
    	} else {
    		flag = 0;
    	}
    }
    if(flag) {
    	for(i = 0; i < n; i++) {
    		if(num[i] == -1) {
    			if(i == 0) {
    				num[i] = 1;
    			} else {
    				num[i] = 0;
    			}
    		}
    	}
    	for(auto u: num) {
    		cout<<u;
    	} cout<<"\n";
    } else {
    	cout<<"-1\n";
    }
}