def resolve():
    N, M = list(map(int, input().split()))
    SC = [list(map(int, input().split())) for _ in range(M)]
    value = [None for _ in range(N)]
    for s, c in SC:
        if s == 1 and c == 0:
            print(-1)
            return
        if value[s-1] is None or value[s-1] == c:
            value[s-1] = c
        else:
            print(-1)
            return
    for i in range(N):
        if i == 0:
            if value[i] is None:
                value[i] = 1
                continue
            elif N != 1 and value[i] == 0:
                print(-1)
                return
        if value[i] is None:
            value[i] = 0
    print("".join(map(str, value)))


if '__main__' == __name__:
    resolve()