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

int main(){
	int n, m;	cin >> n >> m;
	int arr[n+1] = {0};
	bool run = true;
	for(int i = 0; i < m; i++){
		int pos, val;	cin >> pos >> val;
		if(arr[pos] != 0 && arr[pos] != val)
			run = false;
        if(pos == 1 && val == 0)
            run = false;
		arr[pos] = val;
	}
	int idx = 1;
	while(arr[idx] == 0){
		arr[idx++] = 1;

	}
    if(run)
	    for(int i = 1; i <= n; i++)	cout << arr[i];
    else    cout << -1;
}
