/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

// 配列の要素を出力
// in 配列
// in 配列サイズ
void trace(int* intArray, int arraySize){
	cout << intArray[0];
	for (int i = 1; i < arraySize; ++i){
		cout << " " << intArray[i];
	}
	cout << "\n";
}

int main(){
	int n, m;
	cin >> n >> m;
	int *x = new int[n];
	int *flag = new int[n];
	for (int i = 0; i<n; ++i){
		flag[i] = 0;
		x[i] = 10;
	}

	int s, c;

	for (int i = 0; i<m; ++i){
		cin >> s;
		cin >> c;

		if (x[s-1] == 10){
			x[s-1] = c;
			flag[s-1] = 1;
		}
		else{
			if (x[s-1] != c){
				flag = 2;
			}
		}
	}

	for(int i = 0; i<m; ++i){
		if (flag[i] == 2){
			cout << -1;
			return 0;
		}
	}

	if (n == 1 && x[0] == 0){
		cout << x[0];
		return 0;
	}

	if (flag[0] == 0){
		x[0] = 1;
	}

	if (x[0] == 0){
		cout << -1;
		return 0;
	}

	for (int i = 1; i<n; ++i){
		if (flag[i] == 0){
			x[i] = 0;
		}
	}


	for (int i = 0; i < n; ++i){
		cout << x[i];
	}



	return 0;
}
