def main():
    N,M = map(int, input().split())
    x = ["0"]*N
    for _ in range(M):
        s,c = input().split()
        # 左からsけた目がc
        x[int(s)-1] = c
        if s==1 and c==0:
            hfixed=True
    if N==1:
        print("".join(x))
    else:
        if x[0]=="0":
            if hfixed:
                print("-1")
            else:
                x[0] = "0"
                print("".join(x))
        else:
            print("".join(x))

main()
