N, M = map(int, input().split())
a = [-1]*N
f = True
for i in range(M):
    s, c = map(int, input().split())
    if a[s-1] != -1 and a[s-1] != c:
        f = False
        break
    elif N != 1 and s == 1 and c == 0:
        f = False
        break
    else:
        a[s-1] = c
if not f:
    print(-1)
else:
    result = ''
    for i in range(N):
        if a[i] != -1:
            result += str(a[i])
        else:
            if i == 0:
                result += '1'
            else:
                result += '0'
    print(int(result))