N,M = map(int, input().split())
lst = [-999 for i in range(N+1)]
for i in range(M):
    idx, val = map(int, input().split())
    if lst[idx] == -999:
        lst[idx] = val
    elif lst[idx] != val:
        print(-1)
        exit(0)
res = ""
if lst[1] == 0:
    print(-1)
    exit(0)
if lst[1] == -999:
    lst[1] = 1
for i in range(1,N+1):
    if lst[i] == -999:
        res += "0"
    else:
        res += str(lst[i])
print(res)