Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to attend the contest. Now she is solving the following problem. You are given four positive integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$, such that $$$a \leq b \leq c \leq d$$$. Your task is to find three integers $$$x$$$, $$$y$$$, $$$z$$$, satisfying the following conditions: $$$a \leq x \leq b$$$. $$$b \leq y \leq c$$$. $$$c \leq z \leq d$$$. There exists a triangle with a positive non-zero area and the lengths of its three sides are $$$x$$$, $$$y$$$, and $$$z$$$.Ichihime desires to get the cookie, but the problem seems too hard for her. Can you help her?

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$)  — the number of test cases. The next $$$t$$$ lines describe test cases. Each test case is given as four space-separated integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ ($$$1 \leq a \leq b \leq c \leq d \leq 10^9$$$).

For each test case, print three integers $$$x$$$, $$$y$$$, $$$z$$$  — the integers you found satisfying the conditions given in the statement. It is guaranteed that the answer always exists. If there are multiple answers, print any.

NoteOne of the possible solutions to the first test case:One of the possible solutions to the second test case:

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d, $e) = explode(" ", trim(fgets(STDIN)));
     print $c . " " . $d . " " . $d . "\n";
}
?>

<?php
//$stdin = fopen('input.txt', 'r');

for($t = intval(fgets(STDIN)); $t > 0; $t--){

	$a = explode(' ', fgets(STDIN));

	echo $a[1]. ' ' . $a[2]. ' '. $a[2] ."\n";

}

<?php

main();

function main() {
  $num_cases = trim(fgets(STDIN));

  for ($n = 1; $n <= $num_cases; $n++) {
    list($a, $b, $c, $d) = explode(" ", trim(fgets(STDIN)));
    $res = run_case($a, $b, $c, $d);

    print join(" ", $res) . "\n";
  }
}

function run_case($a, $b, $c, $d) {
	return [$b, max(min($c - $b + 1, $c), $b), $c];
}

?>

<?php
    define("MAXN", 1024) ;
    define("GAP_VAL", 1e-7) ;

    function gap($n)
    {
        return $n < GAP_VAL ;
    }

    $t = intval(trim(fgets(STDIN))) ;
    while($t --)
    {
        $in_str = explode(" ", trim(fgets(STDIN))) ;

        echo implode(" ", array($in_str[1], $in_str[2], $in_str[2])) . "\n" ;
    }
?>


A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.

The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.

Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.

<?php
list($n,$m)=explode(' ',rtrim(fgets(STDIN)));
$min_x=$min_y=100;
$max_x=$max_y=-1;
$letter=array();
for ($i=0;$i<$n;$i++) {
  $line=rtrim(fgets(STDIN));
  $letter[]=$line;
  for ($j=0;$j<$m;$j++) {
    if ($line[$j]=='*') {
      $min_x=min($min_x,$j);
      $min_y=min($min_y,$i);
      $max_x=max($max_x,$j);
      $max_y=max($max_y,$i);
    }
  }
}
for ($i=$min_y;$i<=$max_y;$i++) {
  for ($j=$min_x;$j<=$max_x;$j++) {
    echo $letter[$i][$j];
  }
  echo "\n";
}
?>

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
$leftJ = -1;
$rightI = 0;
$leftI = -1;
$rightJ = 0;
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){

			$cols[$i]++;
			$rows[$j]++;

			$rightJ = max($rightJ, $j);
			$rightI = max($rightI, $i);
			if ($leftJ < 0)
				$leftJ = $j;
			if ($leftI < 0)
				$leftI = $i;
			$leftI = min($leftI, $i);
			$leftJ = min($leftJ, $j);

		}
	}
}
if ($leftJ < 0)
	return;
if ($leftI < 0)
	return;
for($j = $leftJ;$j<=$rightJ;$j++){
	echo substr($lines[$j], $leftI, $rightI-$leftI+1) . "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){

			$cols[$i]++;
			$rows[$j]++;
		}
	}
}
$j=0;
$i=0;
$iLeft = 0;
$jLeft = 0;
for($i=0;$i<$x && !isset($cols[$i]);$i++);

for($iLeft=$x;$iLeft>0 && !isset($cols[$iLeft]);$iLeft--);
$iLeft++;
$iLeft = $iLeft-$i;

for($j=0;$j<$y && !isset($rows[$j]);$j++);
for($jLeft=$y;$jLeft>0 && !isset($rows[$jLeft]);$jLeft--);
$jLeft;
for(;$j<=$jLeft;$j++){
	echo substr($lines[$j], $i, $iLeft) . "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){
			if (!isset($cols[$i]))
				$cols[$i] = 0;
			if (!isset($rows[$j]))
				$rows[$j] = 0;
			$cols[$i]++;
			$rows[$j]++;
		}
	}
}
$j=0;
$i=0;
$iLeft = 0;
$jLeft = 0;
for($i=0;$i<$x && !isset($cols[$i]);$i++);

for($iLeft=$x;$iLeft>0 && !isset($cols[$iLeft]);$iLeft--);
$iLeft++;
if ($i == $iLeft)
	$iLeft = 1;
else
	$iLeft = $iLeft-$i;

for($j=0;$j<$y && !isset($rows[$j]);$j++);
for($jLeft=$y;$jLeft>0 && !isset($rows[$jLeft]);$jLeft--);
$jLeft;
for(;$j<=$jLeft;$j++){
	echo substr($lines[$j], $i, $iLeft) . "\n";
}

<?php

$in = 'php://stdin';
//$in = 'input.txt';

$arr = file($in);
//$data = file_get_contents($in);
//$r = fopen($in, 'r');
list($n, $m) = explode(' ', array_shift($arr));

while (!$arr[count($arr) - 1]) {
	array_pop($arr);
}

foreach ($arr as $k1 => &$valf) {
	$valf = trim($valf);
	$valf = str_split($valf);
	foreach ($valf as $k => $a) {
		$arr2[$k][$k1] = $a;
	}

}
foreach ($arr as $k => $val) {
	if (in_array('*', $val)) {
		$minx = isset($minx) ? $minx : $k;
		$maxx = $k;
	}
}

foreach ($arr2 as $k => $val) {
	if (in_array('*', $val)) {
		$miny = isset($miny) ? $miny : $k;
		$maxy = $k;
	}
}

for ($i = $minx; $i <= $maxx; $i++) {
	for ($j = $miny; $j <= $maxy; $j++) {
		echo $arr[$i][$j];
	}
	echo "\n";
}

<?php
function emptyColumn($j) {
	global $n, $s;
	for ($i = 0; $i < $n; $i++)
		if ($s[$i][$j] == '*')
			return false;
	return true;
}
function emptyRow($i) {
	global $m, $s;
	for ($j = 0; $j < $m; $j++)
		if ($s[$i][$j] == '*')
			return false;
	return true;
}

fscanf(STDIN, "%d %d", $n, $m);
$s = array();
for ($i = 0; $i < $n; $i++)
	$s[$i] = fgets(STDIN);
$li = 0; $ri = $n - 1;
$lj = 0; $rj = $m - 1;
while (emptyRow($li)) $li++;
while (emptyRow($ri)) $ri--;
while (emptyColumn($lj)) $lj++;
while (emptyColumn($rj)) $rj--;
for ($i = $li; $i <= $ri; $i++)
	print(substr($s[$i], $lj, $rj - $lj + 1)."\n")
?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

