program gianadoume;
var
infile,outfile:text;
A:char;
B,C,D,E:Integer;
function cubesum(B,C,D,E:integer):integer;
begin
cubesum:=B*C*D*3+E*E*E;
end;
function sqrsum(B,C,D,E:integer):integer;
begin
sqrsum:=B*C*3+E*E;
end;
function avsqrsum(B,C,D,E:integer):real;
begin
avsqrsum:=(B+C+D+E)/4;
end;
Begin
assign (infile,'c:\values.txt');
assign (outfile,'c:\Results.txt');
reset(infile);
rewrite(outfile);
while (not eof(infile))do
readln(infile,A,B,C,D,E);
if A='C'then
writeln(outfile,cubesum(B,C,D,E),' Sum of the cubes');
if A='S' then
writeln(outfile,sqrsum(B,C,D,E),' Sum of Square');
if A='A' then
writeln(outfile,avsqrsum(B,C,D,E),' Avarage of the squares');
end;
close(outfile);
close(infile);
end.