Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $$$26$$$ buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctioning. To check which buttons need replacement, Polycarp pressed some buttons in sequence, and a string $$$s$$$ appeared on the screen. When Polycarp presses a button with character $$$c$$$, one of the following events happened:  if the button was working correctly, a character $$$c$$$ appeared at the end of the string Polycarp was typing;  if the button was malfunctioning, two characters $$$c$$$ appeared at the end of the string. For example, suppose the buttons corresponding to characters a and c are working correctly, and the button corresponding to b is malfunctioning. If Polycarp presses the buttons in the order a, b, a, c, a, b, a, then the string he is typing changes as follows: a $$$\rightarrow$$$ abb $$$\rightarrow$$$ abba $$$\rightarrow$$$ abbac $$$\rightarrow$$$ abbaca $$$\rightarrow$$$ abbacabb $$$\rightarrow$$$ abbacabba.You are given a string $$$s$$$ which appeared on the screen after Polycarp pressed some buttons. Help Polycarp to determine which buttons are working correctly for sure (that is, this string could not appear on the screen if any of these buttons was malfunctioning).You may assume that the buttons don't start malfunctioning when Polycarp types the string: each button either works correctly throughout the whole process, or malfunctions throughout the whole process.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then the test cases follow. Each test case is represented by one line containing a string $$$s$$$ consisting of no less than $$$1$$$ and no more than $$$500$$$ lowercase Latin letters.

For each test case, print one line containing a string $$$res$$$. The string $$$res$$$ should contain all characters which correspond to buttons that work correctly in alphabetical order, without any separators or repetitions. If all buttons may malfunction, $$$res$$$ should be empty.

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});
function main()
{
    let n = Number(readline());
        while(n--) {
            let a = Array.from(readline());
            let liters = new Set();
            while(a.length > 0) {
                if(a[0] == a[1]) {
                    a.splice(0, 2);
                } else {
                    liters.add(a[0]);
                    a.splice(0, 1);
                }
            }
            liters=Array.from(liters);
            liters.sort();
            for(let l of liters)
            {
                process.stdout.write(l);
            }
            process.stdout.write('\n');
        }
    return 0;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

// your code goes here
let input = "";
process.stdin.on("data", x => input += x);
process.stdin.on("end", () => {
	console.log(input
		.split("\n")
		.filter(x => x !== "")
		.filter((_, i) => i !== 0)
		.map(string =>
			[...new Set([...string.match(/(.)\1{0,}/g)
				.filter(x => x.length % 2 !== 0)
				.join("")])].sort().join("")
		)
		.join("\n"));
});

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return [...new Set(res.sort())].join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

function answer (input) {
    var charArr = input.split('');
    var res = [];
    var currentStreak = 1;
    for (var i = 1; i < charArr.length; i++) {
        if (charArr[i] === charArr[i - 1]) {
            currentStreak++;
        } else {
            res.push(charArr[i - 1] + '-' + currentStreak);
            currentStreak = 1;
        }
    }
    res.push(charArr[charArr.length - 1] + '-' + currentStreak);

    var answer = [];
    res.forEach(elem => {
        if (parseInt(elem.split('-')[1]) % 2 === 1) {
            answer.push(elem.split('')[0]);
        }
    });
    return [...new Set(answer)].sort().join('');
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});
function main()
{
    let n = Number(readline());
        while(n--) {
            let a = Array.from(readline());
            let liters = new Set();
            while(a.length > 0) {
                if(a[0] == a[1]) {
                    a.splice(0, 2);
                } else {
                    liters.add(a[0]);
                    a.splice(0, 1);
                }
            }
            for(let l of liters)
            {
                process.stdout.write(l);
            }
            process.stdout.write('\n');
        }
    return 0;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});
function main()
{
    let n = Number(readline());
        while(n--) {
            let a = Array.from(readline());
            let liters = [];
            while(a.length > 0) {
                if(a[0] == a[1]) {
                    a.splice(0, 2);
                } else {
                    liters.push(a[0]);
                    a.splice(0, 1);
                }
            }
            liters.sort((a, b) => {
                return a.charCodeAt(0) - b.charCodeAt(0);
            })
            for(let l of liters)
            {
                process.stdout.write(l);
            }
            process.stdout.write('\n');
        }
    return 0;
}

