def main():
    I=lambda:input()
    L=lambda:list(map(int,input().split()))
    n,m=L()
    sc=[]
    for i in range(m):
        si,ci=L()
        sc.append([si,ci])
    for i in range(10**(n-1),10**n):
        tmp=str(i)
        flag=True
        for j in range(m):
            if tmp[sc[j][0]-1]!=str(sc[j][1]):
                flag=False
        if flag:
            print(i)
            exit()
    print(-1)
        
    
    
if __name__ == '__main__':
    main()