Variants of the Two Machine Flow Shop Problem connected with factorization of matrix functions