def main():
    n,m = map(int,input().split())
    ans = ["0"for i in range(n)]
    for i in range(m):
        s,c = map(int,input().split())
        ans[s-1] = str(c)
    if ans[0]=="0":
        print(-1)
    else:
        print("".join(ans))
    


    return 

if __name__=="__main__":
    main()