Lunar New Year is approaching, and you bought a matrix with lots of "crosses".This matrix $$$M$$$ of size $$$n \times n$$$ contains only 'X' and '.' (without quotes). The element in the $$$i$$$-th row and the $$$j$$$-th column $$$(i, j)$$$ is defined as $$$M(i, j)$$$, where $$$1 \leq i, j \leq n$$$. We define a cross appearing in the $$$i$$$-th row and the $$$j$$$-th column ($$$1 < i, j < n$$$) if and only if $$$M(i, j) = M(i - 1, j - 1) = M(i - 1, j + 1) = M(i + 1, j - 1) = M(i + 1, j + 1) = $$$ 'X'.The following figure illustrates a cross appearing at position $$$(2, 2)$$$ in a $$$3 \times 3$$$ matrix. X.X.X.X.X Your task is to find out the number of crosses in the given matrix $$$M$$$. Two crosses are different if and only if they appear in different rows or columns.

The first line contains only one positive integer $$$n$$$ ($$$1 \leq n \leq 500$$$), denoting the size of the matrix $$$M$$$. The following $$$n$$$ lines illustrate the matrix $$$M$$$. Each line contains exactly $$$n$$$ characters, each of them is 'X' or '.'. The $$$j$$$-th element in the $$$i$$$-th line represents $$$M(i, j)$$$, where $$$1 \leq i, j \leq n$$$.

Output a single line containing only one integer number $$$k$$$ — the number of crosses in the given matrix $$$M$$$.

NoteIn the first sample, a cross appears at $$$(3, 3)$$$, so the answer is $$$1$$$.In the second sample, no crosses appear since $$$n < 3$$$, so the answer is $$$0$$$.In the third sample, crosses appear at $$$(3, 2)$$$, $$$(3, 4)$$$, $$$(4, 3)$$$, $$$(4, 5)$$$, so the answer is $$$4$$$.

//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↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : 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 list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = next();
  }
  var output = 0;
  if(N <= 2){
    myout(output);
    return;
  }
  for(var i = 0; i < N - 2; i++){
    for(var j = 0; j < N - 2; j++){
      if(list[i][j] == "X"){
        if(list[i][j + 2] == "X" &&
          list[i + 2][j] == "X" &&
          list[i + 1][j + 1] == "X" &&
          list[i + 2][j + 2] == "X"){
          output++;
        }
      }
    }
  }
  myout(output);
}

"use strict";
// NYAN NYAN
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░
// ░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░
// ░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░
// ░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░
// ░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░
// ░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░
// ░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░
// ░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░
// ░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░
// ░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░
// ░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░
// ░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// 백준의 노드 버전이 너무 낮아 babel 사용.
// 풀이는 solve() 함수에 있음.
const CODEFORCES_NODE = "cf";
const CODEFORCES_V8 = "cf-v8";
const BEAKJOON = "bj";
const TEST = "test";
const PROGRAMMERS = "ps";
var SITE = CODEFORCES_NODE;
// var SITE = CODEFORCES_NODE;
// var SITE = PROGRAMMERS;
var DEBUG = false;
if (SITE == BEAKJOON) {
    if (!String.prototype.startsWith) {
        String.prototype.startsWith = function (search, pos) {
            return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
        };
    }
    if (!String.prototype.endsWith) {
        String.prototype.endsWith = function (search, this_len) {
            if (this_len === undefined || this_len > this.length) {
                this_len = this.length;
            }
            return this.substring(this_len - search.length, this_len) === search;
        };
    }
    if (!String.prototype.repeat) {
        String.prototype.repeat = function (count) {
            'use strict';
            if (this == null) {
                throw new TypeError('can\'t convert ' + this + ' to object');
            }
            var str = '' + this;
            count = +count;
            if (count != count) {
                count = 0;
            }
            if (count < 0) {
                throw new RangeError('repeat count must be non-negative');
            }
            if (count == Infinity) {
                throw new RangeError('repeat count must be less than infinity');
            }
            count = Math.floor(count);
            if (str.length == 0 || count == 0) {
                return '';
            }
            // Ensuring count is a 31-bit integer allows us to heavily optimize the
            // main part. But anyway, most current (August 2014) browsers can't handle
            // strings 1 << 28 chars or longer, so:
            if (str.length * count >= 1 << 28) {
                throw new RangeError('repeat count must not overflow maximum string size');
            }
            var maxCount = str.length * count;
            count = Math.floor(Math.log(count) / Math.log(2));
            while (count) {
                str += str;
                count--;
            }
            str += str.substring(0, maxCount - str.length);
            return str;
        };
    }
}
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ HELPER ALGORITHMS/POLYFILLS ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
function getCombinations2(n) {
    let ret = [];
    for (let start = 0; start < n; start++) {
        for (let k = start + 1; k < n; k++) {
            let s = new Set();
            s.add(start);
            s.add(k);
            ret.push(s);
        }
    }
    return ret;
}

function getSubbits(n) {
    let ret = [];
    for (var subset = n; subset; subset = (subset - 1) & n) {
        ret.push(subset);
    }
    return ret;
}
String.prototype.replaceAt = function (index, replacement) {
    return this.substr(0, index) + replacement + this.substr(index + replacement.length);
};
Function.prototype.repeat = function (times, callback = undefined) {
    for (let i = 0; i < times; i++) {
        this();
    }
    return callback ? callback() : null;
};
Array.prototype.getMaxConsecutiveSum = function (defaultValue = -Infinity) {
    const N = this.length;
    let maxsum = defaultValue;
    let cursum = defaultValue;
    let cur;
    for (var ii = 0; ii < N; ii++) {
        cur = this[ii];
        if (cursum + cur > 0) {
            if (cur > cursum + cur) {
                cursum = cur;
            } else
                cursum += cur;
        } else {
            cursum = cur;
            if (maxsum < cursum) {
                maxsum = cursum;
            }
        }
        if (maxsum < cursum) {
            maxsum = cursum;
        }
    }
    this.maxConsecutiveSum = maxsum;
    return maxsum;
};
try {
    require('manakin').global;
    // require ("babel-polyfill");
} catch (error) {}
try {
    process.argv.forEach(function (val, index, array) {
        if (val.startsWith("site")) {
            switch (val.split("=")[1]) {
                case "test":
                    // console.log('change site to test')
                    SITE = TEST;
                    break;
                case "cf-node":
                    // console.log('change site to cf')
                    SITE = CODEFORCES_NODE;
                    break;
                case "cf":
                    // console.log('change site to cf')
                    SITE = CODEFORCES_NODE;
                    break;
                case "cf-v8":
                    // console.log('change site to cf')
                    SITE = CODEFORCES_V8;
                    break;
                case "bj":
                    // console.log('change site to bj')
                    SITE = BEAKJOON;
                    break;
            }
        }
        if (val.startsWith("debug")) {
            switch (val.split("=")[1]) {
                case "true":
                    DEBUG = true;
                    break;
                case "false":
                    DEBUG = false;
                    break;
            }
        }
    });
} catch (error) {}
let inputFilePath = '';
switch (SITE) {
    case TEST:
        const config = require('config');
        var fs = require("fs");
        var path = require('path');
        inputFilePath = config.get('INPUTFILEPATH') || path.resolve(__dirname, "input.txt");
        break;
    default:
        inputFilePath = './input.txt';
        break;
}
const INPUTFILEPATH = inputFilePath;
// if (!String.prototype.endsWith) {
// 	String.prototype.endsWith = function(search, this_len) {
// 		if (this_len === undefined || this_len > this.length) {
// 			this_len = this.length;
// 		}
// 		return this.substring(this_len - search.length, this_len) === search;
// 	};
// }
// if (!Array.prototype.includes) {
//   Array.prototype.includes = function (target) {
//     return this.indexOf(target) !== -1
//   }
// }
if (!Array.prototype.sortNumber) {
    /**
     * @memberof Array
     * @summary sorts array by number
     */
    Array.prototype.sortNumber = function (order = 'asc') {
        return this.sort((a, b) => ((order == 'asc') ? 1 : -1) * (+a - +b));
    };
}
const newLine = '\n';
var ans;
var inputText = "";
var lineCount = 0;
var lines;
var input;
/**
 * @type {(trim?=true)=>string}
 */