$entries = array();
for ($i = 0; $i < $data[0]; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    $emptyRow = true;
        for ($i = 0; $i < strlen($value); $i++) {
            if ($value[$i] != 'x') {
            $emptyRow = false;
            echo($value[$i]);
            }
        }
    if (!$emptyRow) echo "\n";
}

/*
foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
        else next($entries);
    }
    echo "\n";
}
*/

?>

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
    fgetc(STDIN);
}
for ($i = $upper; $i <= $bottom; $i++) {
    for ($j = 0; $j < $m; $j++) {
        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
        }
    }
    if ($i != $bottom) {
        echo "\n";
    }
}

<?php
function cut($letter) {
  $h=count($letter);
  $w=count($letter[0]);
  $blank=true;
  for ($i=0;$i<$h;$i++) {
    for ($j=0;$j<$w;$j++) {
      if ($letter[$i][$j]=='*') {
        $blank=false;
        break;
      }
    }
    if (! $blank) {
      $letter = array_slice($letter,$i);
      break;
    }
  }
  return $letter;
}

function rotate($letter) {
  $h=count($letter);
  $w=count($letter[0]);
  $new_letter=array();
  for ($i=0;$i<$w;$i++) $new_letter[]=array();
  for ($i=0;$i<$h;$i++) {
    for ($j=0;$j<$w;$j++) {
      $new_letter[$j][$h-$i-1]=$letter[$i][$j];
    }
  }
  return $new_letter;
}

list($n,$m)=explode(' ',rtrim(fgets(STDIN)));
$letter = array();
for ($i=0;$i<$n;$i++) {
  $line = rtrim(fgets(STDIN));
  $letter[$i]=array();
  for ($j=0;$j<strlen($line);$j++) {
    $letter[$i][]=$line[$j];
  }
}

$letter=cut($letter);
$letter=rotate($letter);
$letter=cut($letter);
$letter=rotate($letter);
$letter=cut($letter);
$letter=rotate($letter);
$letter=cut($letter);
$letter=rotate($letter);

for ($i=0;$i<count($letter);$i++) {
  for ($j=0;$j<count($letter[0]);$j++) {
    echo $letter[$i][$j];
  }
  echo "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
for($j=0;$j<$y;$j++){
	$line = trim(fgets(STDIN));
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){
			$cols[$i]++;
			$rows[$j]++;
		}
	}
}
$j=0;
$i=0;
$iLeft = 0;
for($i=0;$i<$x && !isset($cols[$i]);$i++);

for($iLeft=$x;$iLeft>0 && !isset($cols[$iLeft]);$iLeft--);
$iLeft++;
$iLeft = $iLeft-$i;

for($j=0;$j<$y && !isset($rows[$j]);$j++);
for(;$j<=$y && isset($rows[$j]);$j++){
	echo substr($lines[$j], $i, $iLeft) . "\n";
}

//var_dump($lines);
//var_dump($cols);
//var_dump($rows);

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
$leftJ = -1;
$rightI = 0;
$leftI = -1;
$rightJ = 0;
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){

			$cols[$i]++;
			$rows[$j]++;
			$rightJ = $j;
			$rightI = $i;
			if ($leftJ < 0)
				$leftJ = $j;
			if ($leftI < 0)
				$leftI = $i;

		}
	}
}
if ($leftJ < 0)
	return;
if ($leftI < 0)
	return;

for($j = $leftJ;$j<$rightJ;$j++){
	echo substr($lines[$j], $leftI, $rightI-$leftI+1) . "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){
			if (!isset($cols[$i]))
				$cols[$i] = 0;
			if (!isset($rows[$j]))
				$rows[$j] = 0;
			$cols[$i]++;
			$rows[$j]++;
		}
	}
}
$j=0;
$i=0;
$iLeft = 0;
$jLeft = 0;
for($i=0;$i<$x && !isset($cols[$i]);$i++);

for($iLeft=$x;$iLeft>0 && !isset($cols[$iLeft]);$iLeft--);
$iLeft++;
$iLeft = $iLeft-$i;

for($j=0;$j<$y && !isset($rows[$j]);$j++);
for($jLeft=$y;$jLeft>0 && !isset($rows[$jLeft]);$jLeft--);
$jLeft++;
$jLeft = $jLeft-$j;
for(;$j<=$jLeft-1;$j++){
	echo substr($lines[$j], $i, $iLeft) . "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
var_dump($line);
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
for($j=0;$j<$y;$j++){
	$line = trim(fgets(STDIN));
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){
			$cols[$i]++;
			$rows[$j]++;
		}
	}
}
$j=0;
$i=0;
$iLeft = 0;
for($i=0;$i<$x && !isset($cols[$i]);$i++);
for($iLeft=$x;$iLeft>0 && !isset($cols[$iLeft]);$iLeft--);
$iLeft = $x-$iLeft;
for($j=0;$j<$y && !isset($rows[$j]);$j++);
for(;$j<$y && isset($rows[$j]);$j++){
	echo substr($lines[$j], $i, $iLeft) . "\n";
}

var_dump($lines);

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
$leftJ = -1;
$rightI = 0;
$leftI = -1;
$rightJ = 0;
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){

			$cols[$i]++;
			$rows[$j]++;
			$rightJ = $j;
			$rightI = $i;
			if ($leftJ < 0)
				$leftJ = $j;
			if ($leftI < 0)
				$leftI = $i;

		}
	}
}
if ($leftJ < 0)
	return;
if ($leftI < 0)
	return;

for($j = $leftJ;$j<=$rightJ;$j++){
	echo substr($lines[$j], $leftI, $rightI-$leftI+1) . "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
$leftJ = -1;
$rightI = 0;
$leftI = -1;
$rightJ = 0;
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){

			$cols[$i]++;
			$rows[$j]++;

			$rightJ = max($rightJ, $j);
			$rightI = max($rightI, $i);
			if ($leftJ < 0)
				$leftJ = $j;
			if ($leftI < 0)
				$leftI = $i;
			$leftI = min($leftI, $i);
			$leftJ = min($leftJ, $j);

		}
	}
}
if ($leftJ < 0)
	return;
if ($leftI < 0)
	return;
echo "$leftI $rightI, $leftJ $rightJ\n";
for($j = $leftJ;$j<=$rightJ;$j++){
	echo substr($lines[$j], $leftI, $rightI-$leftI+1) . "\n";
}

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
for($j=0;$j<$y;$j++){
	$line = trim(fgets(STDIN));
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){
			$cols[$i]++;
			$rows[$j]++;
		}
	}
}
$j=0;
$i=0;
$iLeft = 0;
$jLeft = 0;
for($i=0;$i<$x && !isset($cols[$i]);$i++);

for($iLeft=$x;$iLeft>0 && !isset($cols[$iLeft]);$iLeft--);
$iLeft++;
$iLeft = $iLeft-$i;

for($j=0;$j<$y && !isset($rows[$j]);$j++);
for($jLeft=$y;$jLeft>0 && !isset($rows[$jLeft]);$jLeft--);
$jLeft++;
$jLeft = $jLeft-$j;
for(;$j<=$jLeft;$j++){
	if (isset($rows[$j]))
		echo substr($lines[$j], $i, $iLeft) . "\n";
}

//var_dump($lines);
//var_dump($cols);
//var_dump($rows);

<?

$line = trim(fgets(STDIN)); // reads one line from STDIN
list($y,$x) = explode(' ', $line);
$arr = array();

