#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t N, M;
std::vector<int64_t> s, c;

bool ok(std::string str)
{
	if(str.size() != N) return false;
	for (int64_t i = 0; i < M; i++)
	{
		if (str[s[i]] != (char)(c[i] + '0')) return false;
	} 

	return true;
}

void solve()
{
	std::cin >> N >> M;
	s.resize(M);
	c.resize(M);

	for (int64_t i = 0; i < M; i++)
	{
		std::cin >> s[i] >> c[i];
		s[i]--;
	}

	std::string ans = "-1";
	for (int64_t i = 0; i < 1000; i++)
	{
		std::stringstream i_ss;
		i_ss << i;
		std::string str = i_ss.str();
		if (ok(str)) ans = str; 
	}

	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}
