read n;

E=echo
l=`sed 's/ /\\\n/g'`

s() {
  ($E -e $l | awk 'NR%2=='"$1"'' |  uniq -c | sort -rnk1; $E 0 0) | head -2
}




g() {
  $E $((a=$1+$7,b=$3+$5,$2!=$6?n-$1-$5:a>b?n-a:n-b))
}

# ss 1
g `s 1; s 0`
