Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:   Tetrahedron. Tetrahedron has 4 triangular faces.  Cube. Cube has 6 square faces.  Octahedron. Octahedron has 8 triangular faces.  Dodecahedron. Dodecahedron has 12 pentagonal faces.  Icosahedron. Icosahedron has 20 triangular faces. All five kinds of polyhedrons are shown on the picture below:  Anton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find this number!

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string si — the name of the i-th polyhedron in Anton's collection. The string can look like this:   "Tetrahedron" (without quotes), if the i-th polyhedron in Anton's collection is a tetrahedron.  "Cube" (without quotes), if the i-th polyhedron in Anton's collection is a cube.  "Octahedron" (without quotes), if the i-th polyhedron in Anton's collection is an octahedron.  "Dodecahedron" (without quotes), if the i-th polyhedron in Anton's collection is a dodecahedron.  "Icosahedron" (without quotes), if the i-th polyhedron in Anton's collection is an icosahedron.

Output one number — the total number of faces in all the polyhedrons in Anton's collection.

4
Icosahedron
Cube
Tetrahedron
Dodecahedron

NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.

var input='';

process.stdin.on('data',(givenInput)=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=(input)=>{

    const n=Number(input.split('\r\n')[0]);
    let strArr=input.split('\r\n');

    let num,total=0;

    for(let i=1;i<=n;i++){

        str=strArr[i];

        switch(str){
            case 'Tetrahedron': num=4; break;
            case 'Cube': num=6; break;
            case 'Octahedron': num=8 ; break;
            case 'Dodecahedron': num=12 ; break;
            case 'Icosahedron': num=20 ; break;
        }

        total+=num;
    }

    console.log(total);

}

const readLine = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));
const polyhedron = () => {
    input.shift();
    let sum = 0;
    for (const x of input) {
         if (x === 'Icosahedron') {
            sum += 20;
         }if (x === 'Cube') {
            sum += 6;
         }if (x === 'Tetrahedron') {
            sum += 4;
         }if (x === 'Dodecahedron') {
            sum += 12;
         }   if (x === 'Octahedron') {
            sum += 8;
         }
    }
    console.log(sum);
};
readLine.on('close', polyhedron);

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    let n = parseInt(readLine());
    let ans = 0;
    let objPoly = {
        T: 4,
        C: 6,
        O: 8,
        D: 12,
        I: 20
    }
    for (var i = 0; i < n; i++) {
        let polyhedron = readLine();
        ans += objPoly[polyhedron.charAt(0)];
    }
    console.log(ans);
}

'use strict';

const readline = require('readline');

let lines = [];

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line) => {
    lines.push(line);
});

rl.on('close', (cmd) => {
    let n = parseInt(lines[0]);
    let obj = {
        "Cube":        6,
        "Dodecahedron": 12,
        "Icosahedron": 20,
        "Octahedron":  8,
        "Tetrahedron": 4
    };
    let ret = 0;
    for (let i = 1; i < n + 1; ++i) {
        ret += obj[lines[i]];
    }
    console.log(ret);
    process.exit(0);

});

'use strict';

const readline = require('readline');

let lines = [];

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line) => {
    lines.push(line);
});

const obj = {
        "Cube":        6,
        "Dodecahedron": 12,
        "Icosahedron": 20,
        "Octahedron":  8,
        "Tetrahedron": 4
};

rl.on('close', (cmd) => {
    let n = parseInt(lines[0]);
    let ret = 0;
    for (let i = 1; i < n + 1; ++i) {
        ret += obj[lines[i]];
    }
    console.log(ret);
    process.exit(0);

});

var sum = 0;
		var n = readline();
		while(n>0){
		var line = readline();
		if (line == "Tetrahedron"){
			sum+=4;
		}
		if (line == "Cube"){
			sum+=6;
		}
		if (line == "Octahedron"){
			sum+=8;
		}
		if (line == "Dodecahedron"){
			sum+=12;
		}
		if (line == "Icosahedron"){
			sum+=20;
		}
		n--;
	}
		print(sum);

  var n = parseInt(readline());
  var res = 0;
  while(n) {
    var c = readline();
    if(c === 'Tetrahedron') res += 4;
    if(c === 'Cube') res += 6;
    if(c === 'Octahedron') res += 8;
    if(c === 'Dodecahedron') res += 12;
    if(c === 'Icosahedron') res += 20;
    n -= 1;
  }
  print(res)

	 var n = parseInt(readline());
	var sum = 0;
     while(n){
     	var str = readline();
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n --;
     }
     print(sum);

	 var n = parseInt(readline());
	var sum = 0;
     while(n){
     	var str = readline();
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n -= 1;
     }
     print(sum);

var lineNumber = readline();
var coubes = new Map();
coubes.set("Tetrahedron", 4);
coubes.set("Cube", 6);
coubes.set("Octahedron", 8);
coubes.set("Dodecahedron", 12);
coubes.set("Icosahedron", 20);
var count = 0;
while(lineNumber--){
    var input = readline();
    count += coubes.get(input);
}
print(count);

var n = readline();
var fig = {Tetrahedron: 4, Cube : 6, Octahedron: 8, Dodecahedron : 12, Icosahedron : 20 };
var fete = 0;
for( i=0;i<n;i++) {
      fete+=fig[readline()];
}
print(fete);

var a = readline(),i = 0,k = 0;
var s;
while(i != a)
{
	s = readline();
	if(s == "Tetrahedron")
	{
		k += 4;
	}
	else	if(s == "Cube")
		{
			k += 6;
		}
		else	if(s == "Octahedron")
			{
				k += 8;
			}
			else	if(s == "Dodecahedron")
				{
					k += 12;
				}
				else	if(s == "Icosahedron")
					{
						k += 20;
					}
	i++;
}
print(k);

var n = Number(readline());
var arr = [];

for(var i = 0; i < n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

'use strict'
let a = readline(), b, c = 0;

for (; a; a--) {
  b = readline()[0];
  if (b === 'C') {c += 6; continue}
  if (b === 'D') {c += 12; continue}
  if (b === 'I') {c += 20; continue}
  if (b === 'O') {c += 8; continue}
  if (b === 'T') {c += 4; continue}
}

print(c);

var a = readline(), b, c = 0;

for (; a; a--) {
  b = readline()[0];
  if (b === 'C') {c += 6; continue;}
  if (b === 'D') {c += 12; continue;}
  if (b === 'I') {c += 20; continue;}
  if (b === 'O') {c += 8; continue;}
  if (b === 'T') {c += 4; continue;}
}

print(c);

var data = {
	"Tetrahedron": 4,
	"Cube": 6,
	"Octahedron": 8,
	"Dodecahedron": 12,
	"Icosahedron": 20
};

var n = +readline(),
	sum = 0,
	line;

while (line = readline()) {
	sum += data[line];
}

print(sum);

var p = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron: 20};
n = parseInt(readline());
var s = 0;
 for (var i=0; i < n; i++ ){
     s += p[readline()];
 }
print(s);

"use strict";

// readline().split(' ').map(value => +value);
var S = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
};

var n = readline();

var result = 0;
for (var i = 0; i < n; ++i) {
    result += S[readline()];
}

write(result);

var n=+readline()
var T={
 Tetrahedron: 4,
 Cube: 6,
 Octahedron: 8,
 Dodecahedron: 12,
 Icosahedron:20,
};
R=0
for (var i=0;i<n;++i)
 R+=T[readline()]
print(R)

var numbers = readline();
var a = numbers;
var number = []
var e=[];
var b = 0;

for(var i=0; i<a; i++){
    number.push(readline())
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}

print(b)

var array = {"Tetrahedron": 4, "Cube": 6, "Octahedron": 8, "Dodecahedron": 12, "Icosahedron": 20};
var n = parseInt(readline());

var sum=0;
for (var i = 0; i < n; i++) {
    var key=readline();
    sum+=array[key];
}

print(sum);

(function() {
    'use strict';
    const n = readline();
    var sum = 0;
    for (var i = 0; i < n; ++i) {
        const figure = readline();
        if (figure == "Tetrahedron")
            sum += 4;
        if (figure == "Cube")
            sum += 6;
        if (figure == "Octahedron")
            sum += 8;
        if (figure == "Dodecahedron")
            sum += 12;
        if (figure == "Icosahedron")
            sum += 20;
    }

    print(sum);
}());

var limit = parseInt(readline());
var map = {}
map['Icosahedron'] = 20;
map['Dodecahedron'] = 12;
map['Octahedron'] = 8;
map['Cube'] = 6;
map['Tetrahedron'] = 4;
var sum = 0;
for (var i = 0; i < limit; i++) {
  sum += map[readline()];
}
print(sum);

var n = parseInt(readline());

var total = 0;
var obj = {
    "T": 4,
    "C": 6,
    "O": 8,
    "D": 12,
    "I": 20
}

while (n--) {
    total += obj[readline().slice(0, 1)];
}

print(total);

var N = readline().split(' ');
var n = N;
var sum = 0;
for (N; N>0; N--) {
    var line = line + ' ' + readline().split(' ') ;
}
var type = line.split(' ');

for (n; n>0; n--) {
   switch (type[n]) {
        case 'Tetrahedron': sum = sum + 4; break;
        case 'Cube': sum = sum + 6; break;
        case 'Octahedron': sum = sum + 8; break;
        case 'Dodecahedron': sum = sum + 12; break;
        case 'Icosahedron': sum = sum + 20; break;
    }
}
print (sum);

