const n = Number(readline());
const arr = readline().split(" ").map(x => Number(x));
findLength: for (var length = n;; length >>= 1)
  findBegin: for (var begin = 0; begin < n; begin = end) {
    var end = begin + length;
    for (var i = begin + 1; i < end; i++)
      if (arr[i - 1] > arr[i]) continue findBegin;
    print(length);
    break findLength;
  }

function issorted(arr){
	for (i=1; i<arr.length; i++){
		if(+arr[i-1]>+arr[i]) return false;
	}
	return true;
}

function check(arr){
	if(issorted(arr)) {
		return arr.length;
	} else {
		return Math.max(check(arr.splice(arr.length/2)), check(arr));
	}
}

readline();
var arr = readline().split(' ');
print(check(arr));

let i = '';

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

    var n = Number(lines[0]);
    var t = lines[1].split(' ');
    t = t.map(x=>Number(x));

   console.log(minSorted(t, 0, n-1));
})

function minSorted(u, x, y) {
   var length = y-x+1;
	var middle = x+length/2-1;
	if(isSorted(u,x,y)) return length;
	else return Math.max(minSorted(u,x,middle),minSorted(u,middle+1,y));
}

function isSorted(u, x, y) {
   for (var i=x+1;i<=y;i++) {
       if(u[i]<u[i-1]) {
		     return false;
		 }
   }
   return true;
}

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

    let size=0;
    const thanosArray = lines[1].split(' ');
    thanosArray.map((v,i,a)=>a[i]=Number(v));
    const isSorted = arr => arr.every((v,i,a) => !i || a[i-1] <= v);
    const setSize =num=> size =(size>=num)?size:num;

    const splitArray=array=>{
      if (array.length==0)
         return;
      if (isSorted(array)){
          return setSize(array.length);
      }
      else {
         let half_length = Math.ceil(array.length / 2);
         let leftSide = array.splice(0,half_length);

         splitArray(leftSide);
         splitArray(array);
      }

    }

    splitArray(thanosArray)

   console.log(size)

})

var lengthA = readline();
var line2 = readline();
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] <= arr[start + 1])
            start++;
        else break;
    }

    return start === end ? true : false;
}

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

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

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const n = parseInt(arr[0])

  const a = arr[1].split(' ').map(a => parseInt(a))

  let ans = 1
  if(n == 1) {
    console.log(1)
    return
  }
  for(let i = 1; i < n; i++) {
    if(n >= 2 && a[i] >= a[i - 1] && (i + 1) % 2 == 0) ans = max(ans, 2)
    if(i >= 3 && n >= 4 && a[i] >= a[i - 1] && a[i - 1] >= a[i - 2] && a[i - 2] >= a[i - 3] && (i + 1) % 4 == 0) ans = max(ans, 4)
    if(i >= 7 && n >= 8 && a[i] >= a[i - 1] && a[i - 1] >= a[i - 2] && a[i - 2] >= a[i - 3] && a[i - 3] >= a[i - 4] && a[i - 4] >= a[i - 5] && a[i - 5] >= a[i - 6] && a[i - 6] >= a[i - 7] && (i + 1) % 8 == 0) ans = max(ans, 8)
    let flag = true
    if(i == 15) {
      for(let j = 1; j < n; j++) {
        if(a[j] < a[j - 1]) {
          flag = false
          break
        }
      }
    }
    if(flag && i == 15) {
      ans = 16
    }
  }
  wr(ans)
})

function wr(...x) {
  console.log(...x)
}

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/

    main(lines);
})

function main(lines) {
	let n = parseInt(lines[0]);
	let a = lines[1].split(' ').map(v => {return parseInt(v)});
	console.log(helper(a, 0, n-1))

}

function helper(arr, a, b) {

	// console.log(`calling helper ${a} ${b}`);
	if(isArraySorted(arr, a, b)) {
		return b-a+1;
	} else {
		let mid = Math.floor((a+b)/2);
		return Math.max(helper(arr, a, mid), helper(arr, mid+1, b));
	}

}
function isArraySorted(arr, a, b) {

	if(a === b) {
		return true;
	}
	for(let i = a+1; i<=b; i++) {
		if(arr[i] < arr[i-1]) {
			return false;
		}
	}
	return true;

}

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

const isSorted = (arr, l, r) => {
  for (let i = l; i < r; i += 1) {
    if (arr[i] > arr[i + 1]) {
      return false;
    }
  }

  return true;
};

