n, m = map(int, input().split())
s = [0]*m
c = [0]*m
num = ['']*n
for i in range(m):
    s[i], c[i] = map(int, input().split())
    if s[i]==1 and c[i]==0:
        print(-1)
        exit()
    elif num[s[i]-1] == '':
        num[s[i]-1] = c[i]
    elif num[s[i]-1] != c[i]:
        print(-1)
        exit()
for j in range(n):
    if num[j]=='':
        if j == 0:
            num[j] = 1
        else:
            num[j] = 0
print(''.join(map(str,num)))