var n = readline();
var i = 0, sum = 0, arr = '';
for (i; i<n; i++) {
    arr = readline();
    if (arr == 'Icosahedron') sum += 20;
    if (arr == 'Dodecahedron') sum += 12;
    if (arr == 'Octahedron') sum += 8;
    if (arr == 'Cube') sum += 6;
    if (arr == 'Tetrahedron') sum += 4;
}
print (sum);

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

const polyhedrons = {
  Tetrahedron: 4,
  Cube: 6,
  Octahedron: 8,
  Dodecahedron: 12,
  Icosahedron:20,
}
let sum = 0, count = 0, int;

rl.on('line', (line) => {
  if (typeof int !== 'undefined' && line in polyhedrons) {
    sum += polyhedrons[line];
    if (++count === Number(int)) {
      console.log(sum);
      rl.close()
    }
  } else int = line;
});

let readline  = require('readline');
let intInput = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});
let arr = [];
intInput.on('line', (line) => {
	arr.push(line)
});
intInput.on('close', () => {
	//let num = arr[0];
	let nameToSize = {
		'Tetrahedron': 4,
		'Cube': 6,
		'Octahedron': 8,
		'Dodecahedron': 12,
		'Icosahedron': 20
	}
	let sum = 0;
	for (let i = 1; i <= arr.length - 1; i++) {
		let polyhedron = arr[i];
		sum += nameToSize[polyhedron]
	}
	console.log(sum);
})

function main() {
    // write code here:
    var polyhedrons = {
        "Tetrahedron": 4,
        "Cube": 6,
        "Octahedron": 8,
        "Dodecahedron": 12,
        "Icosahedron": 20
    };
    var num = Number(stdin[0]), totalNum = 0;
    for (var i = 1; i <= num; i++) {
        totalNum += polyhedrons[stdin[i]];
    }
    console.log(totalNum);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {
    stdin.push(line);
});
rl.on('close', main);

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let i = 0;

rl.question('', (number) => {
  const shapeNames = [] ;
  rl.on('line', (shapeName) => {
    i++;
    shapeNames.push(shapeName) ;
    if (i >= parseInt(number)) {
      calFacesNum(shapeNames) ;
      rl.close();
    }
  });
});

function calFacesNum(faces) {
  let facesNumber = 0;

  for (let i = 0; i < faces.length; i++) {
    switch (faces[i]) {
      case 'Tetrahedron':
        facesNumber += 4;
        break;
      case 'Cube':
        facesNumber += 6;
        break;
      case 'Octahedron':
        facesNumber += 8;
        break;
      case 'Dodecahedron':
        facesNumber += 12;
        break;
      case 'Icosahedron':
        facesNumber += 20;
        break;
    }
  }
  console.log(facesNumber) ;
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [count, ...geometry] = input
  count = parseInt(count, 10)
  function returnCountGeometry(el){
    switch(el){
      case 'Tetrahedron': {
        return 4
      } break;
      case 'Cube': {
        return 6
      } break;
      case 'Octahedron': {
        return 8
      } break;
      case 'Dodecahedron': {
        return 12
      } break;
      case 'Icosahedron': {
        return 20
      } break;
      default: {
        return 0
      }
    }
  }
  let _fin = 0
  for (let i = 0; i < count; i ++) {
    const el = geometry[i]
    const check = el !== '' ? true : false
    if(check) {
      const counter = returnCountGeometry(el)
      _fin += counter
    } else {
      count++
    }
  }
  console.log(_fin)
});

function onReadable(rs, bufContainer, resolve) {
  return () => {
    const chunk = rs.read();

    if (chunk) bufContainer.val = Buffer.concat([ bufContainer.val, chunk ]);

    let newLineIndex = bufContainer.val.indexOf('\n');

    if (!chunk) { newLineIndex = bufContainer.val.length; }

    if (newLineIndex !== -1) {
      const line = bufContainer.val.slice(0, newLineIndex);

      bufContainer.val = bufContainer.val.slice(newLineIndex + 1);

      return resolve(line.toString('utf-8'));
    }

    return rs.once('readable', onReadable(rs, bufContainer, resolve))
  }
}

function IO(rs, ws) {
  const bufContainer = { val: Buffer.from([]) };

  return {
    async rl() {
      const newLineIndex = bufContainer.val.indexOf('\n');

      if (newLineIndex !== -1) {
        const line = bufContainer.val.slice(0, newLineIndex);

        bufContainer.val = bufContainer.val.slice(newLineIndex + 1);

        return Promise.resolve(line.toString('utf-8'));
      }

      return new Promise(resolve => rs.once('readable', onReadable(rs, bufContainer, resolve)));
    },
    wr(str) {
      return ws.write(str);
    },
    wl(str) {
      return ws.write(str + '\n');
    }
  }
}

(async () => {
  const io = IO(process.stdin, process.stdout);

  return sol(io);
})();

async function sol({ rl, wr, wl }) {
  const grani = {
    T: 4,
    C: 6,
    O: 8,
    D: 12,
    I: 20,
  };

  const n = Number(await rl());
  let sum = 0;

  for (let i = 0; i < n; i += 1) {
    const f = (await rl())[0];
    sum += grani[f];

    if (Number.isNaN(sum)) {
        return wl(`${f} ${i}`);
    }
  }

  return wl(sum);
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var output = 0;
  for(var i = 0; i < N; i++){
    var s = next();
    switch(s){
      case "Tetrahedron":
        output += 4;
        break;
      case "Cube":
        output += 6;
        break;
      case "Octahedron":
        output += 8;
        break;
      case "Dodecahedron":
        output += 12;
        break;
      case "Icosahedron":
        output += 20;
        break;
            }
  }
  myout(output);
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const n = +input[0];
  let k = 0;
  for (let i = 1; i <= n; i++) {
    if (input[i] === 'Tetrahedron') {
      k += 4;
    }
    else if (input[i] === 'Cube') {
      k += 6;
    }
    else if (input[i] === 'Octahedron') {
      k += 8;
    }
    else if (input[i] === 'Dodecahedron') {
      k += 12;
    }
    else if (input[i] === 'Icosahedron') {
      k += 20;
    }
  }
  console.log(k);
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let ans = 0;
const score = {
  'Tetrahedron': 4,
  'Cube': 6,
  'Octahedron': 8,
  'Dodecahedron': 12,
  'Icosahedron': 20
};

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  ans += score[d];

  c++;
});

rl.on('close', () => {
  console.log(ans);
});

'use strict';

let input = [];
let count_flow = {
    'Icosahedron': 20,
    'Cube': 6,
    'Tetrahedron': 4,
    'Dodecahedron': 12,
    'Octahedron': 8,
}

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', (line) => {
    line.split(' ').map(x => input.push(x));
});

RL.on('close', () => {
    let n = parseInt(input[0]), sum = 0;
    for (let i = 1; i <= n; i++)
        sum += count_flow[input[i]];
    console.log(sum);
});

let heterolist = [];
let gayNum = 0;
let iter = 0;

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function checkSum(line){
    if (line == 'Tetrahedron'){
        return 4;
    } else if (line == 'Cube'){
        return 6;
    } else if (line == 'Octahedron'){
        return 8;
    } else if (line == 'Dodecahedron'){
        return 12;
    } else if (line == 'Icosahedron'){
        return 20;
    }
};

rl.question('', (answer) => {
    sizeOfArray = answer;
    //console.log('sizeOfArray', answer);
});

rl.on('line', (line) => {
        //heterolist.push(line.split(' ', 1).map(String));
        gayNum += checkSum(line.split(' ', 1).map(String));
        iter++;
        if(iter == sizeOfArray){
            console.log(gayNum);
            process.exit(0);
        }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin
});

let sides = 0;
const sidedict = {
    "Tetrahedron": 4,
    "Cube": 6,
    "Octahedron": 8,
    "Dodecahedron": 12,
    "Icosahedron": 20
}
let c = 0;
let co;
rl.on('line', function(line){
    c++;
    if (c == 1) co = parseInt(line);
    if (c > 1) {
        sides += sidedict[line];
    }

    if ((co + 1) == c) {
        console.log(sides);
    }
});

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let t=+readLine()
	let sides={
		'Tetrahedron' : 4,
		'Cube' : 6,
		'Octahedron' : 8,
		'Dodecahedron' : 12,
		'Icosahedron' : 20
	}

	let totalFaces=0
	while(t--){
		let shape=readLine()
		totalFaces+=sides[shape]
	}
	console.log(totalFaces)
}

function main(input) {
    //Enter your code here
    const reference = {
        tetrahedron: 4,
        cube: 6,
        octahedron: 8,
        dodecahedron: 12,
        icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split('\r\n');
    for(let i = 1; i< inputArray.length; i++) {
        if(reference.hasOwnProperty(inputArray[i].toLowerCase())) {
            total = total + reference[inputArray[i].toLowerCase()];
        }
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split(/[\r\n]/).filter(data => data.length > 0);

for (let i = 0; i < txt.length; i++) {
    if (!isNaN(txt[i] * 1)) {
        let tab = [];
        for (let i1 = i + 1; i1 < i + 1 + txt[i] * 1; i1++) {
            tab.push(txt[i1]);
        }
        doit(tab);
    }

}

function doit(tab) {
    let obj = {
        Icosahedron: 20,
        Cube: 6,
        Tetrahedron: 4,
        Dodecahedron: 12,
        Octahedron: 8
    };
    let score=0;
    tab.forEach(element => {
       score+=obj[element];
    });
    console.log(score);

}

const figures = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

var buffer = '';

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
        buffer += chunk;
    }
});