const getMaxArrayLength = (arr) => {
  const wrapper = (l, r) => {
    if (r <= l) {
      return 1;
    }

    if (isSorted(arr, l, r)) {
      return r - l + 1;
    }

    const half = Math.floor((r + l) / 2);

    const left = wrapper(l, half);
    const right = wrapper(half + 1, r);

    return Math.max(left, right);
  };

  return wrapper(0, arr.length - 1);
};

let n = -1;
readline.on('line', (line) => {
  if (n === -1) {
    n = Number(line);
  } else {
    const numbers = line.split(' ').map(v => Number(v));
    console.log(getMaxArrayLength(numbers));
  }
});

readline();
var a = readline().split(" ").map(function(x) { return parseInt(x); });
var sort = function(a) {
    var c = JSON.parse(JSON.stringify(a));
    var sorted = c.sort(function(a,b){
        return a - b;
    });

    if (JSON.stringify(a) == JSON.stringify(sorted)) {
        // the array is sorted
        return a.length;
    } else {
        // if the array is not sorted
        // do recursion
        var first = a.splice(0, a.length / 2);
        var firstAns = sort(first);
        var secondAns = sort(a);
        return Math.max(firstAns, secondAns);
    }

}
write(sort(a));

readline();
var inputs = readline().split(" ").map((x) => parseInt(x));

function isSorted(array) {
    var limit = array.length - 1;
    for (var i = 0; i < limit; i++) {
        var current = array[i], next = array[i + 1];
        if (current > next) { return false; }
    }
    return true;

}

function thanosSort(start, end) {
    if(start === end) {
        return 1;
    }

    var sliceInputs = inputs.slice(start, end);
    if(isSorted(sliceInputs)) {
        return sliceInputs.length;
    }

    var mid = Math.floor((start+end)/ 2);
    return Math.max(thanosSort(start, mid), thanosSort(mid, end));
}

var count = thanosSort(0, inputs.length);
print(count);

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

    var n = read.number();
    var a = read.arrNumber(' ');

    function isSorted(arr) {
        for(var i = 1; i < arr.length; i++) {
            if(arr[i] < arr[i - 1]) {
                return false;
            }
        }
        return true;
    }

    if(isSorted(a)) {
        print(a.length);
        return;
    }

    var res = 1;

    function getPol(arr) {
        var arr1 = arr.slice(0, arr.length/2);
        if(isSorted(arr1)) {
            res = arr1.length;
            return;
        }

        var arr2 = arr.slice(arr.length/2, arr.length);
        if(isSorted(arr2)) {
            res = arr2.length;
            return;
        }

        if(arr2.length > 1 ) {
            getPol(arr1);
            getPol(arr2);
        }
    }

    getPol(a);
    print(res);
}());

