n,m = map(int,input().split())

ans_list = ['' for _ in range(n)]


def ans(n,m,ans_list):
    ans_list_tmp = ans_list
    for _ in range(m):
        s,c = map(int,input().split())
        s -= 1
        if s == 0 and c == 0:
            return -1
        elif ans_list_tmp[s] not in ['', c]:
            return -1
        else:
            ans_list_tmp[s] = c

    ans = [i if i!='' else 0 for i in ans_list_tmp]
    if ans[0] == 0:
        ans[0] = 1
    ans = map(str,ans)

    ans = ''.join(ans)
    return ans

print(ans(n,m,ans_list))