N,M = (int(x) for x in input().split())
num = [-10]*N

ans = True

for i in range(M):
    s,c = (int(x) for x in input().split())

    if num[s-1] == -10 or num[s-1] == c:
        num[s-1] = c
    else:
        ans = False
        break
if num[0] == -10:
    num[0] = 1
    
for i in range(1,N):
    if num[i] == -10:
        num[i] = 0

if num[0] == 0:
    ans = False

if ans:
    for s in num:
        print(s,end='')

    print()

else:
    print(-1)

