N,M = map(int,input().split())
ln = [-1]*N
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    if (ln[s] != c) and(ln[s] != -1):
        print("-1")
        exit()
    else:
        ln[s] = c
for j in range(1,M):
    if ln[j] == -1:
        ln[j] = 0
if ln[0] == 0:
    print("-1")
    exit()
if ln[0] == -1:
    ln[0] = 1

print("".join(map(str,ln)))