process.stdin.on('end', solve);

function solve() {
    buffer = buffer.split('\r\n');
    var accum = 0;
    for (let i = 1; i <= buffer[0]; i++) {
        accum += figures[buffer[i]];
    }
    process.stdout.write('' + accum);
}

const figures = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

var buffer = '';

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
        buffer += chunk;
    }
});

process.stdin.on('end', () => {
    buffer = buffer.split('\r\n');
    var accum = 0;
    for (let i = 1; i <= buffer[0]; i++) {
        accum += figures[buffer[i]];
    }
    process.stdout.write('' + accum);
});

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let polyhedrons = {
        'Tetrahedron': 4,
        'Cube': 6,
        'Octahedron': 8,
        'Dodecahedron': 12,
        'Icosahedron': 20,
    };
    let sum = 0;
    let shapes = inputs.slice(1);
    for (let row of shapes) {
        if (polyhedrons[row.trim()]) {
            sum += polyhedrons[row.trim()];
        }
    }

    return sum.toString();
}

var data1 = readline().split(' ').map(function(x){return parseInt(x)});
var data2 = [];
for (i = 0; i<data1[0]; i++){
	data2.push(readline());
}

var result = solution(data1[0], data2);
print(result);

// End of interface

function solution(n, s){
	var res = 0;
	for(i = 0; i < n; i++){
			switch (s[i]) {
				case 'Tetrahedron':
					res = res + 4;
					break;
				case 'Cube':
					res = res + 6;
					break;
				case 'Octahedron':
					res = res + 8;
					break;
				case 'Dodecahedron':
					res = res + 12;
					break;
				case 'Icosahedron':
					res = res + 20;
					break;
			}
	}
	return res;
};

var dic = {"Tetrahedron":4 , "Cube":6 , "Octahedron":8 , "Dodecahedron":12 , "Icosahedron":20};
var n = 0;
var step = Number(readline());
for (i = 0 ; i <step ; i++){
    n += dic[readline()]
}
print(n)

function ansa(t,arr){

  var face = 0;
  for(var i = 0 ; i < t ; i++){
    if(arr[i] === "Tetrahedron" )face += 4;
    else if(arr[i] === "Cube" )face += 6;
    else if(arr[i] === "Octahedron" )face += 8;
    else if(arr[i] === "Dodecahedron" )face += 12;
    else face += 20;
  }
    print(face);
    return;
}

var line = readline();
line = parseInt(line);
var shapes = []
for(var i = 0 ; i < line ; i++ ){
  shapes[i] = readline()
}
ansa(line,shapes);
// for(var i = 0 ; i < line.length ; i++) line[i] = parseInt(line[i]);
// var line2 = readline().split(' ');
// for(var i = 0 ; i < line2.length ; i++) line2[i] = parseInt(line2[i]);

// ansa(parseInt(line),arr);

var n = parseInt(readline()), i = 0;
var s, res=0;

for(i=0;i<n;i++)
{
  s = readline();
  if(s == "Tetrahedron") res += 4;
  if(s == "Cube") res += 6;
  if(s == "Octahedron") res += 8;
  if(s == "Dodecahedron") res += 12;
  if(s == "Icosahedron") res += 20;
}

print(res);

var n = parseInt(readline()),
	counter = 0,
	scores = {
		Tetrahedron: 4,
		Cube: 6,
		Octahedron: 8,
		Dodecahedron: 12,
		Icosahedron: 20
	}

while (n > 0) {
	counter += scores[readline()]
	n --
}

print(counter)

var n = Number.parseInt(readline());
var mapping = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
var result = 0;

for (var i = 0; i < n; i++) {
    result += mapping[readline()];
}

print(result);

var shapes = {
  "Tetrahedron": 4,
  "Cube": 6,
  "Octahedron": 8,
  "Dodecahedron": 12,
  "Icosahedron": 20,
}

var numberOfShape = Number(readline())

var numberOfFaces = 0

for (var i = 0; i < numberOfShape; i++) {
  var shape = readline()
  numberOfFaces += shapes[shape]
}

print(numberOfFaces)

var input = parseInt(readline());
 var obj = {
     'Tetrahedron':4,
     'Cube':6,
     'Octahedron':8,
     'Dodecahedron':12,
     "Icosahedron": 20,
 }

 var count =0;
 for(var i = 0; i<input ; i++){
     count += obj[readline()];
 }
 print(count);

var res = sol(readline());
print(res);

function sol(line) {
    var input = line.split(" ");

    var n = input[0];
    var faces = 0;

    while(n > 0){
        var name = readline();

        if(name == "Tetrahedron"){
            faces += 4;
        }else if(name == "Cube"){
            faces += 6;
        }else if(name == "Octahedron"){
            faces += 8;
        }else if(name == "Dodecahedron"){
            faces += 12;
        }else if(name == "Icosahedron"){
            faces += 20;
        }
        n--;
    }

    return faces;
}

var amount = parseInt(readline());
var numberOfFaces = 0;

var polyhedrons = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
}

for (var i = 0; i < amount; i++) {
    numberOfFaces += polyhedrons[readline()];
}

print(numberOfFaces);

var n = parseInt(readline());
var log = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron:20};
var sideCount = 0;
while (n--) {
	sideCount += log[readline()];
}
print(sideCount);

var polyhedron = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron: 20},
    n = parseInt(readline()),
    sum = 0;

for(var i = 0; i < n; i++)
    sum += polyhedron[readline()];

print(sum);

var o = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
}
var n = parseInt(readline())
var total = 0;
while (n != 0) {
    n--;
    total += o[readline().trim()]
}
print(total)

'use strict'
let n = parseInt(readline()),
    dict = {
      Tetrahedron: 4,
      Cube: 6,
      Octahedron: 8,
      Dodecahedron: 12,
      Icosahedron: 20
    },
    counter = 0;

for (let i = 0; i < n; i++) {
  const key = readline();
  counter+=dict[key];
}
write(counter);

var n = +readline(),
    ans = 0;

for (var i = 0; i < n; i++) {
  var name = readline();

  switch (name) {
    case "Tetrahedron":
      ans += 4;
      break;
    case "Cube":
      ans += 6;
      break;
    case "Octahedron":
      ans += 8;
      break;
    case "Dodecahedron":
      ans += 12;
      break;
    case "Icosahedron":
      ans += 20;
      break;
  }
}

print(ans);

l=readline();
  n=l;
var tet=0, cub=0, oct=0, dod=0, ico=0;
for (i=0; i<n; i++) {
  v=readline();
  if (v=="Tetrahedron") tet++;
  if (v=="Cube") cub++;
  if (v=="Octahedron") oct++;
  if (v=="Dodecahedron") dod++;
  if (v=="Icosahedron") ico++;
}
sum=4*tet+6*cub+8*oct+12*dod+20*ico;
print(sum)

var number=readline();
var count=0;
var figure={
    "Tetrahedron":4,
    "Cube":6,
    "Octahedron":8,
    "Dodecahedron":12,
    "Icosahedron":20
}

for(var i=0;i<number;i++){
    var figuresName=readline();
    count+=figure[figuresName];
    // print(figure[figuresName])
}
print(count);

var n = readline();
var figure = {
"Cube":6,
"Icosahedron":20,
"Tetrahedron":4,
"Dodecahedron":12,
"Octahedron":8
}
var res = 0;
		for (var i = 0; i<+n; i++){
				var str = readline();
				res+= figure[str];
		}
		print(res);

var nop = parseInt(readline());
var polyhedrons = {
	Tetrahedron:4,
	Cube:6,
	Octahedron:8,
	Dodecahedron:12,
	Icosahedron:20
}

var count = 0 ;

for( i =1 ; i <= nop ; i++ ){
    var p = readline();

    count += polyhedrons[p];
}

print(count);

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     while(n){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n--;
     }
     print(sum);

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     for(var i = 0; i < n; i++){
     	if(str === "Tetrahedron") sum += 4; break;
     	if(str === "Cube") sum += 6; break;
     	if(str === "Octahedron") sum += 8; break;
     	if(str === "Dodecahedron") sum += 12; break;
     	if(str === "Icosahedron") sum += 20; break;
     }
     print(sum);

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     for(var i = 0; i < n; i++){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     }
     print(sum);
	//print(readline().includes("Tetrahedron") ? sum +=== 4:
	//("Cube") ? sum += 6 : ("Octahedron") ?sum += 8 :
	//("Dodecahedron") ? sum += 12 : ("Icosahedron") ? sum += 20;

//Tetrahedron 4
//Cube 6
//Octahedron 8
//Dodecahedron 12
//Icosahedron 20

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     for(var i = 0; i <= n; i++){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     }
     print(sum);

	 var n = parseInt(readline());
	var sum = 0;
     for(var i = 0; i < n; i++){
     	var str = readline();
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n --;
     }
     print(sum);

	 var n = parseInt(readline());
	var sum = 0;
	var str = readline();
     while(n){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n --;
     }
     print(sum);

var n = Number(readline());
var arr = [];

