l = input().split()
N = int(l[0])
M = int(l[1])
def ans(N,M):
    p = 0
    b = [str(10) for i in range(N)]
    for i in range(M):
        c = input().split()
        if c[0] == str(1) and c[1] == str(0) and N !=1:
            print('-1')
            p = 1
            break
        elif b[int(c[0])-1] == str(10):
            b[int(c[0])-1] = c[1]
        elif b[int(c[0])-1] != c[1]:
            print('-1')
            p = 1
            break
    if p == 0:
        if b[0] == str(0):
            b[0] = str(1)
        elif b[0] == str(10):
            if N >1:
                b[0] = str(1)
            else:
                b[0] = str(0)
        for i in range(1,N):
            if b[i] == str(10):
                b[i] = str(0)
        k = ''.join(b)
        print(k)
ans(N,M)