BEGIN{
x =0
y = 0
}
{
if($1 == "forward"){
x += $2
else if($1 == "down"){
y += $2
else if($1 == "up"){
y -= $2
END{
print x, y
print x*y