var readline;
var getlines;
var lineOpen = false;
var readingLine = '';
var clockStart;
var clock;
/**
 * @type {typeof import('glob')}
 */
var glob;
var customFilesPattern = 'inputs/**/*.in';
var customFiles = [];
var print;
print = console.log;
var it;
var step;

function EnableLogging() {
    it = console.info;
    step = console.success;
}

function DisableLogging() {
    it = function it(params) {
        return 0;
    };
    step = it;
}

function RunCustomTests() {
    // glob = require('glob');
    // it(process.cwd());
    // it(process.cwd() + customFilesPattern);
    // glob(customFilesPattern, (er,files)=>{
    //   console.log('files count: ' + files.length);
    //   files.forEach(file=>{
    //     console.log(`custom test case files : ${file}`);
    //     customFiles.push(file);
    //   })
    // });
    // var path2 = process.cwd().replace(/\\/g, "/");
    // path = require('path');
    // glob("*.js", (er,files)=>{
    //   console.log('files count: ' + files.length);
    //   files.forEach(file=>{
    //     console.log(`custom test case files : ${file}`);
    //   })
    // });
    // customFiles.forEach(file=>{
    //   const filePath = process.cwd() + file;
    //   console.info(filePath);
    // })
}
if (DEBUG) {
    EnableLogging();
    clock = function (start) {
        if (!start)
            return process.hrtime();
        var end = process.hrtime(start);
        return Math.round((end[0] * 1000) + (end[1] / 1000000));
    };
} else {
    DisableLogging();
}
// prepares test data. to replace line input, assign arrays to lines variable.
function prepareTestData() {
    // it(lines);
    // lines = ['custom line 1', 'custom line 2'];
}
// executes exactly once for both test and run. execution time will be included to elapsed time.
const prepareSolve = () => {};

function power(x, y) {
    let ret = 1;
    while (y > 0) {
        if (y % 2) {
            ret *= x;
            ret %= P;
        }
        x *= x;
        x %= P;
        y /= 2;
    }
    return ret;
}

function createArray(lengths) {
    var arr = new Array(lengths || 0),
        i = lengths;
    if (arguments.length > 1) {
        var args = Array.prototype.slice.call(arguments, 1);
        while (i--)
            arr[lengths - 1 - i] = createArray.apply(this, args);
    }
    return arr;
}

function numericSortList(list) {
    list.sort((a, b) => a - b);
}

function getRectangleIntersection(r1, r2) {
    if (r1.x > r2.x + r2.w)
        return null;
    if (r1.x + r1.w < r2.x)
        return null;
    if (r1.y > r2.y + r2.h)
        return null;
    if (r1.y + r1.h < r2.y)
        return null;
    var rect = {};
    rect.x = Math.max(r1.x, r2.x);
    rect.y = Math.max(r1.y, r2.y);
    rect.w = Math.min(r1.x + r1.w, r2.x + r2.w) - rect.x;
    rect.h = Math.min(r1.y + r1.h, r2.y + r2.h) - rect.y;
    return rect;
}

function getRandomNumber(to, from) {
    if (from == undefined) {
        return Math.floor(Math.random() * to + 1);
    }
    return Math.floor(Math.random() * (to - from) + from);
}
/**
 * a queue that will be stop working someday.
 */
class TerminallyIllQueue {
    constructor() {
        this.data = {};
        this.head = 0;
        this.tail = 1;
    }
    length() {
        return this.tail - this.head - 1;
    }
    enqueue(v) {
        this.data[this.tail - 1] = v;
        this.tail++;
    }
    dequeue() {
        const v = this.data[this.head];
        this.head++;
        return v;
    }
}
/**
 * @template T
 * @type {TwoDimensionalMap<T>}
 */
class TwoDimensionalMap {
    constructor() {
        this.data = {};
    }
    /**
     * @memberof TwoDimensionalMap<T>
     * @public
     * @param {number} x
     * @param {number} y
     * @returns {T}
     */
    getPosition(x, y) {
        return this.data[`${x}.${y}`];
    }
    /**
     * @memberof TwoDimensionalMap<T>
     * @public
     * @param {number} x
     * @param {number} y
     * @param {T} value
     */
    setPosition(x, y, value) {
        this.data[`${x}.${y}`] = value;
    }
}
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ MAIN SOLVE FUNCTION ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
function solve() {
    const n = ri();
    var maps = new TwoDimensionalMap();
    for (var j = 0; j < n; j++) {
        const li = rs();
        // it(li);
        for (var i = 0; i < n; i++) {
            maps.setPosition(i, j, li[i]);
        }
    }

    var ans = 0;
    for (var y = 0; y < n; y++) {
        for (var x = 0; x < n; x++) {
            it(maps.getPosition(x,y));
            if (maps.getPosition(x, y) != 'X') continue;
            if (maps.getPosition(x - 1, y - 1) == 'X' &&
                maps.getPosition(x - 1, y + 1) == 'X' &&
                maps.getPosition(x + 1, y - 1) == 'X' &&
                maps.getPosition(x + 1, y + 1) == 'X') {
                ans++;
            }
        }
    }
    print(ans);
}
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
function resetRead() {
    lineCount = 0;
}

function checkMemoryUsage() {
    it(process.memoryUsage());
}

function readOne(separator = ' ') {
    if (lineOpen && readingLine != null) {
        // if(lineOpen){
        // it(readingLine);
        let splitPos = readingLine.search(separator);
        let ret = readingLine.slice(0, splitPos);
        if (splitPos == -1) {
            // it('close');
            ret = readingLine;
            readingLine = '';
            lineOpen = false;
        }
        readingLine = readingLine.substr(splitPos + 1);
        // it(ret, readingLine, splitPos);
        if (ret == '' || ret == separator) {
            return readOne(separator);
        } else {
            return ret;
        }
    } else {
        readingLine = readline();
        lineOpen = true;
        if (readingLine == null)
            return '';
        return readOne(separator);
    }
}

function ri() {
    return +readOne();
}

function ria() {
    return readInts();
}
/**
 * @return {string}
 */
function rs() {
    return readOne();
}
/**
 * @return {string[]}
 */
function rsa() {
    return readline().split(' ');
}
/**
 * @returns {number[]}
 */
