n, m = map(int, input().split())
sc = [map(int, input().split()) for i in range(m)]

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]

    for i in range (10**(n-1),10**n):
        p = str(i)
        flag = 0
        for j in range(m):
            if p[s[j]-1] != str(c[j]):
                flag = 1
                break

        if flag == 0:
            print(i)
            flag = 2
            break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")