var n = parseInt(readline());
var arr = readline().split(" ").map(function(item){return parseInt(item,10)});
// var n= 8;
// var arr = [11, 12, 1, 2, 13, 14, 3, 4];
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l % 2 == 0){
        k++;
        l = Math.floor(l / 2);
    }
    l = Math.pow(2, k);
    while (l > 0){
        if (kol>= l){
            if(l > max){
                max = l;
            }
        }
        l = Math.floor(l /2);
    }
    if (arr[i] <= arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

	(function main(){
		function sort(n, arr){
			function assessmentSort(arr, begin, end){
				var assessment = 0;
				var count = 0;
				for(i = begin+1; i < end; i++){
					count++;
					if(arr[i-1]>arr[i]){
						assessment += 1;
					}
				}
				return assessment;
			}
			var begin = 0; var end = n;
			var assessment = assessmentSort(arr, begin, end);
			while(assessment>0){
				var separate = (end - begin)/2 + begin;
				var assessment1 = assessmentSort(arr, begin, separate);
				var assessment2 = assessmentSort(arr, separate, end);
				if(assessment1>assessment2){
					begin = separate;
					assessment = assessment2
				}
				else {
					end = end - (end - begin)/2;
					assessment = assessment1
				}
			}
			debugger;
			return end - begin;

		}
		print(sort(readline()-0, (readline()).split(" ").map(i=>i-0)))
	})();

    var sizeOfArray = readline();
    var arr = readline().split(" ").map(string => parseInt(string));

    print(thanosSort(arr));

function thanosSort(arr) {
  if (isSorted(arr)) {
    return arr.length;
  }
  var newArr1 = arr.slice(0, arr.length / 2);
  var newArr2 = arr.slice(arr.length / 2);

  var sortedLength1 = thanosSort(newArr1);
  var sortedLength2 = thanosSort(newArr2);

  return Math.max(sortedLength1, sortedLength2);
}

function isSorted(arr) {
  for (var i = 0; i < arr.length - 1; i++) {
    if (arr[i] > arr[i + 1]) {
      return false;
    }
  }
  return true;
}

var len = parseInt(readline());
var mas = readline().split(' ');

function isSorted(mas, len, subLen) {

    var k = len / subLen;
    for (var i = 0; i < k; i++) {

        var begin = i * subLen + 1;
        var end = (i + 1) * subLen;
        var sorted = true;
        for (var j = begin; j < end; j++) {
            if ( parseInt(mas[j-1]) > parseInt(mas[j]) ) {
                sorted = false;
                break;
            }
        }
        if (sorted) {
            return true;
        }

    }
    return false;
}

var subLen = len;
while (subLen > 0) {

    if (isSorted(mas, len, subLen)) {
        break;
    }
    subLen /= 2;
}
print(subLen);

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

    let size=0;
    const thanosArray = lines[1].split(' ');
    thanosArray.map((v,i,a)=>a[i]=Number(v));
    const isSorted = arr => arr.every((v,i,a) => !i || a[i-1] <= v);
    const setSize =num=> size =(size>=num)?size:num;

    const splitArray=array=>{
      if (array.length==0)
         return;
      if (isSorted(array))
         return setSize(array.length);

      else {
         let half_length = Math.ceil(array.length / 2);
         let leftSide = array.splice(0,half_length);
         let rightSide = array.splice(half_length,array.length);

         splitArray(leftSide);
         splitArray(rightSide);
      }

    }

    splitArray(thanosArray)

   console.log(size)

})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/

    main(lines);
})

function main(lines) {
	let n = parseInt(lines[0]);
	let a = lines[1].split(' ').map(v => {return parseInt(v)});
	console.log(helper(a, 0, n-1))

}

function helper(arr, a, b) {
	if(isArraySorted(arr, a, b)) {
		return b-a+1;
	} else {
		mid = (a+b)/2;
		return Math.max(helper(arr, a, mid), helper(arr, mid+1, b));
	}

}
function isArraySorted(arr, a, b) {

	if(a === b) {
		return true;
	}
	for(let i = a+1; i<=b; i++) {
		if(arr[i] < arr[i-1]) {
			return false;
		}
	}
	return true;

}