function readInts() {
    try {
        lineOpen = false;
        return readline()
            .split(" ")
            .map(x => parseInt(x));
    } catch (error) {
        console.error(error);
        return null;
    }
}
let inputListener;
let readlines;
switch (SITE) {
    case TEST:
        var fs = require("fs");
        var path = require('path');
        // input = fs.createReadStream(path.resolve(__dirname, "input.txt"), {
        //   encoding: "utf8"
        // });
        input = fs.createReadStream(INPUTFILEPATH, {
            encoding: "utf8"
        });
        inputListener = (line) => {
            console.log(line);
            if (line.startsWith('end')) {
                console.log('end');
                closing();
            }
            if (!line) {
                closing();
            }
            lineCount++;
            inputText += line + "\r\n";
        };
        readlines = () => {
            const readline = require("readline");
            const rl = readline.createInterface({
                input,
                output: process.stdout,
                terminal: false
            });
            rl.on("line", inputListener);
            rl.on('close', closing);
        };
        getlines = function* (inputText) {
            var lines = inputText.split(/\r?\n/);
            for (let line of lines) {
                yield line + newLine;
            }
        };
        readline = function (trim = true) {
            const lineval = lines.next().value;
            return trim ? lineval.trim() : lineval;
        };
        readlines();
        break;
    case CODEFORCES_NODE:
        input = process.stdin;
        inputListener = (line) => {
            if (!line) {
                closing();
            }
            lineCount++;
            inputText += line + "\r\n";
        };
        readlines = () => {
            const readline = require("readline");
            const rl = readline.createInterface({
                input,
                output: process.stdout,
                terminal: false
            });
            rl.on("line", inputListener);
            rl.on('close', closing);
        };
        getlines = function* (inputText) {
            var lines = inputText.split(/\r?\n/);
            for (let line of lines) {
                yield line + newLine;
            }
        };
        readline = function (trim = true) {
            const lineval = lines.next().value;
            return trim ? lineval.trim() : lineval;
        };
        readlines();
        break;
    case BEAKJOON:
        var fs = require('fs');
        if (DEBUG) {
            // input = fs.readFileSync('./input.txt').toString();
            inputText = fs.readFileSync(INPUTFILEPATH).toString();
        } else {
            inputText = fs.readFileSync('/dev/stdin').toString();
        }
        readline = function (trim = true) {
            lineCount++;
            let line = lines[lineCount - 1];
            if (line)
                return trim ? lines[lineCount - 1].trim() : lines[lineCount - 1];
            else
                return null;
        };
        getlines = function (inputText) {
            lineCount = 0;
            return inputText.split(/\r?\n/);
        };
        // lines = getlines(input);
        closing();
        break;
    case PROGRAMMERS:
        //자체 함수를 실행할 것이므로 아무것도 하지 않는다.
    default:
        break;
}

function closing() {
    if (DEBUG) {
        DisableLogging();
        const prepareClock = clock();
        lines = getlines(inputText);
        prepareSolve();
        const prepareClockElapsedTime = clock(prepareClock);
        EnableLogging();
        prepareTestData();
        solve();
        console.warn('done. running custom tests');
        RunCustomTests();
        resetRead();
        console.warn('performance check');
        DisableLogging();
        clockStart = clock();
        // lines = getlines(inputText);
        solve();
        console.warn(`${clock(clockStart) + prepareClockElapsedTime} ms`);
        EnableLogging();
        process.exit();
    } else {
        lines = getlines(inputText);
        prepareSolve();
        solve();
        process.exit();
    }
}

"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  const N = Number(inputs[0]);
  const M = [];
  for (let i=0;i<N;i++){
    M[i] = inputs[i+1].split("");
  }

  let count = 0;
  for (let i = 1; i<N-1;i++) {
    for (let j = 1; j<N-1;j++) {
      if (M[i][j] === "X" && M[i-1][j-1] === "X" && M[i-1][j+1] === "X" && M[i+1][j-1] === "X" && M[i+1][j+1] === "X") {
        count++;
      }
    }
  }

  console.log(count);
}

let input = ''
process.stdin.on('data', c => input += c)
process.stdin.on('end', () => {
  main(input)
})

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
const matrix = [];

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

  const col = [...str];
  matrix.push(col);

  c++;
});

rl.on('close', () => {
  let ans = 0;

  for (let i = 1; i < matrix.length - 1; i++) {
    for (let j = 1; j < matrix.length - 1; j++) {
      if (matrix[i][j] === 'X' && matrix[i - 1][j - 1] === 'X' && matrix[i - 1][j + 1] === 'X' && matrix[i + 1][j - 1] === 'X' && matrix[i + 1][j + 1] === 'X') {
        ans++;
      }
    }
  }

  console.log(ans);
});

(function() {

    var read = {
        number: function() {
            return +readline();
        },
        arr: function() {
            return readline(' ').split('');
        },
        arrNumber: function() {
            return +readline(' ')
                .split(' ')
                .map(item => +item);
        }
    }

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

    var count = 0;

    for(var i = 1; i < n - 1; i++) {
        for(var j = 1; j < n - 1; j++) {
            if(arr[i][j] == 'X' && arr[i - 1][j - 1] == 'X' && arr[i + 1][j + 1] == 'X' && arr[i - 1][j + 1] == 'X' && arr[i + 1][j - 1] == 'X') {
                count++;
            }
        }
    }

    print(count);
}());


Немногие знают, что сотрудники ВКонтакте могут менять цвет подсветки в куполе знаменитого Дома Зингера, где расположена штаб-квартира ВКонтакте. Для этого нужно всего лишь отправить сообщение с цветом в специальный чат «Зингер | color», а бот его распознает и сменит подсветку. При этом на время городских мероприятий смена цвета блокируется.Формально, бот обрабатывает три типа сообщений:   lock: заблокировать изменение цвета. Если оно и так заблокировано на данный момент, сообщение игнорируется.  unlock: разблокировать изменение цвета. Если оно и так разблокировано на данный момент, сообщение игнорируется.  red / orange / yellow / green / blue / indigo / violet: изменить цвет купола на заданный, если изменение цвета на данный момент не заблокировано. Вам дана история сообщений, полученных ботом, в хронологическом порядке. Считайте, что перед получением первого сообщения купол подсвечивается голубым (blue), а изменение цвета не заблокировано.Определите, какой цвет будет у купола Дома Зингера после обработки этих сообщений.

В первой строке задано одно целое число $$$n$$$ ($$$1 \le n \le 100$$$) — число сообщений, полученных ботом. В следующих $$$n$$$ строках заданы сообщения, полученные ботом, в хронологическом порядке, по одному сообщению в строке. Каждое сообщение — строка из следующего набора: lock, unlock, red, orange, yellow, green, blue, indigo, violet.

Выведите цвет купола после обработки сообщений ботом.

7
red
violet
unlock
red
orange
lock
indigo

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

const rl = readline.createInterface({ input, output });

const COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];

let isLocked = false;
let currentColor = "blue";

rl.on('line', function foo(input) {
  if (input === "lock") {
    isLocked = true;
    return;
  }
  if (input === "unlock") {
    isLocked = false;
    return;
  }
  if (isLocked) {
    return;
  }
  if (COLORS.includes(input)) {
    currentColor = input;
  }
});

rl.on('close', function boo(input) {
  console.log(currentColor);
});

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

const rl = readline.createInterface({ input, output });

let isLocked = false;
let currentColor = "blue";

const COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];

rl.on('line', function foo(input) {
  if (input === "lock") {
    isLocked = true;
    return;
  }
  if (input === "unlock") {
    isLocked = false;
    return;
  }
  if (isLocked) {
    return;
  }
  if (COLORS.includes(input)) {
    currentColor = input;
  }
});

