n,m = map(int,input().split())
S = []
C = []
for i in range(m):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)

flg = True
res = [10]*n

for i in range(m):
    s,c = S[i], C[i]
    if res[s-1]!=10 and res[s-1]!=c:
        flg=False
        break
    elif res[s-1]==10:
        res[s-1] = c

if not flg:
    print(-1)
else:
    ans = ''
    for i in range(n):
        if i==0 and res[i]==10:
            ans += '1'
        elif i==0:
            ans += str(res[i])
        elif res[i]==10:
            ans += '0'
        else:
            ans += str(res[i])
    if ans=='0'*n:
        print(-1)
    else:
        print(ans)