var n = parseInt(readline());
var arr = readline().split(" ").map(function(item){return parseInt(item,10)});
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l > 1){
        k++;
        l /= 2;
    }
    l = Math.pow(2, k);
    if (kol>= l){
        if(l > max){
        max = l;
    }
    }
    if (arr[i] < arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

var n = parseInt(readline());
var arr = readline().split(" ").map(function(item){return parseInt(item,10)});
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l > 1){
        k++;
        l /= 2;
    }
    l = Math.pow(2, k);
    if (kol>= l){
        if(l > max){
        max = l;
    }
    }
    if (arr[i] <= arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

var n = parseInt(readline());
var arr = readline().split(" ").map((item) => {return parseInt(item,10)});
var kol = 1, max = 1;
for(var i = 0; i < n; i++){
    var l = i+1, k = 0;
    while (l > 1){
        k++;
        l /= 2;
    }
    l = Math.pow(2, k);
    if (kol>= l){
        if(l > max){
        max = l;
    }
    }
    if (arr[i] < arr[i+1]){
        kol++;
    } else{
        kol = 1;
    }
}
print(max);

function sort(n, arr){
	function assessmentSort(arr, begin, end){
		var assessment = 0;
		for(var i = begin+1; i < end; i++){
			if(arr[i-1]>arr[i]){
				assessment += 1;
			}
		}
		return assessment;
	}
	var begin = 0; var end = arr.length;
	var assessment = assessmentSort(arr, begin, end);
	while(assessment>0){
		var separate = end/2;
		var assessment1 = assessmentSort(arr, begin, separate);
		var assessment2 = assessmentSort(arr, separate, end);
		if(assessment1>assessment2){
			begin = separate;
			assessment = assessment2
		}
		else {
			end = separate;
			assessment = assessment1
		}
	}
	return end - begin;

}

print(sort(readline(), (readline()).split(" ")))

	function sort(n, arr){
		function assessmentSort(arr, begin, end){
			var assessment = 0;
			var count = 0;
			for(i = begin+1; i < end; i++){
				count++;
				if(arr[i-1]>arr[i]){
					assessment += 1;
				}
			}
			return assessment;
		}
		var begin = 0; var end = arr.length;
		var assessment = assessmentSort(arr, begin, end);
		while(assessment>0){
			var separate = end/2;
			var assessment1 = assessmentSort(arr, begin, separate);
			var assessment2 = assessmentSort(arr, separate, end);
			if(assessment1>assessment2){
				begin = separate;
				assessment = assessment2
			}
			else {
				end = separate;
				assessment = assessment1
			}
		}
		return end - begin;

	}
	print(sort(readline(), (readline()).split(" ").map(i=>i-0)))

	function sort(n, arr){
		function assessmentSort(arr, begin, end){
			var assessment = 0;
			var count = 0;
			for(i = begin+1; i < end; i++){
				count++;
				if(arr[i-1]>arr[i]){
					assessment += 1;
				}
			}
			return assessment;
		}
		var begin = 0; var end = n;
		var assessment = assessmentSort(arr, begin, end);
		while(assessment>0){
			var separate = end/2;
			var assessment1 = assessmentSort(arr, begin, separate);
			var assessment2 = assessmentSort(arr, separate, end);
			if(assessment1>assessment2){
				begin = separate;
				assessment = assessment2
			}
			else {
				end = end - (end - begin)/2;
				assessment = assessment1
			}
		}
		return end - begin;

	}
	print(sort(readline()-0, (readline()).split(" ").map(i=>i-0)))

function issorted(arr){
	for (i=1; i<arr.length; i++){
		if(+arr[i-1]>+arr[i]) return false;
	}
	return true;
}

function check(arr){
	maxLength=1;
	if(issorted(arr)) {
		maxLength=(maxLength > arr.length) ? maxLength:arr.length;
	} else {
		check(arr.splice(arr.length/2));
		check(arr);
	}
	return maxLength;
}

readline();
var arr = readline().split(' ');
print(check(arr));

function issorted(arr){
	for (i=1; i<arr.length; i++){
		if(+arr[i-1]>+arr[i]) return false;
	}
	return true;
}

function check(arr){
	print(arr, issorted(arr));
	if(issorted(arr)) {
		return arr.length;
	} else {
		return Math.max(check(arr.splice(arr.length/2)), check(arr));
	}
}

readline();
var arr = readline().split(' ');
print(check(arr));

var lengthA = readline();
print(lengthA)
var line2 = readline();
print(line2)
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start <= end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();
var line2 = readline();
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start <= end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();
var line2 = readline();
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();
print(lengthA)
var line2 = readline();
print(line2)
var arr = line2.split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var lengthA = readline();

var arr = readline().split(" ").map(_ => parseInt(_))

print(thanosSort(arr, 0, arr.length-1));

function thanosSort(arr, start, end) {

    var lengthOfArray = (end - start + 1);

    if (isSorted(arr, start, end)) return lengthOfArray

    var mid = start + Math.floor(lengthOfArray / 2);

    var left = thanosSort(arr, start, mid - 1),
        right = thanosSort(arr, mid, end);

    return Math.max(left, right);
}

function isSorted(arr, start, end) {
    while (start < end) {
        if (arr[start] < arr[start + 1])
            start++;
        else break;
    }

    if(start === end)
        return true
    else return false;
}

var a = readline().split(" ").map(function(x) { return parseInt(x); });
print(a);

readline();
var inputs = readline().split(" ").map((x) => parseInt(x));

function isSorted(array) {
    var limit = array.length - 1;
    for (var i = 0; i < limit; i++) {
        var current = array[i], next = array[i + 1];
        if (current > next) { return false; }
    }
    return true;

}

function thanosSort(start, end) {
    if(start === end) {
        return 1;
    }

    var sliceInputs = inputs.slice(start, end);
    if(isSorted(sliceInputs)) {
        return sliceInputs.length;
    }

    var mid = Math.floor((start+end)/ 2);
    return Math.max(thanosSort(start, mid -1), thanosSort(mid, end));
}

var count = thanosSort(0, inputs.length);
print(count);

readline();
var inputs = readline().split(" ").map((x) => parseInt(x));

function isSorted(array) {
    var limit = array.length - 1;
    for (var i = 0; i < limit; i++) {
        var current = array[i], next = array[i + 1];
        if (current > next) { return false; }
    }
    return true;

}

function thanosSort(start, end) {
    if(start === end) {
        return 1;
    }

    var sliceInputs = inputs.slice(start, end);
    if(isSorted(sliceInputs)) {
        return sliceInputs.length;
    }

    var mid = Math.floor((start+end)/ 2);
    return Math.max(thanosSort(start, mid -1), thanosSort(mid, end));
}

var count = thanosSort(0, inputs.length - 1);
print(count);


function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = arr[0]
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(i / res)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

var n = +readline(), a = readline().split(" ").map(Number);
var check = true;

for(var i = 0; i < n; i++){
	for(;;){
		if(a[i] % 2 == 0){
			a[i] /= 2;
		}
		else{
			break;
		}
	}

	for(;;){
		if(a[i] % 3 == 0){
			a[i] /= 3;
		}
		else{
			break;
		}
	}
}

for(var i = 0; i < n-1; i++){
	if(a[i] != a[i+1]){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = arr[0]
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    while (res % 6 === 0 && res != 1) res /= 6;
    while (res % 2 === 0 && res != 1) res /= 2;
    while (res % 3 === 0 && res != 1) res /= 3;
    //console.log(res)
    for (let i of arr) {
        let two = 1,
            three = 1
        while (i % (two * 2) === 0) two *= 2;
        while (i % (three * 3) === 0) three *= 3;
        //console.log(res * two * three, i)
        if (res * two * three != i) {
            console.log("No")
            return 0
        }
    }
    console.log("Yes")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

var n = +readline(), arr = readline().split(" ").map(Number);
for(var i =0;i<n;i++)
{
    x = arr[i];
    while(x%2==0){x/=2;}
    while(x%3==0){x/=3;}
    arr[i]=x;
}
arr.sort();
if(arr[0]===arr[n-1])
{
    write('Yes');
}
else
{
    write('No');
}

// Generated by CoffeeScript 1.10.0
(function() {
  var a, gcd, n;

  n = parseInt(readline());

  a = readline().split(' ').map(function(item) {
    return parseInt(item);
  });

  gcd = null;

  (function() {
    var i, j, len, v;
    for (i = j = 0, len = a.length; j < len; i = ++j) {
      v = a[i];
      while (v % 2 === 0) {
        v /= 2;
      }
      while (v % 3 === 0) {
        v /= 3;
      }
      if (gcd == null) {
        gcd = v;
      } else if (gcd !== v) {
        print('No');
        return;
      }
    }
    return print('Yes');
  })();

}).call(this);

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const nok = (a, b) => a * b / gcd(a, b);

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = nok(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(res / i)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(i / res)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    while (res % 6 === 0 && res != 1) res /= 6;
    while (res % 2 === 0 && res != 1) res /= 2;
    while (res % 3 === 0 && res != 1) res /= 3;
    for (let i of arr) {
        let two = 1,
            three = 1
        while (i % (two * 2) === 0) two *= 2;
        while (i % (three * 3) === 0) three *= 3;
        if (res * two * three != i) {
            console.log("NO")
            return 0
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

for(i = 0; i < n; i++){
	if(a[i] == 1 || a[i] == 2 || a[i] == 3){
		a.splice(i,1);
	}
}

if(a.length == 0){
	write("Yes");
}
else if(a.length == 1){
	fact = factorization(a[0]);

	if(Object.keys(fact).length == 2){
		if(fact[2] == undefined && fact[3] == undefined){
			write("No");
		}
		else{
			write("Yes");
		}
	}
	else if(Object.keys(fact).length == 3){
		if(fact[2] && fact[3]){
			write("Yes");
		}
		else{
			write("Yes");
		}
	}
	else{
		write("No");
	}
}
else{
	nod = NOD(a);

	if(nod == 1){
		for(i = 0; i < a.length; i++){
			fact = factorization(a[i]);
			if(Object.keys(fact).length == 1){
				continue;
			}
			else if(Object.keys(fact).length == 2){
				if(fact[2] == undefined && fact[3] == undefined){
					write("No");
					check = false;
					break;
				}
				else{
					continue;
				}
			}
			else if(Object.keys(fact).length == 3){
				if(fact[2] && fact[3]){
					continue;
				}
				else{
					write("No");
					check = false;
					break;
				}
			}
			else{
				write("No");
				check = false;
				break;
			}
		}

		if(check){
			write("Yes");
		}
	}
	else{
		for(i = 0; i < a.length; i++){
			x = a[i] / nod;

			if(((x % 2) != 0) && ((x % 3) != 0)){
				write("No");
				check = false;
				break;
			}
		}

		if(check){
			write("Yes");
		}
	}
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true;

nod = NOD(a);

for(i = 0; i < n; i++){
	x = a[i] / nod;

	if(x == 1){
		continue;
	}

	if(((x % 2) != 0) && ((x % 3) != 0)){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		fact = factorization(a[i]);
		if(Object.keys(fact).length == 1){
			continue;
		}
		else if(Object.keys(fact).length == 2){
			if(fact[2] == undefined || fact[3] == undefined){
				write("No");
				check = false;
				break;
			}
			else{
				continue;
			}
		}
		else if(Object.keys(fact).length == 3){
			if(fact[2] && fact[3]){
				continue;
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
		else{
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true;

nod = NOD(a);

for(i = 0; i < n; i++){
	x = a[i] / nod;

	if(((x % 2) != 0) && ((x % 3) != 0)){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		fact = factorization(a[i]);
		if(Object.keys(fact).length == 1){
			continue;
		}
		else if(Object.keys(fact).length == 2){
			if(fact[2] == undefined && fact[3] == undefined){
				write("No");
				check = false;
				break;
			}
			else{
				continue;
			}
		}
		else if(Object.keys(fact).length == 3){
			if(fact[2] && fact[3]){
				continue;
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
		else{
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		if(a[i] == 2 || a[i] == 3){
			continue;
		}
		else{
			fact = factorization(a[i]);
			if(Object.keys(fact).length == 2){
				if(fact[2] == undefined || fact[3] == undefined){
					write("No");
					check = false;
					break;
				}
				else{
					continue;
				}
			}
			else if(Object.keys(fact).length == 3){
				if(fact[2] && fact[3]){
					continue;
				}
				else{
					write("No");
					check = false;
					break;
				}
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

var n = +readline(), a = readline().split(" ").map(Number);
var check = true;

for(var i = 0; i < n; i++){
	for(;;){
		if(a[i] % 2 == 0){
			a[i] /= 2;
		}
		else{
			break;
		}
	}

	for(;;){
		if(a[i] % 3 == 0){
			a[i] /= 3;
		}
		else{
			break;
		}
	}
}

for(var i = 0; i < n-1; i++){
	if(a[i] != a[i+1]){
		write("No");
		check = false;
	}
}

if(check){
	write("Yes");
}

// Generated by CoffeeScript 1.10.0
(function() {
  var a, gcd, n;

  n = parseInt(readline());

  a = readline().split(' ').map(function(item) {
    return parseInt(item);
  });

  gcd = null;

  (function() {
    var i, j, len, v;
    for (i = j = 0, len = a.length; j < len; i = ++j) {
      v = a[i];
      while (v % 2 === 0) {
        v /= 2;
      }
      while (v % 3 === 0) {
        v /= 3;
      }
      if (gcd == null) {
        gcd = v;
      } else if (gcd !== v) {
        print('No');
        return;
      }
      print(v);
    }
    return print('Yes');
  })();

}).call(this);


//var input = readline()
var t = readline()

var x = 0, y = 0
for(var i=0; i<t; i++) {
    var ar = readline().split(' ')
    var a = ar[0]
    var b = ar[1]
    x += parseInt(a)
    y += parseInt(b)
}
//print(x +' '+ y)

var x2 = 0, y2 = 0
for(var i=0; i<t; i++) {
    var arr = readline().split(' ')
    var c = arr[0]
    var d = arr[1]
    x2 += parseInt(c)
    y2 += parseInt(d)
}
//print(x2 +' '+ y2)

print((x+x2)/t  +' '+  (y+y2)/t)

const rl = require('readline')

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

let n, obelisks = [], clues = [], numLines = 0
readline.on('line', line => {
	if (numLines == 0) {
		n = parseInt(line)
	} else {
		const coordinate = line.split(' ').map(Number);
		[obelisks, clues][numLines > n ? 1 : 0].push({
			x: coordinate[0],
			y: coordinate[1]
		})
	}
	numLines++
}).on('close', () => {
	const p = obelisks.sort((a, b) => a.x - b.x || a.y - b.y).shift()
	const q = clues.sort((a, b) => b.x - a.x || b.y - a.y).shift()
	console.log(`${p.x + q.x} ${p.y + q.y}`)
})

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity:
// Space complexity:

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

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (numberOfObelisks) {
        const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
        if (isReadingObelisksCoordinates) {
            obelisksCoordinates.push(getCoordinate(input));
        } else {
            cluesCoordinates.push(getCoordinate(input));
        }
    } else {
        numberOfObelisks = parseInt(input);
    }

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x}, ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesDictionary = getCluesDictionary(cluesCoordinates);

    for (let clue of cluesCoordinates) {
        const firstObelisk = obelisksCoordinates[0];
        const treasure = firstObelisk.addCoordinate(clue);
        const treasureFound = treasureMatch(treasure, obelisksCoordinates, cluesDictionary);
        if (treasureFound) {
            return `${treasure.x} ${treasure.y}`;
        }
    }

    return "";
}

function treasureMatch(treasure, obelisksCoordinates, cluesDictionary) {
    for (let obelisk of obelisksCoordinates) {
        const x = treasure.x - obelisk.x;
        const y = treasure.y - obelisk.y;

        const possibleClue = new Coordinate(x, y);
        if (cluesDictionary[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

function getCluesDictionary(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

// console.log(findTreasure([new Coordinate(2, 5), new Coordinate(-6, 4)], [new Coordinate(7, -2), new Coordinate(-1, -3)]))

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity: O(n^2)
// Space complexity: O(n)

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

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (!numberOfObelisks) {
        numberOfObelisks = parseInt(input);
        return;
    }

    readCoordinates(input);

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function readCoordinates(input) {
    const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
    if (isReadingObelisksCoordinates) {
        obelisksCoordinates.push(getCoordinate(input));
    } else {
        cluesCoordinates.push(getCoordinate(input));
    }
}

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x} ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesIndexes = getCluesIndexes(cluesCoordinates);
    const firstObelisk = obelisksCoordinates[0];

    for (let clue of cluesCoordinates) {
        const treasureCoordinate = firstObelisk.addCoordinate(clue);
        const treasureFound = isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes);
        if (treasureFound) {
            return treasureCoordinate.toString();
        }
    }

    return "";
}

function getCluesIndexes(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

function isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes) {
    for (let obelisk of obelisksCoordinates) {
        // Check if there is a clue that points to the treasure for the current obelisk
        const x = treasureCoordinate.x - obelisk.x;
        const y = treasureCoordinate.y - obelisk.y;
        const possibleClue = new Coordinate(x, y);
        if (cluesIndexes[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity: O(n^2)
// Space complexity: O(n)

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

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (!numberOfObelisks) {
        numberOfObelisks = parseInt(input);
        return;
    }

    readCoordinates(input);

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function readCoordinates(input) {
    const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
    if (isReadingObelisksCoordinates) {
        obelisksCoordinates.push(getCoordinate(input));
    } else {
        cluesCoordinates.push(getCoordinate(input));
    }
}

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x} ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesIndexes = getCluesIndexes(cluesCoordinates);
    const firstObelisk = obelisksCoordinates.shift();

    for (let clue of cluesCoordinates) {
        const treasureCoordinate = firstObelisk.addCoordinate(clue);
        const treasureFound = isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes);
        if (treasureFound) {
            return treasureCoordinate.toString();
        }
    }

    return "";
}

function getCluesIndexes(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

function isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes) {
    for (let obelisk of obelisksCoordinates) {
        // Check if there is a clue that points to the treasure for the current obelisk
        const x = treasureCoordinate.x - obelisk.x;
        const y = treasureCoordinate.y - obelisk.y;
        const possibleClue = new Coordinate(x, y);
        if (cluesIndexes[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

//var input = readline()
var t = parseInt(readline());

var x = 0, y = 0;
for(var i=0; i<t*2; i++) {
    var ar = readline().split(' ').map(x => parseInt(x));
    var a = ar[0], b = ar[1];
    x += a , y += b;
}
print(x/t  +' '+  y/t);

//

//var input = readline()
var t = readline()

var x = 0, y = 0
for(var i=0; i<t*2; i++) {
    var ar = readline().split(' ')
    var a = ar[0]
    var b = ar[1]
    x += parseInt(a)
    y += parseInt(b)
}
print(x/t  +' '+  y/t)


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

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


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

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


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

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


;(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 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],
		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 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();