This part is not so trivial for me:
awk '{a[$1,$2]+=$3;a[$4,$5]+=$6;}END{for(i=1;i<=NR;i++)for(i=1;j<=4;j++)print i,j,a[i,j];}'
So far this is not working properly. Importent point is that the numbers in the 1st and 4th columns goes from 1 to arbitrary value, let's sat from 1 to 10000; only...