#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M = iim()
    dp = dict()
    for i in range(M):
        si, ci = iim()
        if si in dp:
            if dp[si] != ci:
                print(-1)
                return
            continue
        dp[si] = ci

    if 1 in dp and dp[1] == 0:
        print(-1)
        return

    #print(dp)
    ans = []
    for i in range(1, N+1):
        if i in dp:
            ans.append(dp[i])
        else:
            ans.append(1 if i == 1 else 0)
    print(*ans, sep="")


if __name__ == "__main__":
    resolve()
