def main():
    n,m=map(int,input().split())
    a=[list(map(int,input().split())) for _ in  range(m)]
    a=[[a[i][0],str(a[i][1])] for i in range(m)]

    for num in  range(10**(n-1),10**n):
        num=str(num)
        #print(num)
        flag=True
        for i in range(m):
            #print(1)
            if num[a[i][0]-1]!=a[i][1]:
                flag=False
                break
                
        if flag:
            print(int(num))
            exit()
    print(-1)     
   
if __name__=='__main__':
    main()