var testCases = readline();
while(testCases--){
    var input = readline();
     var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++;
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
}

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
while(testCases--){
    var input = readline();
     var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
}

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    print(str)
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length ;i++) {
        var curr = input[i];
        if (curr !== input[i+1]) {
         output+=curr;
        }
   }
   print(output);
});

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
});

const testCases = readline();
const input1 = readline();
const input2 = readline();
const input3 = readline();
const input4 = readline();
const inputs = [input1,input2,input3,input4];
inputs.forEach(input => print(input))

function answer (input) {
    var charArr = input.split('');
    write(charArr)
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
   output.split("").sort();
   print(output);
});

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    write(str)
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
});

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort();
   print(output);
});


A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it!You are given integers $$$n,k$$$. Construct a grid $$$A$$$ with size $$$n \times n$$$ consisting of integers $$$0$$$ and $$$1$$$. The very important condition should be satisfied: the sum of all elements in the grid is exactly $$$k$$$. In other words, the number of $$$1$$$ in the grid is equal to $$$k$$$.Let's define:  $$$A_{i,j}$$$ as the integer in the $$$i$$$-th row and the $$$j$$$-th column.  $$$R_i = A_{i,1}+A_{i,2}+...+A_{i,n}$$$ (for all $$$1 \le i \le n$$$).  $$$C_j = A_{1,j}+A_{2,j}+...+A_{n,j}$$$ (for all $$$1 \le j \le n$$$).  In other words, $$$R_i$$$ are row sums and $$$C_j$$$ are column sums of the grid $$$A$$$.  For the grid $$$A$$$ let's define the value $$$f(A) = (\max(R)-\min(R))^2 + (\max(C)-\min(C))^2$$$ (here for an integer sequence $$$X$$$ we define $$$\max(X)$$$ as the maximum value in $$$X$$$ and $$$\min(X)$$$ as the minimum value in $$$X$$$). Find any grid $$$A$$$, which satisfies the following condition. Among such grids find any, for which the value $$$f(A)$$$ is the minimum possible. Among such tables, you can find any.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Next $$$t$$$ lines contain descriptions of test cases. For each test case the only line contains two integers $$$n$$$, $$$k$$$ $$$(1 \le n \le 300, 0 \le k \le n^2)$$$. It is guaranteed that the sum of $$$n^2$$$ for all test cases does not exceed $$$10^5$$$.

For each test case, firstly print the minimum possible value of $$$f(A)$$$ among all tables, for which the condition is satisfied. After that, print $$$n$$$ lines contain $$$n$$$ characters each. The $$$j$$$-th character in the $$$i$$$-th line should be equal to $$$A_{i,j}$$$. If there are multiple answers you can print any.

NoteIn the first test case, the sum of all elements in the grid is equal to $$$2$$$, so the condition is satisfied. $$$R_1 = 1, R_2 = 1$$$ and $$$C_1 = 1, C_2 = 1$$$. Then, $$$f(A) = (1-1)^2 + (1-1)^2 = 0$$$, which is the minimum possible value of $$$f(A)$$$.In the second test case, the sum of all elements in the grid is equal to $$$8$$$, so the condition is satisfied. $$$R_1 = 3, R_2 = 3, R_3 = 2$$$ and $$$C_1 = 3, C_2 = 2, C_3 = 3$$$. Then, $$$f(A) = (3-2)^2 + (3-2)^2 = 2$$$. It can be proven, that it is the minimum possible value of $$$f(A)$$$.

const process = require('process');

let inp = "";
process.stdin.on('data', chunk => inp += chunk);
process.stdin.on('end', () => {
    inp = inp.split('\n');
    let ic = 0;
    for (let ntest = +inp[ic++]; ntest--; ) {
        let [n, r] = inp[ic++].trim().split(' ').map(x => +x);
        let a = [];
        for (let i = 0; i < n; ++i) {
            let row = [];
            for (let f = 0;f < n; ++f) row.push(0);
            a.push(row);
        }

        let d = Math.floor(r / n);
        for (let r = 0; r < n; ++r) {
            for (let i = 0; i < d; ++i) {
                let c = (r + i) % n;
                a[r][c] = 1;
            }
        }
        let rem = r % n;
        for (let i = 0; i < rem; ++i) {
            let c = (i + d) % n;
            a[i][c] = 1;
        }

        console.log(rem ? 2 : 0);
        console.log(a.map(row => row.join('')).join('\n'));
    }
});

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();
    });

    D();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let [n,m] = ti(readline().split(' '));
    let a = ti(readline().split(' '));
    let b = ti(readline().split(' '));
    let o = new Array(10);
    let z = new Array(10);
    o.fill(0);
    z.fill(0);
    for(let i = 0; i < m; i++){
        let t = 1;
        for(let j = 0; j < 10; j++){
            if(b[i] & t !== 0)
                o[j] = 1;
            else
                z[j] = 1;

            t << 1;
        }
    }

    let c = new Array(10);
    for(let i = 0; i < n; i++){
        let t = 1;
        for(let j = 0; j < 10; j++){
            if(a[i] & t !== 0){
                if(z[j] === 1)
                    c[j] = 0;
                else
                    c[j] = 1;
            }
            t << 1;
        }
    }

    let res = 0;
    for(let i = 9; i >= 0; i--){
        res += pi(c[i])*Math.pow(2,9-i);
    }
    console.log(res);
}