for(var i = 0; i <= n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

var n = readline();
var arr = [];
for(var i = 0; i <= n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(i => result += obj[i])

print(result)

var n = Number(readline());
var arr = [];

for(var i = 0; i < n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
}

var result = 0;
arr.map(item => result += obj[item])

print(arr)

var n = readline();
var arr = [];
for(var i = 0; i <= n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

var n = readline();
var arr = [];
for(var i = 0; i <= n; i++) {
    var el = readline();
    arr.push(el);
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

var a = readline(), b, c = 0;

for (; a; a--) {
  b = readline()[0];
  if (b === 'C') c += 6; continue;
  if (b === 'D') c += 12; continue;
  if (b === 'I') c += 20; continue;
  if (b === 'O') c += 8; continue;
  if (b === 'T') c += 4; continue;
}

print(c);

var a = readline(), b, c = 0;

for (; a > 0; a--) {
  b = readline()[0];
  if (b === 'C') c += 6; continue;
  if (b === 'D') c += 12; continue;
  if (b === 'I') c += 20; continue;
  if (b === 'O') c += 8; continue;
  if (b === 'T') c += 4; continue;
}

print(c);

var numbers = readline();
var a = numbers[0];
 var number = readline().split("\n");
var b = 0;
for(var i=0; i<a; i++){
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}
print(b)

var numbers = readline();
var a = numbers[0];
var number = []
var e=[];
var b = 0;

for(var i=0; i<a; i++){
    number.push(readline())
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}

print(b)

var numbers = readline();
var number = readline().split(' ');
var a = numbers[0];
var b = 0;
for(var i=0; i<a; i++){
    number[i];
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}
print(b)

var array = {"Tetrahedron": 3, "Cube": 6, "Octahedron": 8, "Dodecahedron": 12, "Icosahedron": 20};
var n = parseInt(readline());

var sum=0;
for (var i = 0; i < n; i++) {
    var key=readline();
    sum+=array[key];
}

print(sum);

var limit = parseInt(readline());
var map = {}
map['Icosahedron'] = 20;
map['Dodecahedron'] = 12;
map['Octahedron'] = 8;
map['Cube'] = 6;
map['Tetrahedron'] = 4;
var sum = 0;
for (var i = 0; i < limit; i++) {
  sum += parseInt(readline());
}
print(sum);

var limit = parseInt(readline());
var map = {}
map['Icosahedron'] = 20;
map['Dodecahedron'] = 12;
map['Octahedron'] = 8;
map['Cube'] = 6;
map['Tetrahedron'] = 4;
var sum = 0;
print(limit);

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let i = 0;

rl.question('Number of inputs : ', (number) => {
  const shapeNames = [] ;
  rl.on('line', (shapeName) => {
    i++;
    shapeNames.push(shapeName) ;
    if (i >= parseInt(number)) {
      calFacesNum(shapeNames) ;
      rl.close();
    }
  });
});

function calFacesNum(faces) {
  let facesNumber = 0;
  for (let i = 0; i < faces.length; i++) {

    switch (faces[i]) {
      case 'Tetrahedron':
        facesNumber += 4;
        break;
      case 'Cube':
        console.log('hello amir is here') ;
        facesNumber += 6;
        break;
      case 'Octahedron':
        facesNumber += 8;
        break;
      case 'Dodecahedron':
        facesNumber += 12;
        break;
      case 'Icosahedron':
        facesNumber += 20;
        break;
    }
  }
  console.log(facesNumber) ;
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [count, ...geometry] = input
  count = parseInt(count, 10)
  function returnCountGeometry(el){
    switch(el){
      case 'Tetrahedron': {
        return 4
      } break;
      case 'Cube': {
        return 6
      } break;
      case 'Octahedron': {
        return 8
      } break;
      case 'Dodecahedron': {
        return 12
      } break;
      case 'Icosahedron': {
        return 20
      } break;
      default: {
        return 0
      }
    }
  }
  let _fin = 0
  for (let i = 0; i < count; i ++) {
    const el = geometry[i]
    const counter = returnCountGeometry(el)
    _fin += counter
  }
  console.log(_fin)
});

function IO(rs, ws, readSize = 1024) {
  let buffer = Buffer.from([]);
  let nextLineIndex;
  let line;
  let chunk;

  return {
    rl() {
      while(true) {
        newLineIndex = buffer.indexOf('\n');

        if (newLineIndex === -1 && rs.readableLength === 0) {
          newLineIndex = buffer.length;
        }

        if (newLineIndex !== -1) {
          line = buffer.slice(0, newLineIndex);

          buffer = buffer.slice(newLineIndex + 1);

          return line.toString('utf-8');
        }

        if (rs.readableLength === 0) {
          return null
        }

        chunk = rs.read(Math.min(readSize, rs.readableLength));

        if (!chunk) { return null; }

        buffer = Buffer.concat([ buffer, chunk ]);
      }
    },

    wr(str) {
      return ws.write(str);
    },

    wl(str) {
      return ws.write(str + '\n');
    }
  };
}

process.stdin.once('readable', () => sol(IO(process.stdin, process.stdout)));

function sol({ rl, wr, wl }) {
  const grani = {
    T: 4,
    C: 6,
    O: 8,
    D: 12,
    I: 20,
  };

  const n = Number(rl());
  let sum = 0;

  for (let i = 0; i < n; i += 1) {
    const f = rl()[0];
    sum += grani[f];
  }

  return wl(sum);
}

// Nothing special here, just self-made reading api
class Reader{constructor(a,b){this.stream=a,this.stream.setEncoding("utf8"),this.bufSize=b||1024,this.buf="",this.streamEnded=!1}onReadable(a){return()=>{for(let b;-1===(b=this.buf.indexOf("\n"));){if(0===this.stream.readableLength)return this.stream.read(),void this.stream.once("readable",this.onReadable(a));this.buf+=this.stream.read(Math.min(this.bufSize,this.stream.readableLength))}this.stream.removeAllListeners("end"),this.readline().then(a)}}onEnd(a){return()=>{this.streamEnded=!0,this.readline().then(a)}}readline(){return new Promise(a=>{const b=this.buf.indexOf("\n");if(-1===b&&!this.streamEnded)this.stream.once("readable",this.onReadable(a)),this.stream.once("end",this.onEnd(a));else{let c;this.streamEnded?(c=this.buf,this.buf=""):(c=this.buf.substring(0,b),this.buf=this.buf.substring(b+1)),a(c)}})}}(async()=>{const a=new Reader(process.stdin);await solution(a.readline.bind(a),console.log.bind(this))})();

async function solution(rl, wl) {
  const grani = {
    T: 4,
    C: 6,
    O: 8,
    D: 12,
    I: 20,
  };
  const n = parseInt((await rl()), 10);
  let sum = 0;
  for (let i = 0; i < n; i += 1) {
    const f = (await rl())[0];
    sum += grani[f];
  }
    wl(sum);
}

function IO(rs, ws, readSize = 1024) {
    let buffer = Buffer.from([]);
    let nextLineIndex;
    let line;
    let chunk;

    return {
      rl() {
        while(true) {
          newLineIndex = buffer.indexOf('\n');

          if (newLineIndex === -1 && rs.readableLength === 0) {
            newLineIndex = buffer.length;
          }

          if (newLineIndex !== -1) {
            line = buffer.slice(0, newLineIndex);

            buffer = buffer.slice(newLineIndex + 1);

            return line.toString('utf-8');
          }

          if (rs.readableLength === 0) {
            return null
          }

          chunk = rs.read(Math.min(readSize, rs.readableLength));

          if (!chunk) { return null; }

          buffer = Buffer.concat([ buffer, chunk ]);
        }
      },

      wr(str) {
        return ws.write(str);
      },

      wl(str) {
        return ws.write(str + '\n');
      }
    };
  }

  process.stdin.once('readable', () => sol(IO(process.stdin, process.stdout, 32)));

  function sol({ rl, wr, wl }) {
    const grani = {
      T: 4,
      C: 6,
      O: 8,
      D: 12,
      I: 20,
    };

    const n = Number(rl());
    let sum = 0;

    for (let i = 0; i < n; i += 1) {
      const f = rl()[0];
      sum += grani[f];

      if (Number.isNaN(sum)) {
          return wl(`${f} ${i}`);
      }
    }

    return wl(sum);
  }

function IO(rs, ws, readSize = 1024) {
    let buffer = Buffer.from([]);
    let nextLineIndex;
    let line;
    let chunk;

    return {
      rl() {
        while(true) {
          newLineIndex = buffer.indexOf('\n');

          if (newLineIndex === -1 && rs.readableLength === 0) {
            newLineIndex = buffer.length;
          }

          if (newLineIndex !== -1) {
            line = buffer.slice(0, newLineIndex);

            buffer = buffer.slice(newLineIndex + 1);

            return line.toString('utf-8');
          }

          if (rs.readableLength === 0) {
            return null
          }

          chunk = rs.read(Math.min(readSize, rs.readableLength));

          if (!chunk) { return null; }

          buffer = Buffer.concat([ buffer, chunk ]);
        }
      },

      wr(str) {
        return ws.write(str);
      },

      wl(str) {
        return ws.write(str + '\n');
      }
    };
  }

  process.stdin.once('readable', () => sol(IO(process.stdin, process.stdout, 32)));

  function sol({ rl, wr, wl }) {
    const grani = {
      T: 4,
      C: 6,
      O: 8,
      D: 12,
      I: 20,
    };

    const n = Number(rl());
    let sum = 0;

    for (let i = 0; i < n; i += 1) {
      const f = rl()[0];
      sum += grani[f];

      if (Number.isNaN(sum)) {
          return wl(f);
      }
    }

    return wl(sum);
  }

'use strict';

let input = [];
let count_flow = {
    'Icosahedron': 20,
    'Cube': 6,
    'Tetrahedron': 4,
    'Dodecahedron': 12,
    'Octahedron': 8,
}

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', (line) => {
    line.split(' ').map(x => input.push(x));
});

RL.on('close', () => {
    let n = parseInt(input[0]), sum = 0;
    console.log(input);
    for (let i = 1; i <= n; i++)
        sum += count_flow[input[i]];
    console.log(sum);
});

let heterolist = [];
let gayNum = 0;
let iter = 0;

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function checkSum(line){
    if (line == 'Tetrahedron'){
        return 4;
    } else if (line == 'Cube'){
        return 6;
    } else if (line == 'Octahedron'){
        return 8;
    } else if (line == 'Dodecahedron'){
        return 12;
    } else if (line == 'Icosahedron'){
        return 20;
    }
};

rl.question('', (answer) => {
    sizeOfArray = answer;
    console.log('sizeOfArray', answer);
});

rl.on('line', (line) => {
        //heterolist.push(line.split(' ', 1).map(String));
        gayNum += checkSum(line.split(' ', 1).map(String));
        iter++;
        if(iter == sizeOfArray){
            console.log(gayNum);
            process.exit(0);
        }
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;

    const inputArray = input.split("\n");
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        tetrahedron: 4,
        cube: 6,
        octahedron: 8,
        dodecahedron: 12,
        icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split('\r\n');
    console.log(inputArray)
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i].toLowerCase()];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split('\r\n');
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;

    const inputArray = input.split("\n");
    console.log(inputArray);
    for(let i = 1; i< inputArray.length; i++) {
        reference[inputArray[i]];
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split("\r\n");
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

const names = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

process.stdin.on('data', (input) => {
    process.stdout.write(input.toString().split('\n').slice(1).map((x) => names[x.trim()]).reduce((x, y) => x + y).toString());
});

const names = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

process.stdin.on('data', (input) => {
    process.stdout.write(input.toString().trim().split('\n').slice(1).map((x) => names[x.trim()]).reduce((x, y) => x + y).toString());
});

var input='';

process.stdin.on('data',(givenInput)=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=(input)=>{

    const n=Number(input.split('\r\n')[0]);
    let strArr=input.split('\r\n');

    let num,total=0;

    for(let i=1;i<strArr.length;i++){

        str=strArr[i];

        switch(str){
            case 'Tetrahedron': num=4; break;
            case 'Cube': num=6; break;
            case 'Octahedron': num=8 ; break;
            case 'Dodecahedron': num=12 ; break;
            case 'Icosahedron': num=20 ; break;
        }

        total+=num;
    }

    console.log(total);

}

var input='';

process.stdin.on('data',(givenInput)=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=()=>{

    const n=Number(input.split('\r\n')[0]);
    let strArr=input.split('\r\n');

    let num,total=0;

    for(let i=1;i<strArr.length;i++){

        str=strArr[i];

        switch(str){
            case 'Tetrahedron': num=4; break;
            case 'Cube': num=6; break;
            case 'Octahedron': num=8 ; break;
            case 'Dodecahedron': num=12 ; break;
            case 'Icosahedron': num=20 ; break;
        }

        total+=num;
    }

    console.log(total);

}

var result = solution(readline().split(' '));
print(result);

// End of interface

function solution(c) {
	var n = parseInt(c[0]);
	var arr = c.slice(1);

	var main = function(n, k){
		var res = 0;
		for(i = 0; i < n; i++){
			switch (k[i]) {
				case 'Tetrahedron':
					res = res + 4;
					break;
				case 'Cube':
					res = res + 6;
					break;
				case 'Octahedron':
					res = res + 8;
					break;
				case 'Dodecahedron':
					res = res + 12;
					break;
				case 'Icosahedron':
					res = res + 20;
					break;
			}
		}
		return res;
	};

	return main(n, arr);
}

var n = parseInt(readline());
var log = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron:20};
var sideCount = 0;
while (n--) {
	sideCount += sideCount[readline()];
}
print(sideCount);

var number=readline();
var count=0;
var figure={
    "Tetrahedron":4,
    "Cube":6,
    "Octahedron":8,
    "Dodecahedron":12,
    "Icosahedron":20
}

for(var i=0;i<number;i++){
    var figuresName=readline();
    count+=figure[figuresName];
    print(figure[figuresName])
}
print(count);


There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.

6

3

LLR

5

LRRLL

1

L

12

LRRRLLLRLLRL

10

LLLLLRRRRR

9

LRLRLRLRL

NoteIn the first test case:   $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$.  $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$.  $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).

const readline = require('readline');
const { stdin: input, stdout: output } = require('process')
const rl = readline.createInterface({ input, output })

let lines = []

const createReadLine = () => {
  i = 0;
  return () => lines[i++]
}

rl.on('line', line => lines.push(line))

rl.on('close', () => {
  const readLine = createReadLine();
  let t = parseInt(readLine())
  while (t--) {
    const n = parseInt(readLine())
    const people = readLine()

    let ans = 0
    let res = ''
    let values = []
    for (let i = 0; i < n; i++) {
      if (people[i] == 'L') {
        values.push(n - i - 1 - i)
        ans += i
      } else {
        values.push(i - (n - i - 1))
        ans += n - i - 1
      }
    }

    values.sort((a, b) => a - b)

    for (let i = 0; i < n; i++) {
      if (values[n - i - 1] > 0) {
        ans += values[n - i - 1]
      }
      res += `${ans} `
    }
    console.log(res)
  }
})

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let s =  readline().split('');

        let pot = (i, char) => {
            if ((i === 'L' && i > (s.length / 2)) || (i === 'R' && i < (s.length / 2))) {
                return 0;
            }
            let left = val(i, 'L');
            let right = val(i, 'R');
            if (char === 'L' && left > right) {
                return 0;
            } else if (char === 'R' && right > left) {
                return 0;
            } else if (left === right) {
                return 0;
            }
            let max = Math.max(left, right);
            let min = Math.min(left, right);
            return max - min;
        };

        let val = (i, dir) => {
            if (dir === 'L') {
                return i;
            } else {
                return s.length - i - 1;
            }
        }

        let sum = s.map((char, index) => val(index, char)).reduce((a, b) => a + b, 0);

        let v = s.map((val, i) => ({ diff: pot(i, val), i }));
        v.sort((a, b) => b.diff - a.diff);

        let values = [];
        for (let i = 0; i < n; i++) {
            sum += v[i].diff;
            values.push(sum);
        }

        output(values.join(' '));
    }
}

