from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    s=[0]*M
    c=[0]*M
    for i in range(M):
        a,b=map(int,readline().split())
        s[i]=a
        c[i]=b

    for n in range(10**N):
        n=str(n)
        for i in range(M):
            if len(n)<s[i]:
                break
            else:
                if n[s[i]-1]!=c[i]:
                    break
        print(n)
        break
    else:
        print(-1)
if __name__=="__main__":
    main()