N, M = map(int, input().split(" "))
ans = [-1 for i in range(N)]
is_conflict = False

for i in range(M):
    s, c = map(int, input().split(" "))
    if ans[s - 1] == -1:
        ans[s - 1] = c
    else:
        is_conflict |= (ans[s - 1] != c)

is_conflict |= (ans[0] == 0)    # 先頭は0以外

for i in range(N):
    if i == 0 and ans[i] == -1:
        ans[i] = 1
    elif ans[i] == -1:
        ans[i] = 0

if is_conflict:
    print(-1)
else:
    print(''.join([str(a) for a in ans]))