N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]



def check(string):
    for s, c in SC:
        if string[s - 1] != str(c):
            return False
    return True 



if N == 1:
    for i in range(10 ** i):
        if check(str(i)):
            print (i)
            exit()
    print (-1)
    exit()
else:
    for i in range(10 ** (N - 1), 10 ** (N)):
        if check(str(i)):
            print (i)
            exit()
    print (-1)
    exit()
       