function B(){
    let t = pi(readline());
    while(t){
        t--;
        let [n,k,z] = ti(readline().split(' '));
        let a = ti(readline().split(' '));

        // pre -> 0,1 -> right,left
        let dp = new Array(z+1);
        for(let i = 0; i < z+1; i++){
            dp[i] = new Array(n);
            dp[i].fill(-1);
        }

        let solve = (i,j,index,pre) => {
            if(index < 0 || index >= n)
                return 0;
            if(i > k)
                return 0;
            if(dp[j][index] !== -1)
                return dp[j][index];
            if(pre){
                return dp[j][index] = a[index] + solve(i+1, j, index+1, 0);
            }else{
                return dp[j][index] = a[index] + Math.max(j < z ? solve(i+1,j+1,index-1,1) : 0, solve(i+1,j,index+1,0));
            }
        }

        console.log(solve(0,0,0,1));
    }
}

function D(){
    let t = pi(readline());
    while(t){
        t--;
        let [n,k] = ti(readline().split(' '));
        let mat = new Array(n);
        for(let i = 0; i < n; i++)
            mat[i] = new Array(n);

        let x = Math.floor(k/n);
        let i = 0;
        let j = 0;
        let c = 0;
        while(i < n){
            while(c < x){
                if(j+c >= n)
                    mat[i][j+c-n] = 1;
                else
                    mat[i][j+c] = 1;
                c++;
            }
            c = 0;
            i++;
            j++;
        }

        for(let i = 0; i < n; i++)
            for(let j = 0; j < n; j++)
                if(mat[i][j] === undefined)
                    mat[i][j] = 0;

        if(k%n !== 0){
            let m = k%n;
            let st = -1;
            for(let i = 0; i < n; i++){
                if(mat[0][i] === 0){
                    st = i;
                    break;
                }
            }
            for(let i = 0; i < n; i++){
                if(m === 0)
                    break;
                for(let j = 0; j < n; j++){
                    if(mat[i][j] === 0 && j === st){
                        mat[i][j] = 1;
                        st += 1;
                        if(st >= n) st = 0;
                        m -= 1;
                        break;
                    }
                }
            }
        }

        if(k%n === 0)
            console.log(0);
        else
            console.log(2);
        for(let i = 0; i < n; i++)
            console.log(mat[i].join(''));
    }
}