$cols = array();
$rows = array();
$lines = array();
$leftJ = -1;
$rightJ = 0;
$leftI = -1;
$rightJ = 0;
for($j=0;$j<$y;$j++){
	$line = fgets(STDIN);
	$lines[] = $line;
	for($i=0;$i<$x;$i++){
		if ($line[$i] == '*'){

			$cols[$i]++;
			$rows[$j]++;
			$rightJ = $j;
			$rightI = $i;
			if ($leftJ < 0)
				$leftJ = $j;
			if ($leftI < 0)
				$leftI = $i;

		}
	}
}
for($j = $leftJ;$j<=$rightJ;$j++){
	echo substr($lines[$j], $leftI, $rightI-$leftI+1) . "\n";
}

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1] - 1; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    unset($array[$row]);
/*
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
*/
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

/*
foreach ($entries as $value) {
    $emptyRow = true;
        for ($i = 0; $i < strlen($value); $i++) {
            if ($value[$i] != 'x') {
            $emptyRow = false;
            echo($value[$i]);
            }
        }
    if (!$emptyRow) echo "\n";
}
*/

foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
        else next($entries);
    }
    echo "\n";
}

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1] - 1; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    unset($array[$row]);
/*
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
*/
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
 $emptyRow = true;
 for ($i = 0; $i < strlen($value); $i++) {
  if ($value[$i] != 'x') {$emptyRow = false; echo($value[$i]);}
 }
 if (!$emptyRow) echo "\n";
}

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1]; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
    }
    echo "\n";
}
//

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1]; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
    }
    echo "\n";
}

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1] - 1; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    unset($array[$row]);
/*
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
*/
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
    }
    echo "\n";
}

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1] - 1; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
    }
    echo "\n";
}

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1] - 1; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    $emptyRow = true;
        for ($i = 0; $i < strlen($value); $i++) {
            if ($value[$i] != 'x') {
            $emptyRow = false;
            echo($value[$i]);
            }
        }
    if (!$emptyRow) echo "\n";
}

/*
foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
        else next($entries);
    }
    echo "\n";
}
*/

?>

<?php

$line = trim(fgets(STDIN));
$data = explode(" ", $line);

for ($i = 0; $i < $data[1]; $i++) {
    $entries[] = trim(fgets(STDIN));
}

$rows = $data[0];
$cols = $data[1];

function check_if_empty_row($array, $row) {
    if (strpos($array[$row], '*') === false) return true;
    else return false;
}

function check_if_empty_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        if ($array[$i][$col] != '.') return false;
    }
    return true;
}

function delete_col($array, $col) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = substr_replace($array[$i], 'x', $col, 1);
    }
    return $array;
}

function delete_row($array, $row) {
    $length = strlen($array[$row]);
    $array[$row] = '';
        for ($i = 0; $i < $length; $i++) {
            $array[$row] .= 'x';
        }
    return $array;
}

for ($i = 0; $i < $cols; $i++) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = $cols - 1; $i >= 0; $i--) {
    if (check_if_empty_col($entries, $i)) $entries = delete_col($entries, $i);
    else break;
}

for ($i = 0; $i < $rows; $i++) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

for ($i = $rows - 1; $i >= 0; $i--) {
    if (check_if_empty_row($entries, $i)) $entries = delete_row($entries, $i);
    else break;
}

foreach ($entries as $value) {
    for ($i = 0; $i < strlen($value); $i++) {
        if ($value[$i] != 'x') print_r($value[$i]);
    }
    echo "\n";
}
print_r($entries);

?>

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
    fgetc(STDIN);
}
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
        }
        if ($j == $m - 1) {
            echo "\n";
        }
    }
}

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
}
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
        }
        if ($j == $m - 1) {
            echo "\n";
        }
    }
}

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
    fgetc(STDIN);
}
for ($i = $upper; $i <= $bottom; $i++) {
    for ($j = 0; $j < $m; $j++) {
        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
        }
    }
}

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
//    fgetc(STDIN);
}
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
        }
        if ($j == $m - 1) {
            echo "\n";
        }
    }
}

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
}
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
        }
    }
    echo "\n";
}

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
}
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
//        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
            echo $pixels[$i][$j];
//        }
        if ($j == $m - 1) {
            echo "\n";
        }
    }
}

<?php
$input = fscanf(STDIN, '%d%d');
$n = $input[0];
$m = $input[1];
$upper = $n;
$bottom = 0;
$left = $m;
$right = 0;
$pixels = array();
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $m; $j++) {
        $pixel = fgetc(STDIN);
        $pixels[$i][$j] = $pixel;
        if ($pixel == '*') {
            if ($left > $j) {
                $left = $j;
            }
            if ($right < $j) {
                $right = $j;
            }
            if ($upper > $i) {
                $upper = $i;
            }
            if ($bottom < $i) {
                $bottom = $i;
            }
        }
    }
    fgetc(STDIN);
}
//for ($i = 0; $i < $n; $i++) {
//    for ($j = 0; $j < $m; $j++) {
//        if ($i <= $bottom && $i >= $upper && $j <= $right && $j >= $left) {
//            echo $pixels[$i][$j];
//        }
//        if ($j == $m - 1) {
//            echo "\n";
//        }
//    }
//}

print_r($pixels);


Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has $$$a$$$ coins, Barbara has $$$b$$$ coins and Cerene has $$$c$$$ coins. Recently Polycarp has returned from the trip around the world and brought $$$n$$$ coins.He wants to distribute all these $$$n$$$ coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives $$$A$$$ coins to Alice, $$$B$$$ coins to Barbara and $$$C$$$ coins to Cerene ($$$A+B+C=n$$$), then $$$a + A = b + B = c + C$$$.Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.Your task is to find out if it is possible to distribute all $$$n$$$ coins between sisters in a way described above.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The next $$$t$$$ lines describe test cases. Each test case is given on a new line and consists of four space-separated integers $$$a, b, c$$$ and $$$n$$$ ($$$1 \le a, b, c, n \le 10^8$$$) — the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.

For each test case, print "YES" if Polycarp can distribute all $$$n$$$ coins between his sisters and "NO" otherwise.

<?php

// your code goes here
function sistersdivide($polycrap,$sisters){
sort($sisters);
$rest = 0;
$arraysize = count($sisters);
  for($i = $arraysize - 1; $i >= 0; $i--){

      $rest +=  max($sisters) - $sisters[$i];

  }
  if(($polycrap - $rest) % $arraysize == 0 && ($polycrap - $rest) >= 0){
    return "YES\n";
  }else {
    return "NO\n";
  }
}
fscanf(STDIN, "%d\n", $size);
for($i = 0; $i < $size; $i++){
   $cases = fgets(STDIN);
    $x = array_map('intval', preg_split('/ /', $cases, -1, PREG_SPLIT_NO_EMPTY));
    $polycrap = $x[count($x)-1];
    unset($x[count($x)-1]);
    $sisters = $x;
    $results = sistersdivide($polycrap,$sisters);
    echo $results;
}

<?php
$t = trim(fgets(STDIN));

for ($i = 0; $i < $t; $i++) {
    $aR = explode(' ', trim(fgets((STDIN))));
    $a = $aR[0];
    $b = $aR[1];
    $c = $aR[2];
    $n = $aR[3];
    unset($aR[3]);
    $max = max($aR);

    $k  = bcsub($n, (bcsub(bcmul(2, $max), (bcsub(bcadd(bcadd($a, $b) , $c) , $max)))));
    if ($k >= 0 && bcmod($k, 3) ==0) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }

}
?>

<?php
    $t = trim(fgets(STDIN));
    for($i=0; $i<$t; $i++) {
        list($a, $b, $c, $n) = explode(' ', trim(fgets(STDIN)));

        if(($a + $b + $c +$n ) % 3 == 0) {
            echo "YES\n";
        }else {
            echo "NO\n";
        }

    }

