#include <iostream>
#include <fstream>

using namespace std;

class student {
private:
    int ScoreNum;
	int *Score;
	int totalScore;
	float ScoreAvg;
public:
	student()
	{
		Score = 0;
		totalScore = 0;
		ScoreAvg = 0.0;
	}
	~student()
	{
		delete []Score;
	}
	void setNum(int ScoreNum)
	{
		this->ScoreNum = ScoreNum;
		Score = new int[ScoreNum];
	}
	int* getScore()
	{
		return Score;
	}
	void compute()
	{
		for(int i = 0; i < ScoreNum; i++) {
			totalScore += Score[i];
		}
		ScoreAvg = (float)totalScore / ScoreNum;
	}
	int getTotal()
	{
		return totalScore;
	}
	float getAvg()
	{
		return ScoreAvg;
	}
};

void readScore(student *&allStudent,int &studentNum,int &ScoreNum)
{
	ifstream iFile("score.txt");
	iFile >> studentNum >> ScoreNum;
	allStudent = new student[studentNum];
	for(int i = 0; i < studentNum; i++) {
		allStudent[i].setNum(ScoreNum);
		for(int j = 0; j < ScoreNum; j++){
			iFile >> allStudent[i].getScore()[j];
		}
		allStudent[i].compute();
	}
	iFile.close();
}

void display(student *allStudent,int studentNum,int ScoreNum)
{
	int sum = 0;
	for(int i = 0; i < studentNum; i++){
		cout << "student" << i+1
			<< "-> total=" << allStudent[i].getTotal()
			<< ",avg=" << allStudent[i].getAvg() << endl;
		sum+= allStudent[i].getTotal();
	}
	cout << "total = " << sum << ", avg = " << (float)sum / (studentNum*ScoreNum);
}

int main()
{
	student *allStudent;
	int studentNum,ScoreNum;
	readScore(allStudent,studentNum,ScoreNum);
	display(allStudent,studentNum,ScoreNum);
	delete []allStudent;
	return 0;
}