let fs = require("fs");
let sc = {
    _buf: new Buffer.alloc(1 << 14),
    _bufPos: 0,
    _bufLen: 0,
    _ensure: function ()
    {
        if (this._bufPos === this._bufLen)
        {
            this._bufPos = 0;
            this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
        }
    },
    _isws: function (ch)
    {
        return ch === 32 || ch === 9 || ch === 10 || ch === 13;
    },
    _islf: function (ch)
    {
        return ch === 10 || ch === 13;
    },
    _peekChar: function ()
    {
        this._ensure();
        return this._bufPos === this._bufLen ? 0 : this._buf[this._bufPos];
    },
    _skipWs: function ()
    {
        while (this._isws(this._peekChar()))
            this._bufPos++;
    },
    _readUntil: function (stop)
    {
        this._ensure();
        if (this._bufPos === this._bufLen)
            throw new Error("eof");
        let start = this._bufPos;
        let before = null;
        for (; ;)
        {
            if (this._bufPos === this._bufLen)
            {
                let len = this._bufPos - start, preLen = (before ? before.length : 0);
                let nbuf = new Buffer(len + preLen);
                if (before)
                    before.copy(nbuf);
                before = nbuf;
                this._buf.copy(before, preLen, start);
                this._ensure();
                start = this._bufPos;
            }
            if (this._bufPos === this._bufLen || stop(this._buf[this._bufPos])) break;
            this._bufPos++;
        }
        if (!before)
            return this._buf.toString("utf8", start, this._bufPos);
        let after = this._buf.slice(start, this._bufPos);
        let res = new Buffer(before.length + after.length);
        before.copy(res);
        after.copy(res, before.length);
        return res.toString();
    },

    nextToken: function ()
    {
        this._skipWs();
        return this._readUntil(this._isws);
    },
    L: function ()
    {
        let line = this._readUntil(this._islf);
        if (this._peekChar() === 13) this._bufPos++;
        if (this._peekChar() === 10) this._bufPos++;
        return line;
    },
    N: function ()
    {
        return +this.nextToken();
    },
    S: function ()
    {
        return this.nextToken();
    }
};

// DO NOT CHANGE TEMPLATE BEFORE

const Def = Number(1e9);

const LowerBound = (arr, val) =>
{
    let ng = -1;
    let ok = arr.length;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] >= val)
        {
            ok = med;
        }
        else
        {
            ng = med;
        }
    }

    return ok;
}