<?php
$t = trim(fgets(STDIN));

for ($i = 0; $i < $t; $i++) {
    $aR = explode(' ', trim(fgets((STDIN))));
    $a = $aR[0];
    $b = $aR[1];
    $c = $aR[2];
    $n = $aR[3];
    unset($aR[3]);
    $max = max($aR);

    $k  = bcsub($n, (bcsub(bcmul(2, $max), (bcsub(bcadd(bcadd($a, $b) , $c) , $max)))));
    if (bcmod($k, 3) ==0) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }

}
?>

<?php
$i = trim(fgets(STDIN));

for($j = 0; $j < $i; $j++){
    $k = trim(fgets(STDIN));
    $a = array();
    for($m = 0; $m < $k; $m++){
        $d = explode(" ", trim(fgets(STDIN)));
        $a[$d[0]][] = $d[1];
    }
    ksort($a);
    $x = 0;
    $y = 0;
    $res = '';
    foreach($a as $key => $val){
        sort($val);
        if($key >= $x){
            for($t = 0; $t < $key - $x; $t++){
                    $res .= 'R';
                }
            $x = $key;
        } else {
            echo "NO\n";
            continue 2;
        }
        foreach($val as $v){
            if($v >= $y){
                for($t = 0; $t < $v - $y; $t++){
                    $res .= 'U';
                }
                $y = $v;
            } else {
                echo "NO\n";
                continue 3;
            }
        }

    }
    echo "YES\n";
    echo $res."\n";

}


You have integer $$$n$$$. Calculate how many ways are there to fully cover belt-like area of $$$4n-2$$$ triangles with diamond shapes. Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. $$$2$$$ coverings are different if some $$$2$$$ triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.Please look at pictures below for better understanding.  On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill. These are the figures of the area you want to fill for $$$n = 1, 2, 3, 4$$$. You have to answer $$$t$$$ independent test cases.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$) — the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$).

For each test case, print the number of ways to fully cover belt-like area of $$$4n-2$$$ triangles using diamond shape. It can be shown that under given constraints this number of ways doesn't exceed $$$10^{18}$$$.

NoteIn the first test case, there are the following $$$2$$$ ways to fill the area:  In the second test case, there is a unique way to fill the area:

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     print trim(fgets(STDIN)) . "\n";
}
?>

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --){
    //print pow(2, intval(fgets(STDIN)) - 1)."\n";
    print intval(fgets(STDIN))."\n";
}

<?php
    define("MAXN", 200001) ;

    function solve($n, $k)
    {
    }

    $T = intval(fgets(STDIN));
    while($T --)
    {
        $n = intval(fgets(STDIN)) ;

        echo $n . "\n" ;
    }
?>

<?php
$in = fopen("php://stdin", "r"); //or simply $in = STDIN;
$t = trim(fgets($in));

for($i = 0;$i <$t; $i++)
{
    $n = trim(fgets($in));
    print $n."\n";
}
?>

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --){
    print pow(2, intval(fgets(STDIN)) - 1)."\n";
}

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --){
    //print pow(2, intval(fgets(STDIN)) - 1)."\n";
    print intval(fgets(STDIN))."/n";
}


You are given an array $$$a$$$ of length $$$n$$$, and an integer $$$x$$$. You can perform the following operation as many times as you would like (possibly zero): replace two adjacent elements of the array by their sum. For example, if the initial array was $$$[3, 6, 9]$$$, in a single operation one can replace the last two elements by their sum, yielding an array $$$[3, 15]$$$, or replace the first two elements to get an array $$$[9, 9]$$$. Note that the size of the array decreases after each operation.The beauty of an array $$$b=[b_1, \ldots, b_k]$$$ is defined as $$$\sum_{i=1}^k \left\lceil \frac{b_i}{x} \right\rceil$$$, which means that we divide each element by $$$x$$$, round it up to the nearest integer, and sum up the resulting values. For example, if $$$x = 3$$$, and the array is $$$[4, 11, 6]$$$, the beauty of the array is equal to $$$\left\lceil \frac{4}{3} \right\rceil + \left\lceil \frac{11}{3} \right\rceil + \left\lceil \frac{6}{3} \right\rceil = 2 + 4 + 2 = 8$$$.Please determine the minimum and the maximum beauty you can get by performing some operations on the original array.

The first input line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 1000$$$). The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \leq n \leq 10^5$$$, $$$1 \leq x \leq 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$), the elements of the array $$$a$$$.  It is guaranteed that the sum of values of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case output two integers — the minimal and the maximal possible beauty.

NoteIn the first test case the beauty of the array does not change if we perform any operations.In the second example we can leave the array unchanged to attain the maximum beauty, and to get the minimum beauty one can replace two elements $$$4$$$ and $$$11$$$ with their sum, yielding an array $$$[6, 15]$$$, which has its beauty equal to $$$7$$$.

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $x) {
    $sum = 0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function getSum($array, $n) {
    $sum = 0;

    for ($k=0; $k<$n; $k++) {
        $sum += $array[$k];
    }

    return $sum;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    printf("%0.0f", getArrayBeauty([getSum($array, $n)], $x));
    echo " ";
    printf("%0.0f", getArrayBeauty($array, $x));
    echo "\n";
}

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));
for ($i = 0; $i < $t; $i++) {
  list($n, $x) = explode(" ", trim(fgets($file)));
  $a = explode(" ", trim(fgets($file)));
  $m = 0; $k = 0;

  for ($j = 0; $j < $n; $j++) {
    $m += ceil($a[$j] / $x);
    $k += $a[$j];
  }
  $k = ceil($k / $x);
  $min = min($m, $k);
  $max = max($m, $k);
  printf('%0.0f',$min);
  echo ' ';
  printf('%0.0f',$max);
  echo PHP_EOL;
}
?>

<?php
function solve() {
    list($n, $x) = explode(' ', Read::string());
    $a = Read::array_int();
    $min = 0;
    $max = 0;
    for ($i = 0; $i < $n; $i++) {
        $min = Bigint::add($min, $a[$i]);
        $max = Bigint::add($max, Bigint::div($a[$i], $x, 'ceil'));
    }

    echo Bigint::div($min, $x, 'ceil')." ".$max;
}

#$t = 1;
$t = Read::int();
while ($t--) {
    solve();
    echo "\n";
}

class Read
{
    public static function string()
    {
        return trim(fgets(STDIN));
    }

    public static function int()
    {
        return intval(fgets(STDIN));
    }

    public static function array_int($sep = ' ')
    {
        $s = trim(fgets(STDIN));
        return preg_split("/[\s,]+/", $s);
    }

}

