N, M = map(int, input().split())
conds = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()
    if s - 1 in conds:
        if conds[s - 1] != c:
            print(-1)
            exit()
    else:
        conds[s - 1] = c

res = ['1'] * N
banned = set()
for digit, num in conds.items():
    res[digit] = str(num)
    banned.add(digit)
for i in range(1, N):
    if i not in banned:
        res[i] = '0'
print(''.join(res))