using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string str = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int[] num = new int[n];
			for (int i = 0; i < n; i++) {
				num[i] = -1;
			}
			for (int i = 0; i < m; i++) {
				vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				int s = vs[0] - 1;
				int c = vs[1];
				if (num[s] == -1 || num[s] == c) {
					num[s] = c;
				} else {
					Console.WriteLine("-1");
					return;
				}
			}
			if (num[0] == 0) {
				Console.WriteLine("-1");
				return;
			}
			for (int i = 0; i < n; i++) {
				if (num[i] == -1) {
					if (i == 0 && n > 1) {
						num[i] = 1;
					} else {
						num[i] = 0;
					}
				}
			}
			Console.WriteLine(string.Concat(num));


			//Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}
