n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
cnt = True
for i in s:
    #print(i)
    if i == '0' and cnt and len(s) != 1:
        ans += str(1)
        cnt = False
    ans += str(i)
#print(ans)
if len(ans) != len(str(int(ans))):
    print(-1)
else:
    print(ans)