rl.on('close', function boo(input) {
  console.log(currentColor);
});

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

let currentState = 'unlock'
let currentColor = 'blue'
let i = 0

rl
    .on('line', value => {
        if (i === 0) {
            i++
            return
        }
        if (value === 'lock' || value === 'unlock') {
            currentState = value
            return;
        }
        if (currentState !== 'lock') {
            currentColor = value
        }
    })
    .on('close', () => {
        process.stdout.write(currentColor)
    })

var readline = require('readline');
var fs = require('fs');
var rl = readline.createInterface({
    // input: fs.createReadStream('./A.txt'),
    input: process.stdin,
    output: process.stdout,
    terminal: false
});

// function A (content) {
//     let currentState = 'unlock'
//     let currentColor = 'blue'
//     for (let i = 0; i < content.length; i++) {
//         let value = content[i]
//         if (i === 0) {
//             continue
//         }
//         if (content[i] === 'lock' || content[i] === 'unlock') {
//             currentState = value
//             continue
//         }
//         if (currentState !== 'lock') {
//             currentColor = value
//         }
//     }
//     return currentColor
// }

let currentState = 'unlock'
let currentColor = 'blue'
let i = 0

rl
    .on('line', value => {
        if (i === 0) {
            i++
            return
        }
        if (value === 'lock' || value === 'unlock') {
            currentState = value
            return;
        }
        if (currentState !== 'lock') {
            currentColor = value
        }
        i++
    })
    .on('close', () => {
        process.stdout.write(currentColor)
    })

// module.exports = A

const readline = require('readline');
const fs = require('fs');

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

let count = 0;
let quantity = 0;
let flag = false;
let output = 'blue';

readInterface.on('line', function(line) {
    if (count === 0) {
        quantity = line;
    } else {
        switch (line) {
            case 'lock':
                flag = true
                break;
            case 'unlock':
                flag = false
                break;
            case 'red':
            case 'orange':
            case 'yellow':
            case 'green':
            case 'blue':
            case 'indigo':
            case 'violet':
                output = !flag ? line : output;
                break;
        }
    }

    if (count == quantity) {
        console.log(output);
    }

    count++;

});

let inputString = '';

process.stdin.on('data', chunk => inputString += chunk);
process.stdin.on('end', () => {
    const lines = inputString
        .split('\n')
        .map(line => line.trim())
        .filter(line => line.length > 0);

    const count = +lines[0];
    const messages = lines.slice(1, count + 1);

    const LOCK = 'lock';
    const UNLOCK = 'unlock';
    const ALLOW_COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];

    let isLock = false;
    let currentColor = 'blue';

    messages.forEach((message) => {
        if (message === UNLOCK) {
            isLock = false;
        }

        if (message === LOCK) {
            isLock = true;
        }

        if (ALLOW_COLORS.includes(message) && !isLock) {
            currentColor = message;
        }
    });

    console.log(currentColor);
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    let lines = i.split(EOL)
    let color = 'blue';
    let status = 'unlock'
    lines = lines.slice(1, lines.length - 1);
        lines.forEach(item => {
        switch (item) {
            case 'unlock':
                status = 'unlock';
                break;
            case 'lock':
                status = 'lock';
                break;
            default:
                if (status === 'lock') {
                    break;
                } else if (status === 'unlock') {
                    color = item;
                }
        }
    });
    console.log(color);
});

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const N = parseInt(lines[0]);
  let res = 'blue';
  let isUnlock = true;

  const color = {
    blue: 'blue',
    red: 'red',
    orange: 'orange',
    yellow: 'yellow',
    green: 'green',
    indigo: 'indigo',
    violet: 'violet',
  };

  for (let i = 1; i < lines.length; i++) {
    if (lines[i] === 'lock') {
      isUnlock = false;
    } else if (lines[i] === 'unlock') {
      isUnlock = true;
    }
    if (isUnlock) {
      if (color[lines[i]] != undefined) {
        res = lines[i];
      }
    }
  }

  console.log(res);
});

const nextString = (function() {
  const listeners = [], strings = [], ps = process.stdin
  let last = ''
  ps.setEncoding('utf8')
  ps.on('readable', () => {
    let chunk
    while ((chunk = ps.read()) !== null) {
      chunk = (last + chunk).split(/\r\n|\r|\n/)
      last = chunk[chunk.length - 1]
      for (let i = 0; i < chunk.length - 1; ++i) {
        if (chunk[i].length > 0) {
          if (listeners.length > 0) {
            listeners.shift(1)(chunk[i])
          }
          else {
            strings.push(chunk[i])
          }
        }
      }
    }
  })
  const fn = resolve => {
    if (strings.length > 0) {
      resolve(strings.shift(1))
    }
    else {
      listeners.push(resolve)
    }
  }
  return () => new Promise(fn)
})()

async function main() {
  let n = +await nextString()
  let ans = 'blue'
  let lock = 'lock'
  let unlock = 'unlock'
  let locked = false
  for (let i = 0; i < n; ++i) {
    let next = await nextString()
    if (next === lock) {
      locked = true
    }
    else if (next === unlock) {
      locked = false
    }
    else if (!locked) {
      ans = next
    }
  }
  console.log(ans)
}

main()

function solveProblem(problem) {
    // console.log('Problem: ', problem);
    let arr = problem.values;
    let color = 'blue';
    let locked = false;
    for (let i = 0; i < arr.length; i++) {
        // console.log(arr[i]);
        let val = arr[i];

        switch (val) {
            case 'lock':
              locked = true;
              break;
            case 'unlock':
                locked = false;
                break;
            case 'red':
            case 'orange':
            case 'yellow':
            case 'green':
            case 'blue':
            case 'indigo':
            case 'violet':
                if (!locked) {
                    color = val;
                }
              break;
            default:
              //
          }
    }
    console.log(color);
}

function readInput() {
    const readline = require('readline')
    const rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout,
      terminal: false
    })

    let problem = {
      N: 0,
      values: []
    }

    rl.on('line', function (line) {
      // TODO: Process input
      if (problem.N === 0) {
        // Get number of test cases from first line
        problem.N = Number(line)
      } else {
        // TODO process the rest of the data
        // const arr = line.split(' ');
        if (line.length > 0) {
            problem.values.push(line);
        }
      }
    })

    .on('close', () => {
      // Finished processing input, now solve question
      solveProblem(problem)
      process.exit()
    })
  }

readInput()

const readline = require('readline');

let color = null;
let state = 'unlock';
let length = 0;
let msgCounter = 0;
let lastColor = 'blue';
const commandList = [];

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

function checkHistory() {
  commandList.forEach((item, index) => {
    switch (item) {
      case 'lock':
      case 'unlock':
        color = lastColor;
        state = item;
        break;
      default:
        if (state === 'unlock') {
          color = item;
          lastColor = color;
        }
    }
  });
}

rl.on('line', input => {
  if (length === 0) length = +(input);
  else commandList.push(input);

  if (length === msgCounter) {
    checkHistory();
    console.log(color);
    rl.close();
  } else msgCounter++;
});

const fs = require('fs');
const readline = require('readline');
const path = require('path')

class CommandsCounter {
    count = undefined

    isInited() {
        return typeof this.count !== 'undefined';
    }

    setInitialCount(count) {
        if (this.isInited()) {
            throw new Error('Commands counter is already inited');
        }

        this.count = count;
    }

    isCommandsLeft() {
        return this.count > 0;
    }

