I want to summarize the two last segments which contain ifs within a loop for the first time, i and j should be 0 and 1 respectively, but then they should be 0 and 2 and ...