#157
def main():
    N, M = map(int,input().split())
    num = [-1]*N
    for i in range(M):
        s, c = map(int,input().split())
        if(num[s-1]==-1):
            if(s==1 and c==0):
                print(-1)
                return
            num[s-1] = c
        else:
            if(num[s-1] != c):
                print(-1)
                return
    result = ''
    for i in range(N):
        if(num[i]!=-1):
            result += str(num[i])
        else:
            if(i==0):
                result+='1'
            else:
                result+='0'
    print(result)

main()