class Bigint
{
    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 / $bigint2
     */
    public static function div($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);
            case 'floor':
                return bcdiv($bigint1, $bigint2);
            case 'round':
                $sResult = bcdiv($bigint1, $bigint2);
                return bcsub(bcdiv($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcdiv($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 + $bigint2
     */
    public static function add($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcadd($bigint1, $bigint2);
            case 'round':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcadd($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 - $bigint2
     */
    public static function bigintSub($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcsub($bigint1, $bigint2);
            case 'round':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsub($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 * $bigint2
     */
    public static function mul($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcmul($bigint1, $bigint2);
            case 'round':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcmul ($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @return string $bigint1 % $bigint2
     */
    public static function mod($bigint1, $bigint2) {
        return bcmod($bigint1, $bigint2);
    }

    /**
     * @param string $bigint
     * @param string $scale (ceil or floor or round)
     * @return string sqrt($bigint)
     */
    public static function sqrt($bigint, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcadd(bcsqrt ($bigint), 1);
            case 'floor':
                return bcsqrt($bigint);
            case 'round':
                $sResult = bcsqrt($bigint);
                return bcsub(bcsqrt($bigint, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsqrt($bigint);
        }
    }

    /**
     * @param string $bigint
     * @param string $exponent
     * @param string $scale (ceil or floor or round)
     * @return string pow($bigint, $exponent)
     */
    public static function pow($bigint, $exponent, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcpow($bigint, $exponent);
            case 'round':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcpow ($bigint, $exponent);
        }
    }
}

?>

<?php
function solve() {
    $s1 = trim(fgets(STDIN));
    list($n, $x) = explode(' ', $s1);
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $min = 0;
    $max = 0;
    for ($i = 0; $i < $n; $i++) {
        $min = bigintAdd($min, $a[$i]);
        $max = bigintAdd($max, bigintDiv($a[$i], $x, 'ceil'));
    }

    echo bigintDiv($min, $x, 'ceil')." ".$max;
}

function bigintDiv($sBigint1, $sBigint2, $sCale = '') {
    switch ($sCale) {
        case 'ceil':
            return bcmod($sBigint1, $sBigint2) == 0 ? bcdiv($sBigint1, $sBigint2) : bcadd(bcdiv($sBigint1, $sBigint2), 1);
        case 'floor':
            return bcdiv($sBigint1, $sBigint2);
        case 'round':
            $sResult = bcdiv($sBigint1, $sBigint2);
            return bcsub(bcdiv($sBigint1, $sBigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
        default:
            return bcdiv($sBigint1, $sBigint2);
    }
}

function bigintAdd($sBigint1, $sBigint2, $sCale = '') {
    switch ($sCale) {
        case 'ceil':
            return bcadd(bcadd($sBigint1, $sBigint2), 1);
        case 'floor':
            return bcadd($sBigint1, $sBigint2);
        case 'round':
            $sResult = bcadd($sBigint1, $sBigint2);
            return bcsub(bcadd($sBigint1, $sBigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
        default:
            return bcadd($sBigint1, $sBigint2);
    }
}

$t = trim(fgets(STDIN));
while ($t--) {
    solve();
    echo "\n";
}
?>

<?php

$t = (int) trim(fgets(STDIN));
for ($i = 0; $i < $t; ++$i) {
    //i[]
    list($ni[], $xi[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $ai[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($i = 0; $i < $t; ++$i) {
    $n = $ni[$i];
    $x = $xi[$i];
    $a = $ai[$i];
    $sum = 0;
    foreach ($a as $v) {
        $sum += ceil($v / $x);
    }
    echo nf(ceil(array_sum($a) / $x)).' '.nf($sum).PHP_EOL;
}
function nf($n)
{
    return number_format($n, 0, '', '');
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getNumbersSum($string1, $string2)
{
    $string1 = trim($string1);
    $string2 = trim($string2);

    $baseArray    = array_fill(0, 28, 0);
    $numberArray1 = array_reverse(str_split($string1));
    $numberArray2 = array_reverse(str_split($string2));

    $count1 = count($numberArray1);
    $count2 = count($numberArray2);

    $maxCount = $count1 >= $count2 ? $count1 : $count2;

    for ($i=0; $i<$count1; $i++) {
        $baseArray[$i] += $numberArray1[$i];
    }

    $memory = 0;
    for ($i=0; $i<$count2; $i++) {
        $elementsSum   = $baseArray[$i] + $numberArray2[$i];
        $elementsSum   += $memory;
        $baseArray[$i] = ($elementsSum)%10;
        $memory        = floor($elementsSum/10);
    }

    while ($memory > 0) {
        $elementsSum   = $baseArray[$i] + $memory;
        $baseArray[$i] = ($elementsSum)%10;
        $memory        = round($elementsSum/10);
        $i++;
    }

    $digitsCount = ($i >= $maxCount) ? $i : $maxCount;

    $resultArray = array_slice($baseArray, 0, $digitsCount);
    $resultArray = array_reverse($resultArray);

    return implode($resultArray);
}

function getArrayBeauty($array, $x) {
    $sum = "0";

    foreach($array as $element) {
        $sum = getNumbersSum($sum, ceil($element / $x));
    }

    return $sum;
}

function getSum($array, $n) {
    $sum = "0";

    for ($k=0; $k<$n; $k++) {
        $sum = getNumbersSum($sum, $array[$k]);
    }

    return $sum;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty([getSum($array, $n)], $x);
    echo " ";
    echo getArrayBeauty($array, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $x) {
    $sum = (float) 0.0;

    foreach($array as $element) {
        $sum += (float) ceil($element / $x);
    }

    return $sum;
}

function getSum($array, $n) {
    $sum = (float) 0.0;

    for ($k=0; $k<$n; $k++) {
        $sum += (float) $array[$k];
    }

    return $sum;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty([getSum($array, $n)], $x);
    echo " ";
    echo getArrayBeauty($array, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $x) {
    $sum = (float) 0.0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function getSum($array, $n) {
    $sum = (float) 0.0;

    for ($k=0; $k<$n; $k++) {
        $sum += $array[$k];
    }

    return $sum;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty([getSum($array, $n)], $x);
    echo " ";
    echo getArrayBeauty($array, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $x) {
    $sum = 0.0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function getSum($array, $n) {
    $sum = 0.0;

    for ($k=0; $k<$n; $k++) {
        $sum += $array[$k];
    }

    return $sum;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty([getSum($array, $n)], $x);
    echo " ";
    echo getArrayBeauty($array, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $x) {
    $sum = 0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function getSum($array, $n) {
    $sum = 0;

    for ($k=0; $k<$n; $k++) {
        $sum += $array[$k];
    }

    return $sum;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty([getSum($array, $n)], $x);
    echo " ";
    echo getArrayBeauty($array, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        // if ($n == 9) {
        //     var_dump($element / $x, ceil($element / $x));
        // }
        $sum += ceil($element / $x);
    }

    // if ($n == 9) {
    //     var_dump("sum ", $sum); exit;
    // }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    // if ($n == 9) {
    //     var_dump($array);
    // }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        // if ($n == 9) {
        //     var_dump($element / $x, ceil($element / $x));
        // }
        $sum += ceil($element / $x);
    }

    if ($n == 9) {
        var_dump("sum ", $sum); exit;
    }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    // if ($n == 9) {
    //     var_dump($array);
    // }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        if ($n == 9) {
            var_dump($element / $x, ceil($element / $x));
        }
        $sum += ceil($element / $x);
    }

    if ($n == 9) {
        var_dump("sum ", $sum);
    }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    // if ($n == 9) {
    //     var_dump($array);
    // }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        if ($n == 9) {
            var_dump($element / $x, ceil($element / $x));
        }
        $sum += ceil($element / $x);
    }

    var_dump("sum ", $sum);

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    // if ($n == 9) {
    //     var_dump($array);
    // }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        if ($n == 9) {
            var_dump($element / $x, ceil($element / $x));
        }
        $sum += ceil($element / $x);
    }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    // if ($n == 9) {
    //     var_dump($array);
    // }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    if ($n == 9) {
        var_dump($array); exit;
    }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php
// ???
$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php

$file = fopen("php://stdin", "r");

$rowsNumber = fgets($file);

function getArrayBeauty($array, $n, $x) {
    $sum = 0;

    foreach($array as $element) {
        $sum += ceil($element / $x);
    }

    return $sum;
}

function isMultipleOfThree($number) {
    return $number%3 === 0;
}

function minimizeArray($array, $n) {
    if ($n == 1) {
        return $array;
    }

    for ($k=0; $k<$n-1; $k++) {
        if (isMultipleOfThree($array[$k]) || isMultipleOfThree($array[$k+1])) {
            continue;
        }

        $array[$k] = $array[$k] + $array[$k+1];
        unset($array[$k+1]);
        $array = array_values($array);
        $k = 0;
    }

    return $array;
}

for ($i=0; $i<$rowsNumber; $i++) {
    list($n, $x) = explode(' ', fgets($file));
    $array       = explode(' ', fgets($file));

    echo getArrayBeauty(minimizeArray($array, $n), $n, $x);
    echo " ";
    echo getArrayBeauty($array, $n, $x);
    echo "\n";
}

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));
for ($i = 0; $i < $t; $i++) {
  list($n, $x) = explode(" ", trim(fgets($file)));
  $a = explode(" ", trim(fgets($file)));
  $m = 0; $k = 0;

  for ($j = 0; $j < $n; $j++) {
    $m += ceil($a[$j] / $x);
    $k += $a[$j];
  }
  $k = ceil($k / $x);
  $min = min($m, $k);
  $max = max($m, $k);
  echo $min.' '.$max.PHP_EOL;
}
?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));
for ($i = 0; $i < $t; $i++) {
  list($n, $x) = explode(" ", trim(fgets($file)));
  $a = explode(" ", trim(fgets($file)));
  $m = 0; $k = 0;

  for ($j = 0; $j < $n; $j++) {
    $m += ceil($a[$j] / $x);
    $k += $a[$j];
  }
  $k = $k / $x;
  $min = min($m, $k);
  $max = max($m, $k);
  echo $min.' '.$max.PHP_EOL;
}
?>

<?php
function solve() {
    $s1 = trim(fgets(STDIN));
    list($n, $x) = explode(' ', $s1);
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $min = ceil(array_sum($a) / $x);
    $max = 0;
    for ($i = 0; $i < $n; $i++) {
        $max += ceil($a[$i] / $x);
    }

    echo returnFloat($min)." ".returnFloat($max);
}

function returnFloat($bigint) {
    return floatval($bigint);
}

$t = trim(fgets(STDIN));
while ($t--) {
    solve();
    echo "\n";
}
?>

<?php
function solve() {
    $s1 = trim(fgets(STDIN));
    list($n, $x) = explode(' ', $s1);
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $min = ceil(array_sum($a) / $x);
    $max = 0;
    for ($i = 0; $i < $n; $i++) {
        $max += ceil($a[$i] / $x);
    }

    echo returnInt($min)." ".returnInt($max);
}

function returnInt($bigint) {
    return number_format($bigint);
}

$t = trim(fgets(STDIN));
while ($t--) {
    solve();
    echo "\n";
}
?>

<?php
function solve() {
    $s1 = trim(fgets(STDIN));
    list($n, $x) = explode(' ', $s1);
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $min = ceil(array_sum($a) / $x);
    $max = 0;
    for ($i = 0; $i < $n; $i++) {
        $max += ceil($a[$i] / $x);
    }

    echo returnInt($min)." ".returnInt($max);
}

function returnInt($i) {
    return strval($i);
}

$t = trim(fgets(STDIN));
while ($t--) {
    solve();
    echo "\n";
}
?>

<?php
function solve() {
    $s1 = trim(fgets(STDIN));
    list($n, $x) = explode(' ', $s1);
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $min = ceil(array_sum($a) / $x);
    $max = 0;
    for ($i = 0; $i < $n; $i++) {
        $max += ceil($a[$i] / $x);
    }

    echo $min." ".$max;
}

$t = trim(fgets(STDIN));
while ($t--) {
    solve();
    echo "\n";
}
?>

<?php

$t = (int) trim(fgets(STDIN));
for ($i = 0; $i < $t; ++$i) {
    //i[]
    list($ni[], $xi[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $ai[] = explode(' ', trim(fgets(STDIN)));
}
for ($i = 0; $i < $t; ++$i) {
    $n = $ni[$i];
    $x = $xi[$i];
    $a = $ai[$i];
    $sum = 0;
    $cnt = 0;
    foreach ($a as $v) {
        $sum = bc1($sum, '+', $v);
        $cnt += ceil($v / $x);
    }
    echo cl($sum, $x).' '.$cnt.PHP_EOL;
}

function fl($x, $y = 1)
{
    return bcdiv(bcsub($x, bcmod($x, $y)), $y);
}
function cl($x, $y = 1)
{
    return bcadd(fl($x, $y), bcmod($x, $y) > 0);
}
function bc1($x, $e, $y = null)
{
    is_null($y) && list($e, $y) = explode(' ', trim($e));
    '+' == $e && $ans = bcadd($x, $y);
    '-' == $e && $ans = bcsub($x, $y);
    '*' == $e && $ans = bcmul($x, $y);
    '/' == $e && $ans = bcdiv($x, $y);
    '%' == $e && $ans = bcmod($x, $y);

    return $ans;
}

<?php

$t = (int) trim(fgets(STDIN));
for ($i = 0; $i < $t; ++$i) {
    //i[]
    list($ni[], $xi[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $ai[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($i = 0; $i < $t; ++$i) {
    $n = $ni[$i];
    $x = $xi[$i];
    $a = $ai[$i];
    $sum = 0;
    foreach ($a as $v) {
        $sum += ceil($v / $x);
    }
    echo ceil(array_sum($a) / $x).' '.$sum.PHP_EOL;
}


Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction  as a sum of three distinct positive fractions in form .Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that . Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.If there is no such answer, print -1.

The single line contains single integer n (1 ≤ n ≤ 104).

If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1. If there are multiple answers, print any of them.

<?php
$STDIN = fopen('./data.txt', 'r');
define('STDIN', $STDIN);
$n = trim(fgets(STDIN));
if ($n == 1) {
    echo '-1';
} else {
    echo $n, ' ', $n + 1, ' ', $n * ($n + 1);
}
?>


Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed $$$n$$$ cans in a row on a table. Cans are numbered from left to right from $$$1$$$ to $$$n$$$. Vasya has to knock down each can exactly once to finish the exercise. He is allowed to choose the order in which he will knock the cans down.Vasya knows that the durability of the $$$i$$$-th can is $$$a_i$$$. It means that if Vasya has already knocked $$$x$$$ cans down and is now about to start shooting the $$$i$$$-th one, he will need $$$(a_i \cdot x + 1)$$$ shots to knock it down. You can assume that if Vasya starts shooting the $$$i$$$-th can, he will be shooting it until he knocks it down.Your task is to choose such an order of shooting so that the number of shots required to knock each of the $$$n$$$ given cans down exactly once is minimum possible.

The first line of the input contains one integer $$$n$$$ $$$(2 \le n \le 1\,000)$$$ — the number of cans. The second line of the input contains the sequence $$$a_1, a_2, \dots, a_n$$$ $$$(1 \le a_i \le 1\,000)$$$, where $$$a_i$$$ is the durability of the $$$i$$$-th can.

In the first line print the minimum number of shots required to knock each of the $$$n$$$ given cans down exactly once. In the second line print the sequence consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ — the order of indices of cans that minimizes the number of shots required. If there are several answers, you can print any of them.

NoteIn the first example Vasya can start shooting from the first can. He knocks it down with the first shot because he haven't knocked any other cans down before. After that he has to shoot the third can. To knock it down he shoots $$$20 \cdot 1 + 1 = 21$$$ times. After that only second can remains. To knock it down Vasya shoots $$$10 \cdot 2 + 1 = 21$$$ times. So the total number of shots is $$$1 + 21 + 21 = 43$$$.In the second example the order of shooting does not matter because all cans have the same durability.

<?
$stdin = fopen('php://stdin', 'r');
ini_set('display_errors', '1');
function read() {
    return trim(fgets(STDIN));
}
/////////////////

$n = read();
$arr = explode(" ", read());
$resStr = '';
$x = 0;
$resNum = 0;
arsort($arr);
foreach ($arr as $k=>$v) {
    $resStr .= ($k+1).' ';
    $resNum += $v*$x+1;
    $x++;
}

echo $resNum."\n";
echo $resStr."\n";


We will consider the numbers $$$a$$$ and $$$b$$$ as adjacent if they differ by exactly one, that is, $$$|a-b|=1$$$.We will consider cells of a square matrix $$$n \times n$$$ as adjacent if they have a common side, that is, for cell $$$(r, c)$$$ cells $$$(r, c-1)$$$, $$$(r, c+1)$$$, $$$(r-1, c)$$$ and $$$(r+1, c)$$$ are adjacent to it.For a given number $$$n$$$, construct a square matrix $$$n \times n$$$ such that:   Each integer from $$$1$$$ to $$$n^2$$$ occurs in this matrix exactly once;  If $$$(r_1, c_1)$$$ and $$$(r_2, c_2)$$$ are adjacent cells, then the numbers written in them must not be adjacent.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$). Then $$$t$$$ test cases follow. Each test case is characterized by one integer $$$n$$$ ($$$1 \le n \le 100$$$).

For each test case, output:    -1, if the required matrix does not exist;  the required matrix, otherwise (any such matrix if many of them exist).  The matrix should be outputted as $$$n$$$ lines, where each line contains $$$n$$$ integers.

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$t = IO::str();

function shift_in_right (&$arr) {
    $item = array_pop($arr);
    array_unshift ($arr,$item);
}

$f = array();
while ($t--){
    $cnt = 0;
    $idx = 0;
    $n = $s = IO::str();
    $res = array();

    if ($n == 2) {
        $f[] = -1;
        continue;
    }
    $arr = array();
    while ($s > 0) {
        for ($i = 0; $i < $n; $i++) {
            $r = $s + ($n*$i);
            $arr[$cnt][] = $r;
        }
        $s--;
        $cnt++;
    }

    foreach ($arr as $id => $item) {
        while($id--) {
            shift_in_right($item);
        }
        $item = implode(' ', $item);
        $res[] = $item;

    }
    $f[] = $res;
}
//print_r($f); exit;

foreach ($f as $i) {
    if (is_array($i)) {
        IO::res($i);
    } else {
        echo $i . "\n";
    }
}

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$t = IO::str();

function shift_in_right (&$arr) {
    $item = array_pop($arr);
    array_unshift ($arr,$item);
}

while ($t--){
    $cnt = 0;
    $idx = 0;
    $n = $s = IO::str();
    $arr = array();
    while ($s > 0) {
        for ($i = 0; $i < $n; $i++) {
            $r = $s + ($n*$i);
            $arr[$cnt][] = $r;
        }
        $s--;
        $cnt++;
    }

    foreach ($arr as $id => $item) {
        while($id--) {
            shift_in_right($item);
        }
        $item = implode(' ', $item);
        $res[] = $item;

    }
}

IO::res($res);


You are given a permutation $$$a$$$ consisting of $$$n$$$ numbers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array in which each element from $$$1$$$ to $$$n$$$ occurs exactly once).You can perform the following operation: choose some subarray (contiguous subsegment) of $$$a$$$ and rearrange the elements in it in any way you want. But this operation cannot be applied to the whole array.For example, if $$$a = [2, 1, 4, 5, 3]$$$ and we want to apply the operation to the subarray $$$a[2, 4]$$$ (the subarray containing all elements from the $$$2$$$-nd to the $$$4$$$-th), then after the operation, the array can become $$$a = [2, 5, 1, 4, 3]$$$ or, for example, $$$a = [2, 1, 5, 4, 3]$$$.Your task is to calculate the minimum number of operations described above to sort the permutation $$$a$$$ in ascending order.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$) — the number of elements in the permutation. The second line of the test case contains $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ — the given permutation $$$a$$$.

For each test case, output a single integer — the minimum number of operations described above to sort the array $$$a$$$ in ascending order.

NoteIn the explanations, $$$a[i, j]$$$ defines the subarray of $$$a$$$ that starts from the $$$i$$$-th element and ends with the $$$j$$$-th element.In the first test case of the example, you can select the subarray $$$a[2, 3]$$$ and swap the elements in it.In the second test case of the example, the permutation is already sorted, so you don't need to apply any operations.In the third test case of the example, you can select the subarray $$$a[3, 5]$$$ and reorder the elements in it so $$$a$$$ becomes $$$[2, 1, 3, 4, 5]$$$, and then select the subarray $$$a[1, 2]$$$ and swap the elements in it, so $$$a$$$ becomes $$$[1, 2, 3, 4, 5]$$$.

<?php

function isPrime($number)
{

    if ($number == 2 || $number == 3)
        return true;

    if ($number % 2 == 0 || $number % 3 == 0)
        return false;

    $divisor = 6;
    while ($divisor * $divisor - 2 * $divisor + 1 <= $number)
    {

        if ($number % ($divisor - 1) == 0)
            return false;

        if ($number % ($divisor + 1) == 0)
            return false;

        $divisor += 6;

    }

    return true;

}

function nextPrime($n)
{
    $n = $n + 1;
    while(!isPrime($n)){
        $n++;
    }

    return $n;
}

function gcd($a, $b)
{
    while($b != 0){
        $t = $a % $b;
        $a = $b;
        $b = $t;
    }
    return $a;
}

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    $n = intval(trim(fgets(STDIN)));

    $array = explode(' ', trim(fgets(STDIN)));

    if($array[0] == 1 && $array[$n - 1] == $n){
        $new_arr = array_slice($array, 1, $n - 2);

        sort($new_arr);

        if($new_arr == array_slice($array, 1, $n - 2))
            echo "0\n";

        else
            echo "1\n";

        continue;

    }

    if($array[0] == 1 || $array[$n - 1] == $n){
        echo "1\n";
        continue;
    }

    if($array[0] == $n && $array[$n - 1] == 1){
        echo "3\n";
        continue;
    }

    echo "2\n";

}

<?php

function isPrime($number)
{

    if ($number == 2 || $number == 3)
        return true;

    if ($number % 2 == 0 || $number % 3 == 0)
        return false;

    $divisor = 6;
    while ($divisor * $divisor - 2 * $divisor + 1 <= $number)
    {

        if ($number % ($divisor - 1) == 0)
            return false;

        if ($number % ($divisor + 1) == 0)
            return false;

        $divisor += 6;

    }

    return true;

}

function nextPrime($n)
{
    $n = $n + 1;
    while(!isPrime($n)){
        $n++;
    }

    return $n;
}

function gcd($a, $b)
{
    while($b != 0){
        $t = $a % $b;
        $a = $b;
        $b = $t;
    }
    return $a;
}

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    $n = intval(trim(fgets(STDIN)));

    $array = explode(' ', trim(fgets(STDIN)));

    if($array[0] == 1 && $array[$n - 1] == $n){
        $new_arr = array_slice($array, 1, $n - 2);

        sort($new_arr);

        if($new_arr == array_slice($array, 1, $n - 2))
            echo "0\n";

        else
            echo "1\n";

        continue;

    }

    if($array[0] == 1 || $array[$n - 1] == $n){
        echo "1\n";
        continue;
    }

    echo "2\n";

}


There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction:   Find any isolated cell on the board. If there are no such cells, print any cell on the board.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.

For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.

NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle.

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{

   list($n, $m) = IO::getArray();
   $ans = '';
    if($n == 3 && $m == 3) {
        $ans = '2 2';
    } elseif($n == 3 && $m == 2) {
       $ans = '2 2';
    } elseif($n == 2 && $m == 3) {
       $ans = '2 2';
    } else {
        $ans = sprintf('%s %s', $n, $m);
    }
    IO::pr($ans);
}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
  $inp = preg_split('#\s+#', trim(file_get_contents("php://stdin")));
  $p = 0;
  $tests = intval($inp[$p++]);
  for($test=0;$test<$tests;$test++)
  {
    $n = intval($inp[$p++]);
    $m = intval($inp[$p++]);
    echo (1+($n>>1))." ".(1+($m>>1))."\n";
  }

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{

   list($n, $m) = IO::getArray();
   $ans = '';
    if($n == 3 && $m == 3) {
        $ans = '2 2';
    } elseif($n < 3 && $m < 3) {
         $ans = '1 1';
    } else {
        $ans = sprintf('%s %s', $n, $m);
    }
    IO::pr($ans);
}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{

   list($n, $m) = IO::getArray();
   $ans = '';
    if($n == 3 && $m == 3) {
        $ans = '2 2';
    } elseif($n < 3 && $m < 3) {
         $ans = '1 1';
    } else {
        $ans = sprintf('%s %s', $n-1, $m-1);
    }
    IO::pr($ans);
}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{

   list($n, $m) = IO::getArray();
   $ans = '';
    if($n == 3 && $m == 3) {
        $ans = '2 2';
    } elseif($n < 3 || $m < 3) {
         $ans = '1 1';
    } else {
        $ans = sprintf('%s %s', $n-1, $m-1);
    }
    IO::pr($ans);
}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}


Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.The camera's memory is d megabytes. Valera's camera can take photos of high and low quality. One low quality photo takes a megabytes of memory, one high quality photo take b megabytes of memory. For unknown reasons, each client asks him to make several low quality photos and several high quality photos. More formally, the i-th client asks to make xi low quality photos and yi high quality photos.Valera wants to serve as many clients per day as possible, provided that they will be pleased with his work. To please the i-th client, Valera needs to give him everything he wants, that is, to make xi low quality photos and yi high quality photos. To make one low quality photo, the camera must have at least a megabytes of free memory space. Similarly, to make one high quality photo, the camera must have at least b megabytes of free memory space. Initially the camera's memory is empty. Valera also does not delete photos from the camera so that the camera's memory gradually fills up.Calculate the maximum number of clients Valera can successfully serve and print the numbers of these clients.

The first line contains two integers n and d (1 ≤ n ≤ 105, 1 ≤ d ≤ 109) — the number of clients and the camera memory size, correspondingly. The second line contains two integers a and b (1 ≤ a ≤ b ≤ 104) — the size of one low quality photo and of one high quality photo, correspondingly.  Next n lines describe the clients. The i-th line contains two integers xi and yi (0 ≤ xi, yi ≤ 105) — the number of low quality photos and high quality photos the i-th client wants, correspondingly.  All numbers on all lines are separated by single spaces.

On the first line print the answer to the problem — the maximum number of clients that Valera can successfully serve. Print on the second line the numbers of the client in any order. All numbers must be distinct. If there are multiple answers, print any of them. The clients are numbered starting with 1 in the order in which they are defined in the input data.

<?php
list($n,$d) = explode(' ',trim(fgets(STDIN)));
list($a,$b) = explode(' ',trim(fgets(STDIN)));

$c = array();
for($i=1;$i<=$n;$i++){
 list($x,$y) = explode(' ',trim(fgets(STDIN)));
 $c[$i] = $a*$x+$b*$y;
}
asort($c);

$s = 0; $r = array();
foreach($c as $k=>$v){
 if($s+$v>$d) break;
 $s += $v;
 $r[] = $k;
}
print count($r)."\r\n".implode(' ',$r);

?>


The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots, s_{n+1}$$$.For each $$$i$$$ ($$$1 \le i \le n$$$) she calculated $$$a_i$$$ — the length of the longest common prefix of $$$s_i$$$ and $$$s_{i+1}$$$.Several days later Koa found these numbers, but she couldn't remember the strings.So Koa would like to find some strings $$$s_1, s_2, \dots, s_{n+1}$$$ which would have generated numbers $$$a_1, a_2, \dots, a_n$$$. Can you help her?If there are many answers print any. We can show that answer always exists for the given constraints.

Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 50$$$) — the elements of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$100$$$.

For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that answer always exists for the given constraints.

aeren
ari
arousal
around
ari
monogon
monogamy
monthly
kevinvu
kuroni
kurioni
korone
anton
loves
adhoc
problems

NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are:  Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$  Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$  Between $$$\color{red}{arou}sal$$$ and $$$\color{red}{arou}nd$$$ $$$\rightarrow 4$$$  Between $$$\color{red}{ar}ound$$$ and $$$\color{red}{ar}i$$$ $$$\rightarrow 2$$$

<?php
$a = trim(fgets(STDIN));
$b = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
for($x = 1; $x <= $a; $x++)
{
     $c = trim(fgets(STDIN));
     $d = explode(" ", trim(fgets(STDIN)));
     print $b . "\n";
     for($y = 0; $y < $c; $y++)
     {
          if($b[$d[$y]] == "a")
          {
               $b[$d[$y]] = "b";
          }
          else
          {
               $b[$d[$y]] = "a";
          }
          print $b . "\n";
     }
}
?>


A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.A string is called a substring of another string, if it can be obtained from that string by dropping some (possibly zero) number of characters from the beginning and from the end of it. For example, "abc", "ab", and "c" are substrings of the string "abc", while "ac" and "d" are not.Let's define a palindromic count of the string as the number of its substrings that are palindromes. For example, the palindromic count of the string "aaa" is $$$6$$$ because all its substrings are palindromes, and the palindromic count of the string "abc" is $$$3$$$ because only its substrings of length $$$1$$$ are palindromes.You are given a string $$$s$$$. You can arbitrarily rearrange its characters. You goal is to obtain a string with the maximum possible value of palindromic count.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 100\,000$$$) — the length of string $$$s$$$. The second line contains string $$$s$$$ that consists of exactly $$$n$$$ lowercase characters of Latin alphabet.

Print string $$$t$$$, which consists of the same set of characters (and each characters appears exactly the same number of times) as string $$$s$$$. Moreover, $$$t$$$ should have the maximum possible value of palindromic count among all such strings strings. If there are multiple such strings, print any of them.

NoteIn the first example, string "ololo" has $$$9$$$ palindromic substrings: "o", "l", "o", "l", "o", "olo", "lol", "olo", "ololo". Note, that even though some substrings coincide, they are counted as many times as they appear in the resulting string.In the second example, the palindromic count of string "abccbaghghghgdfd" is $$$29$$$.

<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
sort($b);
print implode($b);
?>