    decreaseCounter() {
        this.count--;
    }
}

class ZingerLight {
    color = 'blue';
    commandsCounter = 0
    isLocked = false;

    commandsCounter

    constructor(commandsCounter) {
        this.commandsCounter = commandsCounter;
    }

    get currentColor() {
        return this.color;
    }

    exec(command) {
        switch(command) {
            case 'lock':
                return this.lock();
            case 'unlock':
                return this.unlock();
            case 'red':
            case 'orange':
            case 'yellow':
            case 'green':
            case 'blue':
            case 'indigo':
            case 'violet':
                return this.setColor(command);
            default:
                console.log(`Command "${command}" is not recognized`);
        }
    }

    lock() {
        this.isLocked = true;
    }

    unlock() {
        this.isLocked = false;
    }

    setColor(color) {
        if (!this.isLocked) {
            this.color = color;
        }
    }
}

// MAIN

function main() {
    const zingerLight = new ZingerLight();
    const commandsCounter = new CommandsCounter();
    // const readStream = fs.createReadStream(path.resolve(__dirname, './input_1'));
    const readStream = process.stdin;

    const lineCallback = (line) => processLine(zingerLight, commandsCounter, line);
    const closeCallback = () => sendAnswer(zingerLight.currentColor);

    initInputRead(readStream, lineCallback, closeCallback);
}

main();

// ---

function initInputRead(inputInterface, lineCb, closeCb) {
    const readInterface = readline.createInterface({
        input: inputInterface,
    });

    readInterface.on('line', line => lineCb(line));
    readInterface.on('close', () => closeCb());
}

function processLine(zingerLight, commandsCounter, line) {
    // first line: init counter
    if (!commandsCounter.isInited()) {
        commandsCounter.setInitialCount(Number(line));
        return;
    }

    // exec commands while counter of commands is more than inited in first line
    if (commandsCounter.isCommandsLeft()) {
        zingerLight.exec(line);
        commandsCounter.decreaseCounter();
        return;
    }
}

function sendAnswer(answer) {
    process.stdout.write(answer);
    process.stdout.write('\n');
}

const fs = require('fs');
const print = console.log;

let input = fs.readFileSync(0).toString();
input = input.split(/\r?\n/g);

const COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];

let n = +input[0];
let state = 'unlock';
let color = 'blue';

for (let i = 1; i <= n; i++) {
  let cmd = input[i];

  switch (cmd) {
    case 'lock':
    case 'unlock':
      state = cmd;
      break;
    default:
      if (state == 'unlock') {
        color = cmd;
      }
  }
}

print(color);

var readline = require('readline');

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

var count_of_commands
var commands = []
function start() {
    rl.question("", function(answer) {
      count_of_commands = parseInt(answer)
      get_com()
    });
}

function get_command() {
    rl.question("", function(answer) {
        commands.push(answer)
        count_of_commands--
        get_com()
    });

}

function get_com() {
    if (count_of_commands > 0) {
        get_command()
    } else {
        get_color()
    }
}

function get_color() {
    var locked = false
    var color = "blue"
    commands.forEach((com, cim_index) => {
        if (com == "lock") {
            locked = true
        } else if (com == "unlock") {
            locked = false
        } else {
            if (locked == false) {
                color = com
            }
        }
    })
    console.log(color)
}

start();

const readline = require('readline');

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

const defaultColor = 'blue';
const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];

let locked = false;
let currentColor = 'blue';
let argumentsFlow = [];

rl.on('line', function(line){
    argumentsFlow.push(line);
});

rl.on('close', function() {
    for (let i = 0; i < argumentsFlow.length; i++) {
        if (colors.includes(argumentsFlow[i]) && !locked) {
            currentColor = argumentsFlow[i];
        }
        else if (argumentsFlow[i] === 'lock') {
            locked = true;
        }
        else if (argumentsFlow[i] === 'unlock') {
            locked = false;
        }

    }
    process.stdout.write(currentColor);
})

const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', ];

function program(lines) {

  const count = Number(lines[0]);

  let color = "blue";
  let locked = false;

  for (let i = 1; i <= count; i++) {
    const command = lines[i].trim();
    if (command === "lock" && !locked) {
      locked = true;
    }
    if (command === "unlock" && locked) {
      locked = false;
    }
    if (colors.includes(command) && !locked) {
      color = command;
    }
  }

  return color;
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const { EOL } = require('os')
  const lines = i.split(EOL)
  console.log(program(lines));
})

const n = readline();
var nowStatus = "blue";
var flag = false;
for (var i = 0; i < n; i++) {
    var command = readline();

    switch (command) {
        case 'lock':
            flag = true;
            break;
        case 'unlock':
            flag = false;
            break;
        default:
            if (!flag) {
                nowStatus = command;
            }
    }
}

print(nowStatus);

var readline = require('readline');
var { stdin: input, stdout: output } = require('process');

var rl = readline.createInterface({ input, output });

var isLocked = false;
var currentColor = "blue";

rl.on('line', function foo(input) {
  if (typeof input === "number") {
    return;
  }
  if (input === "lock") {
    isLocked = true;
    return;
  }
  if (input === "unlock") {
    isLocked = false;
    return;
  }
  if (isLocked) {
    return;
  }
  currentColor = input;
});

rl.on('close', function boo(input) {
  console.log(currentColor);
});

var readline = require('readline');
var { stdin: input, stdout: output } = require('process');

var rl = readline.createInterface({ input, output });

var isLocked = false;
var currentColor = "blue";

rl.on('line', function foo(input) {
  if (typeof input === "number") {
    return;
  }
  if (input === "lock") {
    isLocked = true;
    return;
  }
  if (input === "unlock") {
    isLocked = false;
    return;
  }
  if (isLocked) {
    return;
  }
  currentColor = input;
});

rl.on('close', function boo(input) {
  console.log(currentColor);
  rl.close();
});

var readline = require('readline');
var { stdin: input, stdout: output } = require('process');

var rl = readline.createInterface({ input, output });

var isLocked = false;
var currentColor = "blue";

rl.on('line', function foo(input) {
  if (typeof input === "number") {
    return;
  }
  if (input === "lock") {
    isLocked = true;
    return;
  }
  if (input === "unlock") {
    isLocked = false;
    return;
  }
  if (isLocked) {
    return;
  }
  currentColor = input;
});

rl.on('close', function boo(input) {
  rl.write(currentColor);
});

module.exports = function color(...args) {
  let isLocked = false;
  let currentColor = "blue";

  args.forEach((arg) => {
    if (typeof arg === "number") {
      return;
    }
    if (arg === "lock") {
      isLocked = true;
      return;
    }
    if (arg === "unlock") {
      isLocked = false;
      return;
    }
    if (isLocked) {
      return;
    }
    currentColor = arg;
  });

  return currentColor;
}

var readline = require('readline');
var fs = require('fs');
var rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('./A.txt'),
    output: process.stdout,
    terminal: false
});

// function A (content) {
//     let currentState = 'unlock'
//     let currentColor = 'blue'
//     for (let i = 0; i < content[0]; i++) {
//         if (i === 0) {
//             continue
//         }
//         if (currentState === 'lock') continue
//         if (content[i] === 'lock' || content[i] === 'unlock') {
//             currentState = content[i]
//             continue
//         }
//         else currentColor = content[i]
//     }
//     return currentColor
// }
//
// module.exports = A