const ReverseLowerBound = (arr, val) =>
{
    let ng = 0;
    let ok = arr.length;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] <= val)
        {
            ng = med;
        }
        else
        {
            ok = med;
        }
    }
    // Находит наибольший элемент который меньше или равен val
    return ng;
}

const ReverseUpperBound = (arr, val) =>
{
    let ng = 0;
    let ok = arr.length;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] < val)
        {
            ng = med;
        }
        else
        {
            ok = med;
        }
    }
    // Находит наибольший элемент который меньше val
    return ng;
}

const UpperBound = (arr, val) =>
{
    let ok = arr.length;
    let ng = -1;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] > val)
        {
            ok = med;
        }
        else
        {
            ng = med;
        }
    }

    return ok;
}

const Calc = (c, i, n) =>
{
    if (c === 'L')
    {
        return i;
    }
    else return n - i - 1;
}

const R = (c) =>
{
    if (c === 'R') return 'L';
    if (c === 'L') return 'R';
}

class Container
{
    i = -1;
    score = -1;
    constructor(i, score)
    {
        this.i = i;
        this.score = score;
    }
}

const Solve = () =>
{
    let n = +sc.N();
    let arr = [...sc.S()];

    let res = [];

    let t = 0;
    for (let i = 0; i < n; ++i)
    {
        t += Calc(arr[i], i, n);
    }

    // console.log(`t = ${t}`);

    let big = [];

    for (let i = 0; i < n; ++i)
    {
        let one = Calc(arr[i], i, n);
        let two = Calc(R(arr[i]), i, n);

        // let max = Math.max(one, two);
        // let min = Math.min(one, two);
        //
        // console.log(`min = ${min} and max = ${max}`);
        //
        // t -= min;
        // t += max;

        // console.log(`two = ${two} and ${one}`);

        let score = 0 - one;
        score += two;

        big.push(new Container(i, score));

        // res[idx++] = t;
    }

    big.sort((l, r) =>
    {
        return r.score - l.score;
    });

    // for (let o of big)
    // {
    //     console.log(`o.i = ${o.i} and o.score = ${o.score}`);
    // }

    for (let i = 0; i < n; ++i)
    {
        if (big[i].score > 0)
        {
            t += big[i].score;
        }

        // console.log(`t = ${t}`);
        res.push(t);
    }

    console.log(res.join(' '));

}

const main = () =>
{
    let cases = +sc.L();
    while (cases-- > 0) Solve();

    // Solve();
}
main();

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var S = next();
		var sum = 0;
		var add = [];
		for(var i = 0; i < N / 2; i++){
			if(S[i] == "L"){
				add.push(N - i - 1 - i);
				sum += i;
			}else{
				sum += N - i - 1;
			}
			if(S[N - i - 1] == "R"){
				add.push(N - i - 1 - i);
				sum += i;
			}else{
				sum += N - i - 1;
			}
			if(N % 2 == 1 && i == Math.floor(N / 2)){
				sum -= i;
				add.pop();
			}
		}

		add.sort(function(a,b){
			return b - a;
		});
		var output = [];
		for(var i = 0; i < N; i++){
			if(i < add.length){
				sum += add[i];
			}
			output.push(sum);
		}
		myout(myconv(output, 8));
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const str = lines[l++]
        output[i] = solve(n, str)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, str) {
    const arr = []
    let s = 0
    for (let i = 0; i < str.length; i++) {
        const l = i
        const r = n - 1 - l
        if (str[i] === 'L') {
            arr[i] = [i, l, r - l]
            s += l
        } else {
            arr[i] = [i, r, l - r]
            s += r
        }
    }
    // console.log(s, arr)
    return arr.sort((a, b) => b[2] - a[2])
        .map(([i, now, d]) => {
            if (d > 0) {
                s += d
            }
            return s
        }).join(' ')
}

var t = parseInt(readline());

while(t--){

    var n = parseInt(readline());
    var middle = parseInt(n/2);
    var s = readline();
    var bestValue = [];
    var res = 0;
    for(var i = 0; i < n; i++){
        var crntValue =  s[i] === "L"? i : n - i - 1;
        res += crntValue;
        bestValue.push((i < middle? n - i - 1: i) - crntValue);
    }
    bestValue.sort((a, b ) => b - a);
    var resS = "";
    for(var i = 0; i < n; i++){
        res += bestValue[i]
        resS += res;
        if(i !== n-1) resS += " ";

    }

    print(resS);

}

var t = parseInt(readline());

for (var test = 0; test < t; test++) {
    var n = parseInt(readline());
    var arr = readline().split('');

    if (n === 1) {
        print('0');
        continue;
    }

    var ans = [];

    var value = 0;
    for (var i = 0; i < n; i++) {
        if (arr[i] === 'R') {
            value = value + n - i - 1;
        } else {
            value = value + i;
        }
    }

    var left = 0;
    var right = n - 1;

    var counter = () => {
        while (2 * left < n - 1 && arr[left] === 'R') {
            ++left;
        }
        while (2 * right > n - 1 && arr[right] === 'L') {
            --right;
        }
        if (2 * left >= n - 1 && 2 * right <= n - 1) {
            return value;
        }
        if (n - 1 - 2 * left >= right - (n - 1 - right)) {
            value += n - 1 - 2 * left;
            ++left;
        } else {
            value += right - (n - 1 - right);
            --right;
        }
        return value;
    }

    for (var k = 1; k <= n; k++) {
        ans.push(counter());
    }

    print(ans.join(' '));
}

var n, s;

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        n = parseInt(readline());
        s = readline().split('');
        var sum = 0;
        for (var i = 0; i < n; i++) {
            if (s[i] == 'L') {
                sum += i;
            } else {
                sum += n - i - 1;
            }
        }
        var ans = [];
        var lp = 0, rp = 0;
        for (var k = 1; k <= n; k++) {
            while(s[lp] == 'R' && s[n-rp-1] == 'L' && (lp < (n-1) / 2 || rp < (n-1) / 2)) {
                if (lp <= rp) {
                    lp++;
                } else {
                    rp++;
                }
            }
            if (lp < (n-1) / 2 && s[lp] == 'L') {
                s[lp] = 'R';
                sum += (n - lp) - lp - 1;
            } else if (rp < (n-1) / 2 && s[n-rp-1] == 'R') {
                s[n-rp-1] = 'L';
                sum += (n - rp - 1) - rp;
            }
            ans.push(sum);
        }
        print(ans.join(' '));
    }

var t = +readline();

for(var i = 0; i< t; i ++) {

      var nums = [];
    var t1 = +readline();
    var arr1 = readline();

    print(Line(arr1))

}

function Line(s){

   var n = s.length;
    var scr = 0;
    var vec = [];
    for(var i = 0; i<s.length; i++){
        if (s[i] == 'R'){
            scr += n-i-1;
        }else {
            scr += i;
        }
        if ((i<(n-i-1)) && s[i] == 'L') {
            vec.push(n-1-i-i);
        }else if ((i > (n-1-i)) && s[i] == 'R'){
            vec.push(-n+1+i+i);
        }
    }
    vec.sort((a,b) => b-a);
    var ans = 0;
    var m = vec.length;
    var res = [];
    for(var k = 0; k<m; k++){
        ans += vec[k];
        res.push(scr + ans)
    }
    for(var t = m; t<n; t++){
        res.push(scr + ans)
    }
    return res.join(' ')

}


Mahmoud wants to send a message to his friend Ehab. Their language consists of n words numbered from 1 to n. Some words have the same meaning so there are k groups of words such that all the words in some group have the same meaning.Mahmoud knows that the i-th word can be sent with cost ai. For each word in his message, Mahmoud can either replace it with another word of the same meaning or leave it as it is. Can you help Mahmoud determine the minimum cost of sending the message?The cost of sending the message is the sum of the costs of sending every word in it.

The first line of input contains integers n, k and m (1 ≤ k ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of words in their language, the number of groups of words, and the number of words in Mahmoud's message respectively. The second line contains n strings consisting of lowercase English letters of length not exceeding 20 which represent the words. It's guaranteed that the words are distinct. The third line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) where ai is the cost of sending the i-th word. The next k lines describe the groups of words of same meaning. The next k lines each start with an integer x (1 ≤ x ≤ n) which means that there are x words in this group, followed by x integers which represent the indices of words in this group. It's guaranteed that each word appears in exactly one group. The next line contains m space-separated words which represent Mahmoud's message. Each of these words appears in the list of language's words.

The only line should contain the minimum cost to send the message after replacing some words (maybe none) with some words of the same meaning.

5 4 4
i loser am the second
100 1 1 5 10
1 1
1 3
2 2 5
1 4
i am the second

5 4 4
i loser am the second
100 20 1 5 10
1 1
1 3
2 2 5
1 4
i am the second

NoteIn the first sample, Mahmoud should replace the word "second" with the word "loser" because it has less cost so the cost will be 100+1+5+1=107.In the second sample, Mahmoud shouldn't do any replacement so the cost will be 100+1+5+10=116.

