import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

ans = -1
N,M = I()
L = [set() for _ in range(N)]
for _ in range(M):
    s,c = I()
    if s == 1 and c == 0 and N > 1:
        print(-1)
        exit()
    L[s-1].add(c)
for i in range(N):
    if len(L[i]) == 0:
        if i == 0:
            L[i] = "1"
        else:
            L[i] = "0"
    elif len(L[i]) == 1:
        L[i] = str(list(L[i])[0])
    else:
        print(-1)
        exit()
print("".join(L), sep = "")
