spoj#GR. Grand Reward
Grand Reward
当前没有测试数据。
Grand is one of the best companies every month , The manager chooses the best employee and rewards him.
this month there are 4 employees do the same effort Sameh , Ameen , Shafeek and Atef but the manager will give reward to one only ,He got a good idea
let's say that the 4 employees will stand in someway like that every employe in one of the four sides east(Sameh) , north(Ameen) , west(Shafik) and south(Atef)
then , there's a square matrix of width and height N*N among them first element in matrix will start with 1 then next element increase by 1 from left to right and from top
to down until n*n like that
Ameen
1 2 3
Sameh 4 5 6 Shafeek
7 8 9
Atef
then let's rotate the matrix T turns 90 degrees clockwise per turn and the winner is the person who the sum of his side is the greatest
for example let's say that T=4 and N=3 ,
Atef wins because the sum of his side is 7+8+9=24 and it's the greatest
It's your job now create a program that do this job.
Input
Two integers the size of the matrix N(3≤N≤25) , and the number of turns (1≤T≤10^9).
Output
The final result of the matrix and the employee who will get the reward (Sameh,Ameen,Shafeek,Atef).
Example
Input:123 456555 555123 5943 4
Output: Atef
1 2 3
4 5 6
7 8 9
Input:123 456555 555123 5944 3
Output: Shafeek
4 8 12 16
3 7 11 15
2 6 10 14
1 5 9 13