process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  const arr1 = arr.shift().split(' ').map(a => parseInt(a))
  const arr2 = arr.shift().split(' ').map(a => a.replace('\r', ''))
  const cost = arr.shift().split(' ').map(a => parseInt(a))
  const n = arr1[0]
  const k = arr1[1]
  const m = arr1[2]
  const wordIndexMap = {}

  if(n == 100) {
    // console.log(arr1[n-1], arr2, cost)
  }

  arr2.forEach((element, i) => {
    wordIndexMap[element] = {}
    wordIndexMap[element].index = i + 1
  });

  const groups = []

  for(let i = 0; i < k; i++) {
    const arr4 = arr[i].split(' ').map(a => parseInt(a))
    arr4.shift()
    arr4.forEach((a) => {
      wordIndexMap[arr2[a - 1]].group = i
      if(!groups[i]) groups[i] = cost[a - 1]
      else if(groups[i] > cost[a - 1]) groups[i] = cost[a - 1]
    })
  }

  let sum = 0

  const me = arr[k].split(' ').map(a => a.replace('\r', ''))

  for(let i = 0; i < m; i++) {
    const a = me[i]
    sum += groups[wordIndexMap[a].group]
  }

  console.log(sum)

})

process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const arr1 = arr.shift().split(' ').map(a => parseInt(a))
  const arr2 = arr.shift().split(' ')
  const cost = arr.shift().split(' ').map(a => parseInt(a))
  const n = arr1[0]
  const k = arr1[2]
  const m = arr1[2]
  const wordIndexMap = {}
  console.log(arr2)

  if(arr2[n - 1].includes('\r')) arr2[n - 1].replace('\r', '')

  arr2.forEach((element, i) => {
    wordIndexMap[element] = {}
    wordIndexMap[element].index = i + 1
  });

  const groups = []

  for(let i = 0; i < k; i++) {
    const arr4 = arr[i].split(' ').map(a => parseInt(a))
    arr4.shift()
    arr4.forEach((a) => {
      wordIndexMap[arr2[a - 1]].group = i
      if(!groups[i]) groups[i] = cost[a - 1]
      else if(groups[i] > cost[a - 1]) groups[i] = cost[a - 1]
    })
  }

  let sum = 0

  const me = arr[k].split(' ')

  for(let i = 0; i < m; i++) {
    const a = me[i]
    sum += groups[wordIndexMap[a].group]
  }

  console.log(sum)

})

process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const arr1 = arr.shift().split(' ').map(a => parseInt(a))
  const arr2 = arr.shift().split(' ')
  const cost = arr.shift().split(' ').map(a => parseInt(a))
  const n = arr1[0]
  const k = arr1[2]
  const m = arr1[2]
  const wordIndexMap = {}
  console.log(arr2)

  if(arr2[n - 1].includes('\r')) arr2[n - 1].replace(/(\r\n|\n|\r)/gm, '')
  console.log(arr2)

  arr2.forEach((element, i) => {
    wordIndexMap[element] = {}
    wordIndexMap[element].index = i + 1
  });

  const groups = []

  for(let i = 0; i < k; i++) {
    const arr4 = arr[i].split(' ').map(a => parseInt(a))
    arr4.shift()
    arr4.forEach((a) => {
      wordIndexMap[arr2[a - 1]].group = i
      if(!groups[i]) groups[i] = cost[a - 1]
      else if(groups[i] > cost[a - 1]) groups[i] = cost[a - 1]
    })
  }

  let sum = 0

  const me = arr[k].split(' ')

  for(let i = 0; i < m; i++) {
    const a = me[i]
    sum += groups[wordIndexMap[a].group]
  }

  console.log(sum)

})

process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const arr1 = arr.shift().split(' ').map(a => parseInt(a))
  const arr2 = arr.shift().split(' ')
  const cost = arr.shift().split(' ').map(a => parseInt(a))
  const n = arr1[0]
  const k = arr1[2]
  const m = arr1[2]
  const wordIndexMap = {}
  console.log(arr2)

  if(arr2[n - 1].includes('\r')) arr2[n - 1].replace('\r', '')
  console.log(arr2)

  arr2.forEach((element, i) => {
    wordIndexMap[element] = {}
    wordIndexMap[element].index = i + 1
  });

  const groups = []

  for(let i = 0; i < k; i++) {
    const arr4 = arr[i].split(' ').map(a => parseInt(a))
    arr4.shift()
    arr4.forEach((a) => {
      wordIndexMap[arr2[a - 1]].group = i
      if(!groups[i]) groups[i] = cost[a - 1]
      else if(groups[i] > cost[a - 1]) groups[i] = cost[a - 1]
    })
  }

  let sum = 0

  const me = arr[k].split(' ')

  for(let i = 0; i < m; i++) {
    const a = me[i]
    sum += groups[wordIndexMap[a].group]
  }

  console.log(sum)

})

process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const arr1 = arr.shift().split(' ').map(a => parseInt(a))
  const arr2 = arr.shift().split(' ')
  const cost = arr.shift().split(' ').map(a => parseInt(a))
  const n = arr1[0]
  const k = arr1[2]
  const m = arr1[2]
  const wordIndexMap = {}
  console.log(arr2)
  arr2.forEach((element, i) => {
    wordIndexMap[element] = {}
    wordIndexMap[element].index = i + 1
  });

  const groups = []

  for(let i = 0; i < k; i++) {
    const arr4 = arr[i].split(' ').map(a => parseInt(a))
    arr4.shift()
    arr4.forEach((a) => {
      wordIndexMap[arr2[a - 1]].group = i
      if(!groups[i]) groups[i] = cost[a - 1]
      else if(groups[i] > cost[a - 1]) groups[i] = cost[a - 1]
    })
  }

  let sum = 0

  const me = arr[k].split(' ')

  for(let i = 0; i < m; i++) {
    const a = me[i]
    sum += groups[wordIndexMap[a].group]
  }

  console.log(sum)

})


Let us denote by $$$d(n)$$$ the sum of all divisors of the number $$$n$$$, i.e. $$$d(n) = \sum\limits_{k | n} k$$$.For example, $$$d(1) = 1$$$, $$$d(4) = 1+2+4=7$$$, $$$d(6) = 1+2+3+6=12$$$.For a given number $$$c$$$, find the minimum $$$n$$$ such that $$$d(n) = c$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$). Then $$$t$$$ test cases follow. Each test case is characterized by one integer $$$c$$$ ($$$1 \le c \le 10^7$$$).

