Replace i by j
run programs three times, add rule to collate results