import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
num = [-1 for _ in range(n)]
for _ in range(m):
    s, c = MAP()
    s -= 1
    if num[s] == -1 or num[s] == c:
        num[s] = c
    else:
        print(-1)
        exit()
if num[0] == 0 and n > 1:
    print(-1)
    exit()
elif num[0] == -1:
    num[0] = 1
for i in range(n):
    if num[i] == -1:
        num[i] = 0
    num[i] = str(num[i])
print(''.join(num))