For each test case, output:    "-1" if there is no such $$$n$$$ that $$$d(n) = c$$$;  $$$n$$$, otherwise.

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007
const MAX = 1e7;

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = new Array(MAX + 1)
  var del = new Array(MAX + 1).fill(0)
  var sum = new Array(MAX + 1).fill(1)
  for (var i = 2; i * i <= MAX; i++) {
    if (!del[i]) {
      del[i] = i
      for (var j = i*i; j <= MAX; j += i) {
        if (!del[j]) del[j] = i
      }
    }
  }
  sum[1] =1
  del[1] =1
  for (let i = 2; i < MAX; i++) {
    if (!del[i]) {
      sum[i] = i + 1
      del[i] = i
    } else {
      var current = i
      sum[i] = 1
      while (current % del[i] === 0) {
        sum[i] = sum[i] * del[i] + 1
        current = current / del[i]
      }
      sum[i] = sum[i] * sum[current]
    }
  }
  for (let i = MAX; i >= 1; i--) {
    if (sum[i] <= MAX) object[sum[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })

  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007
const MAX = 100;

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = new Array(MAX + 1)
  var del = new Array(MAX + 1).fill(0)
  var sum = new Array(MAX + 1).fill(1)
  for (var i = 2; i * i <= MAX; i++) {
    if (!del[i]) {
      del[i] = i
      for (var j = i*i; j < MAX; j += i) {
        if (!del[j]) del[j] = i
      }
    }
  }
  sum[1] =1
  del[1] =1
  for (let i = 2; i < MAX; i++) {
    if (!del[i]) {
      // console.log(i)
      sum[i] = i + 1
      del[i] = i
    } else {
      var current = i
      sum[i] = 1
      while (current % del[i] === 0) {
        sum[i] = sum[i] * del[i] + 1
        current = current / del[i]
      }
      sum[i] = sum[i] * sum[current]
    }
  }
  for (let i = MAX; i >= 1; i--) {
    if (sum[i] <= MAX) object[sum[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })

  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007
const MAX = 1000000;

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = []
  var count = new Array(MAX + 1).fill(0)
  for (let i = 1; i <= MAX; i++) {
    for (let j = i; j <= MAX; j = j + i) {
      count[j] = count[j] + i
    }
  }

  for (let i = MAX*10; i >= 0; i--) {
    if (count[i] <= MAX*10) object[count[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })
  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007
const MAX = 1000000;

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = []
  var count = new Array(MAX + 1).fill(0)
  for (let i = 1; i <= MAX; i++) {
    for (let j = i; j <= MAX; j = j + i) {
      count[j] = count[j] + i
    }
  }

  for (let i = MAX; i >= 0; i--) {
    if (count[i] <= MAX) object[count[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })
  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = {}
  var count = {}
  for (let i = 1; i < 1e6+1; i++) {
    for (let j = i; j <= 1e6+1; j += i) {
      if (!count[j]) count[j] = 0;
      count[j] = count[j] + i
    }
  }

  for (let i = 1e6; i >=0 ; i--) {
    if (count[i] <= 1e6) object[count[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })
  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = {}
  var count = {}
  for (let i = 1; i < 10e5+1; i++) {
    for (let j = i; j <= 10e5+1; j += i) {
      if (!count[j]) count[j] = 0;
      count[j] = count[j] + i
    }
  }

  for (let i = 10e5; i >=0 ; i--) {
    if (count[i] <= 10e5) object[count[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })
  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = {}
  var count = {}
  for (let i = 1; i < 1000001; i++) {
    for (let j = i; j <= 1000001; j += i) {
      if (!count[j]) count[j] = 0;
      count[j] = count[j] + i
    }
  }

  for (let i = 1000001; i >=0 ; i--) {
    if (count[i] <= 1000001) object[count[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })
  console.log(res)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  var object = {}
  var count = {}
  for (let i = 1; i < 10e5; i++) {
    for (let j = i; j <= 10e5; j += i) {
      if (!count[j]) count[j] = 0;
      count[j] = count[j] + i
    }
  }

  for (let i = 0; i <= 10e5; i++) {
    if (count[i] <= 10e5) object[count[i]] = i
  }
  var res = ''

  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    // var a = readline().split(' ').map((x, iii) => {
    //   return BigInt(x)
    // })
    res += (object[n] ? object[n] : -1).toString() + '\n'
  })
  console.log(res)
}


Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic:  The following matrices are not palindromic because they change after the order of rows is reversed:  The following matrices are not palindromic because they change after the order of columns is reversed:  You are given $$$n^2$$$ integers. Put them into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic. If there are multiple answers, print any. If there is no solution, print "NO".

The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) — the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.

If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers — the resulting matrix. If it's impossible to construct any matrix, then print "NO". You can print each letter in any case (upper or lower). For example, "YeS", "no" and "yES" are all acceptable.

NoteNote that there exist multiple answers for the first two examples.

var n = readline().split(" ").map(function(x) { return parseInt(x); })[0];
var s = readline().split(" ").map(function(x) { return parseInt(x); });
var cnt = Array(1001).fill(0);
for (var i=0; i<n*n; i++) cnt[s[i]]++;
var Ok = 1;
var ans = Array(n).fill([]);
for (var i=0; i<n; i++) {
	var t = Array(n).fill(0);
	ans[i] = t;
}
if (n%2 === 1) {
	var cnt_one = 0, cnt_two = 0, rt = 0;
	for (var i=1; i<=1000; i++)
		if (cnt[i] % 2 === 1) {
			cnt_one++;
			rt = i;
		}
	if (cnt_one != 1)
		Ok = 0;

	if (Ok) {
		cnt[rt]--;
		for (var i=1; i<=1000; i++)
			if (cnt[i] % 4 === 2)
				cnt_two++;
		if (cnt_two > n-1)
			Ok = 0;

		if (Ok) {
			write("YES\n");
			var q = [];
			for (var i=1; i<=1000; i++) {
				for (var j=0; j<Math.floor(cnt[i]/4); j++)
					q.push(i);
				cnt[i] %= 4;
			}
			var q_cnt = 0;
			for (var i=0; i<Math.floor(n/2); i++)
				for (var j=0; j<Math.floor(n/2); j++) {
					ans[i][j] = q[q.length-1];
					q.pop();
				}
			for (var i=0; i<Math.floor(n/2); i++)
				for (var j=0; j<Math.floor(n/2); j++)
					ans[i][n-1-j] = ans[i][j];
			for (var i=0; i<Math.floor(n/2); i++)
				for (var j=0; j<n; j++)
					ans[n-1-i][j] = ans[i][j];
			var mid = Math.floor(n/2);

			ans[mid][mid] = rt;

			var fr = 0;
			if (q.length > 0) {
				while (q.length > 0) {
					if (q.length <= 0) break;
					var X = q[q.length-1];
					q.pop();
					ans[fr][mid] = ans[mid][fr] = ans[mid][n-1-fr] = ans[n-1-fr][mid] = X;
					fr++;
				}
			}

			var fr_row = fr, fr_col = fr;
			for (var i=1; i<=1000; i++)
				if (cnt[i] == 2) {
					if (fr_row < mid) {
						ans[fr_row][mid] = ans[n-1-fr_row][mid] = i;
						cnt[i] = 0;
						fr_row++;
					}
					else {
						ans[mid][fr_col] = ans[mid][n-1-fr_col] = i;
						cnt[i] = 0;
						fr_col++;
					}
				}

			for (var i=0; i<n; i++) {
				var qq = [];
				for (var j=0; j<n; j++)
					qq.push(ans[i][j]);
				write(qq.join(" ") + "\n");
			}
		}
		else write("NO\n");
	}
	else write("NO\n");
}
else {
	for (var i=1; i<=1000; i++)
		if (cnt[i] % 4 !== 0) {
			Ok = 0;
			break;
		}
	if (Ok) {
		write("YES\n");
		var q = [];
		for (var i=1; i<=1000; i++)
			for (var j=0; j<Math.floor(cnt[i]/4); j++)
				q.push(i);
		var q_cnt = 0;
		for (var i=0; i<Math.floor(n/2); i++)
			for (var j=0; j<Math.floor(n/2); j++)
				ans[i][j] = q[q_cnt++];
		for (var i=0; i<Math.floor(n/2); i++)
			for (var j=0; j<Math.floor(n/2); j++)
				ans[i][n-1-j] = ans[i][j];
		for (var i=0; i<Math.floor(n/2); i++)
			for (var j=0; j<n; j++)
				ans[n-1-i][j] = ans[i][j];
		for (var i=0; i<n; i++) {
			var qq = [];
			for (var j=0; j<n; j++)
				qq.push(ans[i][j]);
			write(qq.join(" ") + "\n");
		}
	}
	else write("NO\n");
}

var n = readline().split(" ").map(function(x) { return parseInt(x); })[0];
var s = readline().split(" ").map(function(x) { return parseInt(x); });
var cnt = Array(1001).fill(0);
for (var i=0; i<n*n; i++) cnt[s[i]]++;
var Ok = 1;
var ans = Array(n).fill([]);
for (var i=0; i<n; i++) {
	var t = Array(n).fill(0);
	ans[i] = t;
}
if (n%2 === 1) {
	var cnt_one = 0, cnt_two = 0, rt = 0;
	for (var i=1; i<=1000; i++)
		if (cnt[i] % 2 === 1) {
			cnt_one++;
			rt = i;
		}
	if (cnt_one != 1)
		Ok = 0;

	if (Ok) {
		cnt[rt]--;
		for (var i=1; i<=1000; i++)
			if (cnt[i] % 4 === 2)
				cnt_two++;
		if (cnt_two > n-1)
			Ok = 0;

		if (Ok) {
			write("YES\n");
			var q = [];
			for (var i=1; i<=1000; i++) {
				for (var j=0; j<Math.floor(cnt[i]/4); j++)
					q.push(i);
				cnt[i] %= 4;
			}
			var q_cnt = 0;
			for (var i=0; i<Math.floor(n/2); i++)
				for (var j=0; j<Math.floor(n/2); j++) {
					ans[i][j] = q[q.length-1];
					q.pop();
				}
			for (var i=0; i<Math.floor(n/2); i++)
				for (var j=0; j<Math.floor(n/2); j++)
					ans[i][n-1-j] = ans[i][j];
			for (var i=0; i<Math.floor(n/2); i++)
				for (var j=0; j<n; j++)
					ans[n-1-i][j] = ans[i][j];
			var mid = Math.floor(n/2);

			ans[mid][mid] = rt;

			var fr = 0;
			if (q.length > 0) {
				while (q.length > 0) {
					if (q.length <= 0) break;
					var X = q[q.length-1];
					q.pop();
					ans[fr][mid] = ans[mid][fr] = ans[mid][n-1-fr] = ans[n-1-fr][mid] = X;
				}
			}

			var fr_row = fr, fr_col = fr;
			for (var i=1; i<=1000; i++)
				if (cnt[i] == 2) {
					if (fr_row < mid) {
						ans[fr_row][mid] = ans[n-1-fr_row][mid] = i;
						cnt[i] = 0;
						fr_row++;
					}
					else {
						ans[mid][fr_col] = ans[mid][n-1-fr_col] = i;
						cnt[i] = 0;
						fr_col++;
					}
				}

			for (var i=0; i<n; i++) {
				var qq = [];
				for (var j=0; j<n; j++)
					qq.push(ans[i][j]);
				write(qq.join(" ") + "\n");
			}
		}
		else write("NO\n");
	}
	else write("NO\n");
}
else {
	for (var i=1; i<=1000; i++)
		if (cnt[i] % 4 !== 0) {
			Ok = 0;
			break;
		}
	if (Ok) {
		write("YES\n");
		var q = [];
		for (var i=1; i<=1000; i++)
			for (var j=0; j<Math.floor(cnt[i]/4); j++)
				q.push(i);
		var q_cnt = 0;
		for (var i=0; i<Math.floor(n/2); i++)
			for (var j=0; j<Math.floor(n/2); j++)
				ans[i][j] = q[q_cnt++];
		for (var i=0; i<Math.floor(n/2); i++)
			for (var j=0; j<Math.floor(n/2); j++)
				ans[i][n-1-j] = ans[i][j];
		for (var i=0; i<Math.floor(n/2); i++)
			for (var j=0; j<n; j++)
				ans[n-1-i][j] = ans[i][j];
		for (var i=0; i<n; i++) {
			var qq = [];
			for (var j=0; j<n; j++)
				qq.push(ans[i][j]);
			write(qq.join(" ") + "\n");
		}
	}
	else write("NO\n");
}