generate input for grimm algorithm