let currentState = 'unlock'
let currentColor = 'blue'
let i = 0

rl
    .on('line', line => {
        if (i === 0) {
            i++
            return
        }
        if (currentState === 'lock') return
        switch (line) {
            case 'lock':
            case 'unlock':
                currentState = line
                return;
            case 'red':
            case 'orange':
            case 'yellow':
            case 'green':
            case 'blue':
            case 'indigo':
            case 'violet':
                currentColor = line
                break
        }
    })
    .on('close', () => {
        process.stdout.write(currentColor)
    })

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

let currentState = 'unlock'
let currentColor = 'blue'
let i = 0

rl
    .on('line', line => {
        if (i === 0) {
            i++
            return
        }
        if (currentState === 'lock') return
        if (line === 'lock' || line === 'unlock') {
            currentState = line
            return
        }
        else currentColor = line
        i++
    })
    .on('close', () => {
        process.stdout.write(currentColor)
    })

const readline = require('readline');
const fs = require('fs');

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

let count = 0;
let quantity = 0;
let flag = false;
let output = 'blue';

readInterface.on('line', function(line) {
    if (count === 0) {
        quantity = line;
    } else {
        switch (line) {
            case 'lock':
                flag = true
                break;
            case 'unlock':
                flag = false
                break;
            case 'red':
            case 'orange':
            case 'yellow':
            case 'green':
            case 'blue':
            case 'indigo':
            case 'violet':
                output = !flag ? line : output;
                break;
        }
    }

    if (count == quantity) {
        console.log('output', output);
    }

    count++;

});

const readline = require('readline');
const fs = require('fs');

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

let count = 0;
let quantity = '';
let flag = false;
let output = 'blue';

readInterface.on('line', function(line) {
    if (count === 0) {
        quantity = line;
    } else {
        switch (line) {
            case 'lock':
                flag = true
                break;
            case 'unlock':
                flag = false
                break;
            case 'red':
            case 'orange':
            case 'yellow':
            case 'green':
            case 'blue':
            case 'indigo':
            case 'violet':
                output = !flag ? line : output;
                break;
        }
    }

    count++

    if (count == quantity) {
        console.log(output);
    }
});

const readline = require('readline');
const fs = require('fs');

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

let count = 0;
let quantity = '';
let flag = false;
let output = 'blue';

readInterface.on('line', function(line) {
    if (count === 0) {
        quantity = line;
    } else {
        switch (line) {
            case 'lock':
                flag = true
                break;
            case 'unlock':
                flag = false
                break;
            default:
                output = !flag ? line : output;
                break;
        }
    }

    count++

    if (count == quantity) {
        console.log(output);
    }
});

const messagesString = `5
lock
unlock
lock
unlock
unlock
`;

const lines = messagesString
    .split('\n')
    .map(line => line.trim())
    .filter(line => line.length > 0);

const count = +lines[0];
const messages = lines.slice(1, count + 1);

const LOCK = 'lock';
const UNLOCK = 'unlock';
const ALLOW_COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];

let isLock = false;
let currentColor = 'blue';

messages.forEach((message) => {
    if (message === UNLOCK) {
        isLock = false;
    }

    if (message === LOCK) {
        isLock = true;
    }

    if (ALLOW_COLORS.includes(message) && !isLock) {
        currentColor = message;
    }
});

console.log(currentColor);

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    let lines = i.split(EOL)
    let color = 'blue';
    let status = 'unlock'
    lines = lines.slice(1);
        lines.forEach(item => {
        switch (item) {
            case 'unlock':
                status = 'unlock';
                break;
            case 'lock':
                status = 'lock';
                break;
            default:
                if (status === 'lock') {
                    break;
                } else if (status === 'unlock') {
                    color = item;
                }
        }
    });
    console.log(color);
});

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const N = parseInt(lines[0]);
  let res = 'blue';
  let isUnlock = true;

  const color = {
    blue: 'blue',
    red: 'red',
    orange: 'orange',
    yellow: 'yellow',
    green: 'green',
    indigo: 'indigo',
    violet: 'violet',
  };

  for (let i = 1; i < N; i++) {
    if (lines[i] === 'lock') {
      isUnlock = false;
    } else if (lines[i] === 'unlock') {
      isUnlock = true;
    }
    if (isUnlock) {
      if (color[lines[i]] != undefined) {
        res = lines[i];
      }
    }
  }

  console.log(res);
});

const nextString = (function() {
  const listeners = [], strings = [], ps = process.stdin
  let last = ''
  ps.setEncoding('utf8')
  ps.on('readable', () => {
    let chunk
    while ((chunk = ps.read()) !== null) {
      chunk = (last + chunk).split(/\r\n|\r|\n/)
      last = chunk[chunk.length - 1]
      for (let i = 0; i < chunk.length - 1; ++i) {
        if (chunk[i].length > 0) {
          if (listeners.length > 0) {
            listeners.shift(1)(chunk[i])
          }
          else {
            strings.push(chunk[i])
          }
        }
      }
    }
  })
  const fn = resolve => {
    if (strings.length > 0) {
      resolve(strings.shift(1))
    }
    else {
      listeners.push(resolve)
    }
  }
  return () => new Promise(fn)
})()

async function main() {
  let n = +await nextString()
  let ans = 'blue'
  let lock = 'lock'
  let unlock = 'unlock'
  let locked = false
  for (let i = 0; i < n; ++i) {
    let next = await nextString()
    if (next === lock) {
      locked = true
    }
    else if (next === unlock) {
      locked = false
    }
    else if (!locked) {
      ans = next
    }
  }
  console.log(next)
}

main()


The Squareland national forest is divided into equal $$$1 \times 1$$$ square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates $$$(x, y)$$$ of its south-west corner.Three friends, Alice, Bob, and Charlie are going to buy three distinct plots of land $$$A, B, C$$$ in the forest. Initially, all plots in the forest (including the plots $$$A, B, C$$$) are covered by trees. The friends want to visit each other, so they want to clean some of the plots from trees. After cleaning, one should be able to reach any of the plots $$$A, B, C$$$ from any other one of those by moving through adjacent cleared plots. Two plots are adjacent if they share a side.    For example, $$$A=(0,0)$$$, $$$B=(1,1)$$$, $$$C=(2,2)$$$. The minimal number of plots to be cleared is $$$5$$$. One of the ways to do it is shown with the gray color. Of course, the friends don't want to strain too much. Help them find out the smallest number of plots they need to clean from trees.

The first line contains two integers $$$x_A$$$ and $$$y_A$$$ — coordinates of the plot $$$A$$$ ($$$0 \leq x_A, y_A \leq 1000$$$). The following two lines describe coordinates $$$(x_B, y_B)$$$ and $$$(x_C, y_C)$$$ of plots $$$B$$$ and $$$C$$$ respectively in the same format ($$$0 \leq x_B, y_B, x_C, y_C \leq 1000$$$). It is guaranteed that all three plots are distinct.

On the first line print a single integer $$$k$$$ — the smallest number of plots needed to be cleaned from trees. The following $$$k$$$ lines should contain coordinates of all plots needed to be cleaned. All $$$k$$$ plots should be distinct. You can output the plots in any order. If there are multiple solutions, print any of them.

NoteThe first example is shown on the picture in the legend.The second example is illustrated with the following image:

