N ,M = map(int,input().split())
cnt = [0]*M
C = [0]*M
for i in range(M):
    s, c = map(int,input().split())
    if c == C[s-1]:
        pass
    else:
        C[s-1] += c
        cnt[s-1] += 1

if max(cnt)>=2 or C[0] == 0   :
    print(-1)
else:
    print("".join(map(str,C)))