using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];

			var degs = new int[n];
			for (int i = 0; i < n; i++) {
				degs[i] = -1;
			}

			for (int i = 0; i < m; i++) {
				var sc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int s = sc[0] - 1;
				int c = sc[1];

				if (degs[s] == -1) {
					degs[s] = c;
				} else {
					if (degs[s] != c) {
						Console.WriteLine(-1);
						return;
					}
				}
			}

			if (degs[0] == -1) {
				degs[0] = 1;
			} else if (degs[0] == 0) {
				Console.WriteLine(-1);
				return;
			}

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

			var sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.Append(degs[i].ToString());
			}

			Console.WriteLine(sb.ToString());
		}
	}
}