function main() {
    let lineA = stdin[0].split(' ');
    let lineB = stdin[1].split(' ');
    let lineC = stdin[2].split(' ');

    let xA = parseInt(lineA[0]);
    let yA = parseInt(lineA[1]);
    let xB = parseInt(lineB[0]);
    let yB = parseInt(lineB[1]);
    let xC = parseInt(lineC[0]);
    let yC = parseInt(lineC[1]);

    let arr = [];

    if( yC>yA && yC>yB ) {
        let yLine = Math.max(yA, yB);
        let xMin = Math.min(xA, xB);
        let xMax = Math.max(xA, xB);
        let xLine = (yLine==yA) ? xB : xA;

        arr = arr.concat(
            GetPath( [xA, yA], [xLine, yLine] )
        );
        arr = arr.concat(
            GetPath( [xB, yB], [xLine, yLine] )
        );
        arr = arr.concat(
            GetPath( [xC, yC], [xC, yLine] )
        );
        arr = arr.concat(
            GetPath( [xLine, yLine], [xC, yLine] )
        );

    } else if( yC<yA && yC<yB ) {
        let yLine = Math.min(yA, yB);
        let xMin = Math.min(xA, xB);
        let xMax = Math.max(xA, xB);
        let xLine = (yLine==yA) ? xB : xA;

        arr = arr.concat(
            GetPath( [xA, yA], [xLine, yLine] )
        );
        arr = arr.concat(
            GetPath( [xB, yB], [xLine, yLine] )
        );
        arr = arr.concat(
            GetPath( [xC, yC], [xC, yLine] )
        );
        arr = arr.concat(
            GetPath( [xLine, yLine], [xC, yLine] )
        );
    } else {
        let yMin = Math.min(yA, yB);
        let yMax = Math.max(yA, yB);
        let xMin = Math.min(xA, xB);
        let xMax = Math.max(xA, xB);

        if( xC < xMin ) {
            arr = arr.concat(
                GetPath( [xC, yC], [xMin, yC] )
            );
            arr = arr.concat(
                GetPath( [xA, yA], [xMin, yC] )
            );
            arr = arr.concat(
                GetPath( [xB, yB], [xMin, yC] )
            );
        }
        else if( xMax < xC ) {
            arr = arr.concat(
                GetPath( [xC, yC], [xMax, yC] )
            );
            arr = arr.concat(
                GetPath( [xA, yA], [xMax, yC] )
            );
            arr = arr.concat(
                GetPath( [xB, yB], [xMax, yC] )
            );
        } else {
            arr = arr.concat(
                GetPath( [xB, yB], [xC, yC] )
            );
            arr = arr.concat(
                GetPath( [xA, yA], [xC, yC] )
            );
        }
    }

    var countMap = arr
        .map( (coords) => {
            return {count: 1, coords: coords};
        })
        .reduce( (a, b) => {
            a[b.coords] = {count: ((a[b.coords]==undefined)? 0 : a[b.coords].count)  + b.count, coords: b.coords};
            return a;
        }, {});

    var uniques = Object.keys(countMap).map( (a) => (countMap[a].coords) );

    console.log(uniques.length);
    for(let i=0 ; i<uniques.length; i++) {
        console.log( uniques[i][0] + ' ' + uniques[i][1] );
    }
};

function GetPath(start, end) {
    let startX = start[0];
    let startY = start[1];
    let endX = end[0];
    let endY = end[1];

    let xDiff = (startX<endX) ? 1 : -1;
    let yDiff = (startY<endY) ? 1 : -1;

    let arr = [];

    for(let x=startX; ; x+=xDiff) {
        arr.push([x, startY]);
        if( x==endX) {
            break;
        }
    }
    for(let y=startY; ; y+=yDiff) {
        arr.push([endX, y]);
        if( y==endY) {
            break;
        }
    }
    return arr;
}

const readline = require('readline');
const rl = readline.createInterface(process.stdin, process.stdout, null);

var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);


The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of $$$n$$$ haybale piles on the farm. The $$$i$$$-th pile contains $$$a_i$$$ haybales. However, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move one haybale in any pile to an adjacent pile. Formally, in one day she can choose any two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$) such that $$$|i-j|=1$$$ and $$$a_i>0$$$ and apply $$$a_i = a_i - 1$$$, $$$a_j = a_j + 1$$$. She may also decide to not do anything on some days because she is lazy.Bessie wants to maximize the number of haybales in pile $$$1$$$ (i.e. to maximize $$$a_1$$$), and she only has $$$d$$$ days to do so before Farmer John returns. Help her find the maximum number of haybales that may be in pile $$$1$$$ if she acts optimally!

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$)  — the number of test cases. Next $$$2t$$$ lines contain a description of test cases  — two lines per test case. The first line of each test case contains integers $$$n$$$ and $$$d$$$ ($$$1 \le n,d \le 100$$$) — the number of haybale piles and the number of days, respectively.  The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 100$$$)  — the number of haybales in each pile.

For each test case, output one integer: the maximum number of haybales that may be in pile $$$1$$$ after $$$d$$$ days if Bessie acts optimally.

NoteIn the first test case of the sample, this is one possible way Bessie can end up with $$$3$$$ haybales in pile $$$1$$$:   On day one, move a haybale from pile $$$3$$$ to pile $$$2$$$  On day two, move a haybale from pile $$$3$$$ to pile $$$2$$$  On day three, move a haybale from pile $$$2$$$ to pile $$$1$$$  On day four, move a haybale from pile $$$2$$$ to pile $$$1$$$  On day five, do nothing  In the second test case of the sample, Bessie can do nothing on the first day and move a haybale from pile $$$2$$$ to pile $$$1$$$ on the second day.

t = +readline();
while (t-->0){
    ar = readline().split(' ').map(Number);
    n = ar[0], m = ar[1];
    sum = 0;
    readline().split(' ').map(Number).forEach((x,ind)=>{
        if (m >= x*ind){
            m -= x*ind;
            sum += x;
        } else {
            sum += Math.floor(m / ind);
            m = 0;
        }
    });
    print(sum);
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var N = one[0];
        var d = one[1];
        var list = myconv(next(),4);
        for(var j = 1; j < N; j++){
            if(d >= list[j] * j){
                list[0] += list[j];
                d -= list[j] * j;
            }else{
                //d:5 list[j]:3 * 2
                list[0] += Math.floor(d / j);
                d = 0;
            }
        }
        output[i] = list[0];
    }
    myout(myconv(output,9));
}

const main = (data) => {
  const testsCount = data[0];

  for (let i = 1; i <= testsCount; i++) {
    let [n, k] =  data[i * 2 - 1].split(' ');
    const arr    =  data[i * 2].split(' ');

    let index = 1;
    let result = 0;

    while (k > 0 && index < arr.length) {
      while (arr[index] > 0 && k > 0) {
        k -= index;
        arr[index]--;
        result++;
      }

      index++;
    }

    if (k < 0) { result-- };

    console.log(+arr[0] + result);
  }
}

let data = '';

process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
  data = data.split('\n');

  main(data);
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (arr, days) {
        let first = arr[0];
        let rest = days;

        for (let i = 1; i < arr.length; i++) {
            if (rest <= 0) return first;
            for (let c = 1; c <= arr[i]; c++) {
                if (rest <= 0) return first;
                if (i <= rest ) {
                    first++;
                    rest = rest - i;
                }
            }
        }

        return first;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let days = lines[testCount * 2 - 1].split(' ').map(Number)[1];
        let arr = lines[testCount * 2].split(' ').map(Number);

        let result = foo(arr, days);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let n, d;

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

  if (c % 2 === 1) {
    c++;
    [n, d] = data.split(' ').map(Number);
    return;
  }

  const arr = data.split(' ').map(Number);

  while (d > 0) {
    for (let i = 1; i < arr.length; i++) {
      if (arr[i] !== 0) {
        arr[i - 1] += 1;
        arr[i] -= 1;
        break;
      }
    }

    d--;
  }

  console.log(arr[0]);

  c++;
});