function solve() {
   var nk = read().split(' ').map(Number);
   var n = nk[0];
   var k = nk[1];
   var ans = [];
   var r = [];
   var c = [];
   for (var i = 0; i < n; i++) {
      r.push(0);
      c.push(0);
      ans.push([]);
      for (var j = 0; j < n; j++) {
         ans[i].push(0);
      }
   }
   var mr = n - 1;
   var mc = n - 1;
   while (k) {
      k--;
      mr = (mr + 1) % n;
      mc = (mc + 1) % n;
      if (ans[mr][mc]) {
         mc = (mc + 1) % n;
      }
      ans[mr][mc] = 1;
      r[mr]++;
      c[mc]++;
   }
   var minr = r[0];
   var maxr = r[0];
   var minc = c[0];
   var maxc = c[0];
   for (var i = 0; i < n; i++) {
      if (r[i] > maxr) {
         maxr = r[i];
      }
      if (r[i] < minr) {
         minr = r[i];
      }
      if (c[i] > maxc) {
         maxc = c[i];
      }
      if (c[i] < minc) {
         minc = c[i];
      }
   }
   write((maxr - minr) * (maxr - minr) + (maxc - minc) * (maxc - minc));
   for (var i = 0; i < n; i++) {
      write(ans[i].join(''));
   }
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

const process = require('process');

let inp = "";
process.stdin.on('data', chunk => inp += chunk);
process.stdin.on('end', () => {
    inp = inp.split('\n');
    let ic = 0;
    for (let ntest = +inp[ic++]; ntest--; ) {
        let [n, r] = inp[ic++].trim().split(' ').map(x => +x);
        let a = [];
        for (let i = 0; i < n; ++i) {
            let row = [];
            for (let f = 0;f < n; ++f) row.push(0);
            a.push(row);
        }

        let d = Math.floor(r / n);
        for (let r = 0; r < n; ++r) {
            for (let i = 0; i < d; ++i) {
                let c = (r + i) % n;
                a[r][c] = 1;
            }
        }
        let rem = r % n;
        for (let i = 0; i < rem; ++i) {
            let c = (i + d) % n;
            a[i][c] = 1;
        }

        console.log(rem ? 2 : 0);
        console.log(a.map(row => row.join(' ')).join('\n'));
    }
});


You have a string $$$s$$$ of length $$$n$$$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters > and <.

For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.

NoteIn the first test case we can delete any character in string <>.In the second test case we don't need to delete any characters. The string > < < is good, because we can perform the following sequence of operations: > < < $$$\rightarrow$$$ < < $$$\rightarrow$$$ <.

const readline = require('readline');

const rl = readline.createInterface({
	input: process.stdin,
	setEncoding: 'utf8',
	terminal: false
});

const readInput = (function* () {
	const t = Number(yield);
	let a = [];
	for (let i = 0; i < t; i++) {
		const n = Number(yield);
		const s = (yield).trim();
		let x = 0;
		const half = Math.floor(n / 2);
		for (let j = 0; j < half; j++) {
			if (s[j] == '<' && s[n - j - 1] == '>') x++;
			else break;
		}
		a.push(x);
	}
	rl.close();
	console.log(a.join('\n'));
})();

readInput.next();

rl.on('line', (line) => {
	readInput.next(line);
});

const readline = require('readline');

const rl = readline.createInterface({
	input: process.stdin,
	setEncoding: 'utf8',
	terminal: false
});

const readInput = (function* () {
	const t = Number(yield);
	let a = [];
	for (let i = 0; i < t; i++) {
		const n = Number(yield);
		const s = (yield).trim();
		let x = 0;
		if (s[0] == '<' && s[n - 1] == '>') x++;
		a.push(x);
	}
	rl.close();
	console.log(a.join('\n'));
})();

readInput.next();

rl.on('line', (line) => {
	readInput.next(line);
});

const readline = require('readline');

const rl = readline.createInterface({
	input: process.stdin,
	setEncoding: 'utf8',
	terminal: false
});

const readInput = (function* () {
	const t = Number(yield);
	let a = [];
	for (let i = 0; i < t; i++) {
		const n = Number(yield);
		const s = (yield).trim();
		let x = 0;
		if (n % 2 == 0 && s[0] == '<' && s[n - 1] == '>') x++;
		a.push(x);
	}
	rl.close();
	console.log(a.join('\n'));
})();

readInput.next();

rl.on('line', (line) => {
	readInput.next(line);
});


A sequence of square brackets is regular if by inserting symbols "+" and "1" into it, you can get a regular mathematical expression from it. For example, sequences "[[]][]", "[]" and "[[][[]]]" — are regular, at the same time "][", "[[]" and "[[]]][" — are irregular. Draw the given sequence using a minimalistic pseudographics in the strip of the lowest possible height — use symbols '+', '-' and '|'. For example, the sequence "[[][]][]" should be represented as: +-        -++- -+    |+- -++- -+||   |||   ||   |||   ||+- -++- -+||   |+-        -++- -+Each bracket should be represented with the hepl of one or more symbols '|' (the vertical part) and symbols '+' and '-' as on the example which is given above.Brackets should be drawn without spaces one by one, only dividing pairs of consecutive pairwise brackets with a single-space bar (so that the two brackets do not visually merge into one symbol). The image should have the minimum possible height. The enclosed bracket is always smaller than the surrounding bracket, but each bracket separately strives to maximize the height of the image. So the pair of final brackets in the example above occupies the entire height of the image.Study carefully the examples below, they adequately explain the condition of the problem. Pay attention that in this problem the answer (the image) is unique.

The first line contains an even integer n (2 ≤ n ≤ 100) — the length of the sequence of brackets. The second line contains the sequence of brackets — these are n symbols "[" and "]". It is guaranteed that the given sequence of brackets is regular.

Print the drawn bracket sequence in the format which is given in the condition. Don't print extra (unnecessary) spaces.

var n = +(readline().trim());
var a = readline().trim();
var level = 0;
var levels = [];
var maxlevel = 0;
for(var i = 0; i < n; i++){
    if(a[i] == "["){
        levels[i] = level;
        if(level > maxlevel) maxlevel = level;
        level++;
    }else{
        level--;
        levels[i] = level;
    }
}

var s = [];
var cells = maxlevel * 2 + 3;
var c = 0;
for(var i = 0; i < n; i++){
    var ns = [];

    if(a[i] == "]" && a[i - 1] == "["){
        var ns = [];
        for(var j = 0; j < cells; j++){
            if(j == levels[i]){
                ns[j] = "-";
            }else if(j == maxlevel * 2 + 2 - levels[i]){
                ns[j] = "-";
            }else{
                ns[j] = " ";
            }
        }
        s[c] = ns.join("");
        c++;
    }

    var ns = [];
    var pluses = [];
    var opened = false;
    for(var j = 0; j < cells; j++){
        if(j == levels[i]){
            ns[j] = "+";
            opened = true;
        }else if(j == maxlevel * 2 + 2 - levels[i]){
            ns[j] = "+";
            opened = false;
        }else if(opened){
            ns[j] = "|";
        }else if(i > 0 && a[i - 1] == "[" && (j == levels[i - 1] || j == maxlevel * 2 + 2 - levels[i - 1])){
            ns[j] = "-";
        }else if(i > 0 && a[i + 1] == "]" && (j == levels[i + 1] || j == maxlevel * 2 + 2 - levels[i + 1])){
            ns[j] = "-";
        }else{
            ns[j] = " ";
        }
    }
    s[c] = ns.join("");
    c++;

    if(a[i] == "[" && a[i + 1] == "]"){
        var ns = [];
        for(var j = 0; j < cells; j++){
            if(j == levels[i]){
                ns[j] = "-";
            }else if(j == maxlevel * 2 + 2 - levels[i]){
                ns[j] = "-";
            }else{
                ns[j] = " ";
            }
        }
        s[c] = ns.join("");
        c++;
        for(var j = 0; j < cells; j++){
            ns[j] = " ";
        }
        s[c] = ns.join("");
        c++;
    }
}

for(var i = 0; i < cells; i++){
    var sd = "";
    for(var j = 0; j < c; j++){
        sd += s[j][i];
    }
    print(sd);
}

readline();
var brackets = readline().split(""),
	maxDeep = getMaxDeep(brackets),
	renderDeep = 1 + maxDeep*2,
	matrix;

function getMaxDeep(brackets) {
	var deep = 0;
	return brackets.reduce(function (maxDeep, bracket) {
		bracket === "[" ? ++deep : --deep;
		return deep > maxDeep ? deep : maxDeep;
	}, 1);
}

function getMatrix(brackets) {
	var matrix = [],
		pointer = 0,
		deep = 1,
		i;

	for(i = 0; i < renderDeep; i++) {
		matrix[i] = [];
	}

	brackets.forEach(function (bracket, index) {
		var height = renderDeep - (deep - 1)*2,
			top = (renderDeep - height)/2,
			bottom = height + top - 1;

		if(bracket === "["){
			if(brackets[index - 1] !== "[") createLine(pointer);
			createLine(pointer + 1)	;
			createLine(pointer + 2);
		} else {
			if(brackets[index - 1] !== "]") createLine(pointer);
			createLine(pointer + 1);
		}

		matrix.forEach(function (line, index) {
			if(index === top || index === bottom) {
				if(bracket === "[") {
					line[pointer] = "+";
					line[pointer + 1] = "-";
				} else {
					line[pointer] = "-";
					line[pointer + 1] = "+";
				}
			} else if(index > top && index < bottom){
				if(bracket === "[") {
					line[pointer] = "|";
				} else {
					line[pointer + 1] = "|";
				}
			}
		});

		if(bracket === "[") {
			if(brackets[index + 1] === "[") {
				pointer += 1;
				deep++;
			} else {
				pointer += 3;
			}
		} else {
			if(brackets[index + 1] === "]") {
				pointer += 1;
				deep--;
			} else {
				pointer += 2;
			}
		}
	});

	function createLine(pointer) {
		matrix.forEach(function (line) {
			line[pointer] = " ";
		});
	}

	return matrix;
}

function printMatrix(matrix) {
	matrix.forEach(function (line) {
		print(line.join(""));
	});
}

matrix = getMatrix(brackets, maxDeep);
printMatrix(matrix);

readline() // count

var str = readline();

var deep = 0, maxDeep = 0;
var data = [];

for (var i = 0, l = str.length; i < l; ++i) {
    if (str[i] == "[") {
        ++deep;
        if (maxDeep < deep) {
            maxDeep = deep;
        }
    } else {
        --deep;
    }
}

var line = [], currentDeep = maxDeep, width = 0;
for (var i = 0, l = str.length; i < l; ++i) {
    if (str[i] == "[") {
        line.push({type: 1, depth: currentDeep, under: str[i - 1] == "["});
        --currentDeep;
    } else {
        if (str[i - 1] == "[") {
            width += 3;
            line.push({type: 2, depth: currentDeep});
        }

        line.push({type: 1, depth: ++currentDeep, under: str[i + 1] == "]"});
    }
    ++width;
}

var data = new Array(maxDeep * 2 + 1),
    middle = Math.floor(data.length / 2),
    x = 0;

for (var i = 0, l = data.length; i < l; ++i) {
    data[i] = new Array(width);
    for (var j = 0, k = width; j < k; ++j) {
        data[i][j] = " ";
    }
};

for (var i = 0, l = line.length; i < l; ++i) {
    switch (line[i].type) {
        case 2:
            data[middle - line[i].depth - 1][x] = "-";
            data[middle + line[i].depth + 1][x] = "-";
            x += 2;
            data[middle - line[i].depth - 1][x] = "-";
            data[middle + line[i].depth + 1][x] = "-";
            x++;
            break;

        case 1:
            if (line[i].under) {
                data[middle - line[i].depth - 1][x] = "-";
            }
            data[middle - line[i].depth][x] = "+";
            for (var y = middle - line[i].depth + 1; y < middle + line[i].depth; ++y) {
                data[y][x] = "|";
            }
            data[middle + line[i].depth][x] = "+";
            if (line[i].under) {
                data[middle + line[i].depth + 1][x] = "-";
            }
            x++;
            break;
    }
}

for (var r = 0, l = data.length; r < l; ++r) {
    print(data[r].join(""));
}


Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the m-th face contains m dots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability . Also she knows that each toss is independent from others. Help her to calculate the expected maximum number of dots she could get after tossing the dice n times.

A single line contains two integers m and n (1 ≤ m, n ≤ 105).

Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10  - 4.

NoteConsider the third test example. If you've made two tosses:  You can get 1 in the first toss, and 2 in the second. Maximum equals to 2.  You can get 1 in the first toss, and 1 in the second. Maximum equals to 1.  You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.  You can get 2 in the first toss, and 2 in the second. Maximum equals to 2. The probability of each outcome is 0.25, that is expectation equals to: You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value

;(function () {

    print(function (m, n) {
        var s = m;
        for (var i = m - 1; i >= 1; i--) {
            s -= Math.pow(i / m, n);
        }

        return s;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		m = data[0], n = data[1],
		mean = m;
	for (var k = 1; k < m; ++k) {
		mean -= Math.pow(k/m, n);
	}
	print(mean);
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		m = data[0], n = data[1],
		prev = 1.0, mean = 0.0;
	for (var k = m; k >= 1; --k) {
		var curr = Math.pow((k-1)/m, n);
		mean += (prev-curr)*k;
		prev = curr;
	}
	print(mean);
}

main();

function read_int() {
    return readline().split(" ").map(function (x) { return parseInt(x); });
}
function read_float() {
    return readline().split(" ").map(function (x) { return parseFloat(x); });
}
function read() {
    return readline().split(' ');
}
var x=read();
var m=x[0]*1.0;
var n=x[1]*1.0;
var ans=m;
for (var i=1;i<m;i++){
    ans=ans-Math.pow(i*1.0/m,n);
}
print(ans);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		m = data[0], n = data[1],
		trialNum = 0.5*Math.pow(10, 8)/n,
		total = 0;
	for (var t = 0; t < trialNum; ++t) {
		var max = 0;
		for (var i = 0; i < n; ++i) {
			max = Math.max(max, 1 + Math.floor(Math.random()*m));
		}
		total += max;
	}
	print(total / trialNum);
}

main();