n,m = map(int,input().split())

x = []
y = []
ans = [10]*n 

for i in range(m):
    s = input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))

cnt = 0

q = 0

for i in x:
    if i == 1 and y[cnt] == 0 and n!=1:
        print(-1)
        q = 1
        break
    else:
        if ans[i-1] !=10:
            if ans[i-1]==y[cnt]:
                cnt += 1
            else:
                print(-1)
                q = 1
                break
        else:
            ans[i-1] = y[cnt]
            cnt += 1
            
cnt2 = 0

if q ==0:
    for i in ans:
        if i == 10:
            if cnt2 == 0:
                ans[cnt2] = 1
                cnt2 += 1
            else:
                ans[cnt2] = 0
        cnt2 += 1
    for i in ans:
        print(i,end = "")