(function () {
    var inp = "";
    process.stdin.on("data", function (d) { return inp += d.toString(); });
    process.stdin.on("end", function () { return main(inp); });
    process.stdin.resume();
})();
function main(rawInput) {
    var lines = rawInput.split("\n");
    var Ntests = parseInt(lines.shift(), 10);
    for (var i = 0; i < Ntests; i++) {
        var _a = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); }), numPiles = _a[0], days = _a[1];
        var piles = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); });
        console.log(solve(days, piles));
    }
}
function solve(days, piles) {
    for (var i = 1; i < piles.length && i <= days; i++) {
        if (piles[i] > 0) {
            piles[i]--;
            piles[0]++;
            days -= i;
            i--;
        }
    }
    return piles[0];
}

t = +readline();
while (t-->0){
    ar = readline().split(' ').map(Number);
    n = ar[0], m = ar[1];
    sum = 0;
    readline().split(' ').map(Number).forEach((x,ind)=>{
        if (m >= x*ind){
            m -= x*ind;
            sum += x;
        } else {
            sum += Math.floor(m / ind);
        }
    });
    print(sum);
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var N = one[0];
        var d = one[1];
        var list = myconv(next(),4);
        for(var j = 1; j < N; j++){
            if(d > list[j] * j){
                list[0] += list[j];
                d -= list[j] * j;
            }else{
                //d:5 list[j]:3 * 2
                list[0] += Math.floor(d / j * list[j]);
                d = 0;
            }
        }
        output[i] = list[0];
    }
    myout(myconv(output,9));
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var N = one[0];
        var d = one[1];
        var list = myconv(next(),4);
        for(var j = 1; j < N; j++){
            if(d >= list[j] * j){
                list[0] += list[j];
                d -= list[j] * j;
            }else{
                //d:5 list[j]:3 * 2
                list[0] += Math.floor(d % list[j]);
                d = 0;
            }
        }
        output[i] = list[0];
    }
    myout(myconv(output,9));
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (arr, days) {
        let first = arr[0];
        let rest = days;

        for (let i = 1; i < arr.length; i++) {
            if (rest <= 0) return first;
            for (let c = 1; c <= arr[i]; c++) {
                if (rest <= 0) return first;
                if (i + 1 <= rest ) {
                    first++;
                    rest = rest - i;
                }
            }
        }

        return first;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let days = lines[testCount * 2 - 1].split(' ').map(Number)[1];
        let arr = lines[testCount * 2].split(' ').map(Number);

        let result = foo(arr, days);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

(function () {
    var inp = "";
    process.stdin.on("data", function (d) { return inp += d.toString(); });
    process.stdin.on("end", function () { return main(inp); });
    process.stdin.resume();
})();
function main(rawInput) {
    var lines = rawInput.split("\n");
    var Ntests = parseInt(lines.shift(), 10);
    for (var i = 0; i < Ntests; i++) {
        var _a = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); }), numPiles = _a[0], days = _a[1];
        var piles = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); });
        console.log(solve(days, piles));
    }
}
function solve(days, piles) {
    for (var i = 1; i < piles.length && i < days; i++) {
        if (piles[i] > 0) {
            piles[i]--;
            piles[0]++;
            days -= i;
            i--;
        }
    }
    return piles[0];
}


Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs in adjacent squares.For example, the correct field to play looks like that: 001*2***101*. The cells that are marked with "*" contain bombs. Note that on the correct field the numbers represent the number of bombs in adjacent cells. For example, field 2* is not correct, because cell with value 2 must have two adjacent cells with bombs.Valera wants to make a correct field to play "Minesweeper 1D". He has already painted a squared field with width of n cells, put several bombs on the field and wrote numbers into some cells. Now he wonders how many ways to fill the remaining cells with bombs and numbers are there if we should get a correct field in the end.

The first line contains sequence of characters without spaces s1s2... sn (1 ≤ n ≤ 106), containing only characters "*", "?" and digits "0", "1" or "2". If character si equals "*", then the i-th cell of the field contains a bomb. If character si equals "?", then Valera hasn't yet decided what to put in the i-th cell. Character si, that is equal to a digit, represents the digit written in the i-th square.

Print a single integer — the number of ways Valera can fill the empty cells and get a correct field. As the answer can be rather large, print it modulo 1000000007 (109 + 7).

NoteIn the first test sample you can get the following correct fields: 001**1, 001***, 001*2*, 001*10.

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, key, newState, state, value, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      for (key in newState) {
        value = newState[key];
        newState[key] = value % 1000000007;
      }
      state = newState;
    }
    return (state.norequire + state.bomb) % 1000000007;
  };

  print(sweep(readline()));

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, key, newState, state, value, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      for (key in newState) {
        value = newState[key];
        newState[key] = value % 1000000007;
      }
      state = newState;
    }
    return state.norequire + state.bomb;
  };

  print(sweep(readline()));

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, newState, state, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      state = newState;
      console.log(char, state);
    }
    return state.norequire + state.bomb;
  };

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, newState, state, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      state = newState;
    }
    return state.norequire + state.bomb;
  };

  print(sweep(readline()));

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);


Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindrome numbers. Pari loves integers with even length (i.e. the numbers with even number of digits), so she tries to see a lot of big palindrome numbers with even length (like a 2-digit 11 or 6-digit 122221), so maybe she could see something in them.Now Pari asks you to write a program that gets a huge integer n from the input and tells what is the n-th even-length positive palindrome number?

The only line of the input contains a single integer n (1 ≤ n ≤ 10100 000).

Print the n-th even-length palindrome number.

NoteThe first 10 even-length palindrome numbers are 11, 22, 33, ... , 88, 99 and 1001.

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

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

function main() {
	let n = readLine().split('');
	let res = n.join('') + n.reverse().join('');
	console.log(res);
}

var n = readline();

write(n);
n = n.split("").reverse().join("");
write(n);

'use strict';

// var inpArr = `
// 12
// `.trim().split('\n').map(x => x.trim()), inpLine = 0;
// function readline() {
//   return inpArr[inpLine++];
// }
// function print(x) {
//   console.log(x);
// }

var str = readline().trim();

print(str + str.split('').reverse().join(''))

var n = readline();
print(n + [...n].reverse().join(''));

var n = readline();
var n_ = n.split('').reverse().join('');

print(n+n_);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var n, reverse;

n = readline();
answer = n + n.split('').reverse().join('');

write(answer);

var s = readline();
var s_ = "";
for (var i in s) {
	s_ = s[i] + s_;
}
write(s+s_);

// načtu číslo
var number = readline();

var result = number;
var t = result;

for (var i = t.length-1; i >= 0; i--) {
	result += t[i];
}

write(result);

var str = readline().trim();
str += str.split('').reverse().join('');
print(str);

// načtu číslo
var number = Number(readline());

var result = String(number);
var t = result;

for (var i = t.length-1; i >= 0; i--) {
	result += t[i];
}

write(result);