n,m = map(int,input().split())

conds = []
for i in range(m):
    s,c = map(int,input().split())
    conds.append([s,c])

flag = False
for i in range(10**(n-1),10**n-1):
    t = str(i)
    temp = True
    for c in conds:
        if int(t[c[0]-1]) == c[1]:
            continue
        else:
            temp = False

    if temp:
        flag = True
        print(i)
        break

if not flag:
    print(-1)
