def main():
    N,M = [int(n) for n in input().split()]
    d = [-1]*N
    for i in range(M):
        s,c = [int(n) for n in input().split()]
        s -= 1
        if d[s] == -1 or d[s] == c:
            d[s] = c
        else:
            print("-1")
            return
    if d[0] == -1:
        d[0] = 1
    for i in range(N):
        if d[i] == -1:
            d[i] = 0
    if d[0] == 0:
        print("-1")
    else:
        print("".join([str(n) for n in d]))
main()