<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for($k = 0; $k < $m; $k++) {
    list($a,$b) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iCount = 0;
    $iAnswer = 0;
   for ($i = 1; $i < count($aArray); $i++) {
        if ($aArray[$i ] > floor($b/($i))) {
            $iCount = floor($b/($i));
        } else {
            $iCount = $aArray[$i];
        }
        $iAnswer += $iCount;
        $b = $b - $iCount * $i;
    }
   $iAnswer += $aArray[0];
   echo $iAnswer . "\n";
}

<?php

$t = (int) trim(fgets(STDIN));

while($t--) number_of_haybales();

function number_of_haybales(){

    $line = explode(" ", trim(fgets(STDIN)));
    $n = $line[0];
    $d = $line[1];

    $arr = array_map(function($el) { return (int) $el; }, explode(" ", trim(fgets(STDIN))));

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

        while($arr[$i]){

            if($d >= $i){
                $d -= $i;
                $arr[$i]--;
                $arr[0]++;
            }
            else{
                print($arr[0]);
                echo "\n";
                return;
            }

        }
    }

    print($arr[0]);
    echo "\n";
    return;

}

<?php
$f = trim(fgets(STDIN));
for($j = 0; $j < $f; $j++){
    $a = explode(' ', trim(fgets(STDIN)));
    $b = explode(' ', trim(fgets(STDIN)));
    $c = $a[1];
    $d = $b[0];
    unset($b[0]);
    $boo = true;
    foreach($b as $k => $v){
        for($i = 1; $i <= $v && $boo; $i++){
            if($c >= $k){
                $d++;
                $c-= $k;
            } else {
                $boo = false;
            }
        }
        if(!$boo){
            break;
        }
    }

    echo $d."\n";
}

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

<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for($k = 0; $k < $m; $k++) {
    list($a,$b) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $j = 1;
    $iCount = 0;
    $iLastIndex = 0;
    for ($i = 1; $i < count($aArray); $i++) {
        if ($b <= $iCount) {
            break;
        }
        if ($aArray[$i] >= $i) {
            $iCount += $i;
        }
    }
    echo $iCount + $aArray[0] . "\n";
}


<?php
  $a=trim(fgets(STDIN));
  $b=strrev($a);
  echo $a. $b;
?>

<?php
$a = trim(fgets(STDIN));
$b = strrev($a);
print $a . $b;
?>

<?php
	$s = trim(fgets(STDIN));
	echo $s.strrev($s);
?>

<?php
$a = trim(fgets(STDIN));
$b = str_split($a);
$c = array_unique($b);
if((count($c) == 1) && (count($b) % 2 == 0))
{
     print $a;
}
else
{
     $d = strrev($a);
     print $a . $d;
}
?>


<?php
$testcases = readline();

for ($i = $testcases; $i > 0; $i--) {
    $str = readline();
    if ($str[0] + $str[1] + $str[2] == $str[3] + $str[4] + $str[5]) {
        echo 'YES' . "\n";
    } else {
        echo 'NO' . "\n";
    }

}

?>

<?php

fscanf(STDIN, "%d", $case);

for($i=0; $i < $case; $i++){
	$array = str_split(trim(fgets(STDIN)));

	if($array[0] + $array[1] + $array[2] == $array[3] + $array[4] + $array[5]){
		echo "YES\n";
	}else{
		echo "NO\n";
	}
}

<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";

  $t = getT();
//   $point = ord('a') + ord('b') ;

  for($q=0; $q <$t; $q++) {
      $ans = 0;
      $n = getT();

        $a = $b = 0;
          for($i=0; $i<3; $i++) {
              $a += $n[$i];
              $b += $n[$i+3];
          }
      pr($a == $b ? $yes :$no);

  }
// bcadd — Add two arbitrary precision numbers
// bccomp — Compare two arbitrary precision numbers
// bcdiv — Divide two arbitrary precision numbers
// bcmod — Get modulus of an arbitrary precision number
// bcmul — Multiply two arbitrary precision numbers
// bcpow — Raise an arbitrary precision number to another
// bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus
// bcscale — Set or get default scale parameter for all bc math functions
// bcsqrt — Get the square root of an arbitrary precision number
// bcsub — Subtract one arbitrary precision number from another
function getDar($n) {
    $dar = [2];
    for($i=0; $i<$n; $i++) {
        $dar[] = $dar[$i] * 2;
    }
    return $dar;
}
function getDar2($n, $k) {
    if($k == 0) {
        return 1;
    }
    return bcmul($n, getDar2($n, $k-1));
}

  function getT() {
      return trim(fgets(STDIN));
  }
  function getA() {
      return explode(' ', trim(fgets(STDIN)));
  }

  function is_prime($n) {
    $d = 2;
        while ($n % $d != 0) {
        	 $d += 1;
        }

        return $d == $n;
    }
function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }

    function getMaxValueBc($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    function getRotate($a, $s, $e, $ind) {
 		$ar = [];
        for ($i= $s; $i<=$e; $i++) {
        	$ar[$i] = $a[$i];
        	$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
        	// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
        	$a[$i] = $j < $i ? $ar[$j] : $a[$j];
        }
        return $a;
    }
    function pr($s) {
        if(is_array($s)) {
            echo implode( ' ', $s), PHP_EOL;
        } else {
            echo $s, PHP_EOL;
        }
    }
    function fab2($n, $a) {
        if($n <= 1) {
            return $a[$n];
        }
       for($i=2; $i<=$n; $i++) {
           $a[$i] = $a[$i-1] + $a[$i-2];
       }

        return $a[$n];
    }

<?php

$input = fopen('php://stdin', 'r');
$primeira = 1;
while (!feof($input)) {
    $linha  = fgets($input);
    if (trim($linha) != '' && $primeira > 1) {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
    $primeira++;
}

<?php

$input = fopen('php://stdin', 'r');

while (!feof($input)) {
    $linha  = fgets($input);
    if (trim($linha) != 5 && trim($linha) != 1000 && trim($linha) != '') {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
}

<?php

$input = fopen('php://stdin', 'r');

while (!feof($input)) {
    $linha  = fgets($input);
    if ( trim($linha) != '') {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
}

<?php

$input = fopen('php://stdin', 'r');

while (!feof($input)) {
    $linha  = fgets($input);
    if (trim($linha) != 5 && trim($linha) != '') {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
}

<?php

$input = fopen('php://stdin', 'r');

while (!feof($input)) {
    $linha  = fgets($input);
    if (trim($linha)!=5) {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
}

<?php

$input = fopen('php://stdin', 'r');

while (!feof($input)) {
    $linha  = fgets($input);
    if (strlen($linha) == 7 ||strlen($linha) == 6) {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
}

<?php

$input = fopen('php://stdin', 'r');
$primeira = 1;
while (!feof($input)) {
    $linha  = fgets($input);
    if ($primeira > 1) {
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
    $primeira++;
}

<?php

$input = fopen('php://stdin', 'r');
$primeira = 1;
while (!feof($input)) {
    if ($primeira > 1) {
        $linha  = fgets($input);
        $tamanho = 0;
        $soma_esquerda = 0;
        $soma_direita = 0;
        while ($tamanho < 6) {
            if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
            } else {
                $soma_direita += $linha[$tamanho];
            }
            $tamanho++;
        }

        if ($soma_esquerda == $soma_direita) {
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    }
    $primeira++;
}

<?php

$input = fopen('php://stdin', 'r');
$linha  = fgets($input);
while (!feof($input)) {
    $linha  = fgets($input);
    $tamanho = 0;
    $soma_esquerda = 0;
    $soma_direita = 0;
    while ($tamanho < 6) {
        if ($tamanho < 3) {
            $soma_esquerda += $linha[$tamanho];
        } else {
            $soma_direita += $linha[$tamanho];
        }
        $tamanho++;
    }

    if ($soma_esquerda == $soma_direita) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php

$input = fopen('php://stdin','r');

$i = 1;

while(!feof($input)){
$linha  = fgets($input);
    $tamanho = 0;
    $soma_esquerda = 0;
    $soma_direita = 0;
    while ($tamanho < 6) {
        if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
        } else {
                $soma_direita += $linha[$tamanho];
        }
        $tamanho++;
    }

    if($soma_esquerda == $soma_direita){
        echo "YES\n";
    }else{
        echo "NO\n";
    }
    $i++;
}

<?php

$input = fopen('php://stdin','r');

$i = 1;
$linha  = fgets($input);
while(!feof($input)){
$linha  = fgets($input);
    $tamanho = 0;
    $soma_esquerda = 0;
    $soma_direita = 0;
    while ($tamanho < 6) {
        if ($tamanho < 3) {
                $soma_esquerda += $linha[$tamanho];
        } else {
                $soma_direita += $linha[$tamanho];
        }
        $tamanho++;
    }

    if($soma_esquerda == $soma_direita){
        echo "YES\n";
    }else{
        echo "NO\n";
    }
    $i++;
}

<?php

$input = file_get_contents('php://input');

$quebrado = explode("
", $input);
$i = 1;
while ($i <= $quebrado[0]) {
    $tamanho = 0;
    $soma_esquerda = 0;
    $soma_direita = 0;
    while ($tamanho < 6) {

        if ($tamanho < 3) {
            $soma_esquerda += $quebrado[$i][$tamanho];
        } else {
            $soma_direita += $quebrado[$i][$tamanho];
        }
        $tamanho++;
    }

    if($soma_esquerda == $soma_direita){
        echo "YES\n";
    }else{
        echo "NO\n";
    }
    $i++;
}

<?php

$input = "5
213132
973894
045207
000000
055776
";

$quebrado = explode("
", $input);
print_r($quebrado);

$i = 1;
while ($i <= $quebrado[0]) {
    $tamanho = 0;
    $soma_esquerda = 0;
    $soma_direita = 0;
    while ($tamanho < 6) {

        if ($tamanho < 3) {
            $soma_esquerda += $quebrado[$i][$tamanho];
        } else {
            $soma_direita += $quebrado[$i][$tamanho];
        }
        $tamanho++;
    }

    if($soma_esquerda == $soma_direita){
        echo "YES\n";
    }else{
        echo "NO\n";
    }
    $i++;
}


<?php

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

$t = + fgets($file);

while($t--)
{
  $n = + fgets($file);
  $arr = array_map('intval', explode(' ', fgets($file)));
  sort($arr);

  $anserCount = floor($n / 2);

  for($i = 1; $i <= $anserCount; $i++)
    echo sprintf("%d %d\n", $arr[$i], $arr[0]);
}

<?php

$t = + fgets(STDIN);

while($t--)
{
  $n = + fgets(STDIN);
  $arr = array_map('intval', explode(' ', fgets(STDIN)));

  sort($arr);

  $anserCount = floor($n / 2);

  for($i = 1; $i <= $anserCount; $i++)
    echo sprintf("%d %d\n", $arr[$i], $arr[0]);
}

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

$t = trim(fgets($file));

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

  sort($a);
  for ($j = 0; $j < floor($n / 2); $j++) {
    echo $a[$j + 1].' '.$a[0].PHP_EOL;
  }
}

?>

<?php

$t = +readline();

while($t--)
{
  $n = + readline();
  $arr = array_map('intval', explode(' ', readline()));
  sort($arr);

  $anserCount = floor($n / 2);

  for($i = 1; $i <= $anserCount; $i++)
    echo sprintf("%d %d\n", $arr[0], $arr[$i]);
}

<?php

$t = (int) readline();

function solve()
{
    $n = (int) readline();
    $desiredAnswersCount = (int) $n / 2;
    $foundAnswersCount = 0;

    $sequence = array_map('intval', explode(' ', trim(readline())));
    $fix = [];

    sort($sequence);
    $sequence = array_reverse($sequence);
    array_walk($sequence, function($el) use(&$fix) {
        $fix[$el] = true;
    });

    for($i= 0; $i < $n; $i++)
    {
        for($j = $i + 1; $j < $n; $j++)
        {
            $first = $sequence[$i];
            $second = $sequence[$j];
            $reminder = $first % $second;

            if(!isset($fix[$reminder]))
            {
                echo "$first $second\n";
                $foundAnswersCount++;
            }

            if($foundAnswersCount === $desiredAnswersCount)
            {
                return;
            }
        }
    }
}

while($t--) solve();

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

$t = trim(fgets($file));

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

  $couples = floor($n / 2);
  rsort($a);

  for ($j = 0; $j < $n; $j++) {
    for ($k = $j + 1; $k < $n; $k++) {
      $mod = $a[$j] % $a[$k];
      if (!in_array($mod, $a)) {
        $couples--;
        echo $a[$j].' '.$a[$k].PHP_EOL;
      }

      if ($couples == 0) {
        break;
      }
    }

    if ($couples === 0) {
      break;
    }
  }
}

?>


<?php
$n = rtrim(fgets(STDIN));
$a = rtrim(fgets(STDIN));
$arr = explode(" ",$a);
$s = 0;
for($i = 0; $i < $n; $i++) $s += $arr[$i]%2;
echo min($s,$n - $s);
?>

<?php
$x = rtrim(fgets(STDIN));
$a = rtrim(fgets(STDIN));
$arr = explode(" ",$a);
$s = 0;
for($i = 0; $i < $x; $i++){
    $s += $arr[$i] % 2;
}
echo min($s,$x - $s);
?>

<?php
	$cin = fopen("php://stdin", "r");
	$n = intval(fgets($cin));
	$s = fgets($cin);
	$a = explode(" ", $s);
	$even = 0;
	$odd = 0;
	for($i = 0; $i < count($a); $i++){
		if(intval($a[$i]) % 2 == 0){
			$even++;
		}
		else{
			$odd++;
		}
	}
	print_r(min($even, $odd)."\n");
?>

// I am Varun Das from Jadavpur University
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define mod 1000000007
#define ll long long
#define dbg(x) cerr << #x << " = " << x << endl
#define INF LLONG_MAX
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) for(int i=a;i>=b;i--)
#define nax 503405
using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//cout<<fixed<<setprecision(12);
ll n;
cin>>n;
ll k,s=0;
loop(i,0,n) cin>>k,s+=k%2;
cout<<min(s,n-s);
	return 0;
}


<?php
fscanf(STDIN,"%d",$tc);
while ($tc--) {
	# code...

$str=trim(fgets(STDIN));
$str1="";
$length=strlen($str);
for($i=1;$i<=$length-2;$i+=2)
{
	$str1.=$str[$i];

}
echo $str[0]."$str1".$str[$length-1]."\n";

}

<?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 = trim(fgets(STDIN)) ;

        $len = strlen($in_str) ;
        $ans = "" ;

        $ans .= $in_str[0] ;
        for($i = 1; $i < $len - 1; $i += 2)
        {
            $ans .= $in_str[$i] ;
            if($in_str[$i] != $in_str[$i + 1]) $ans .= $in_str[$i + 1] ;
        }
        $ans .= $in_str[$len - 1] ;
        echo $ans . "\n" ;
    }
?>

<?php
  $t = intval(readline());
  while ($t--) {
    $b = readline();
    $l = strlen($b);
    echo $b[0];
    for ($i = 1; $i < $l - 1; $i += 2) {
      echo $b[$i];
    }
    echo $b[$l - 1];
    echo "\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();

while ($t--) {
    $s = strtolower(IO::str());

    $asci = array();
    $arr = str_split($s);
    $min = 200;
    for ($i = 0; $i < strlen($s); $i++) {
        $k = ord($arr[$i]);
        if ($k < $min) {
            $min = $k;
            $idx = $i;
        }
    }

    $s1 = $arr[$idx];
    unset($arr[$idx]);

    $s2 = implode($arr);

    echo $s1 . ' ' . $s2 . PHP_EOL;
}

<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    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 asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    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 factorial($number)
    {
        $factorial = 1;
        for ($i = 1; $i <= $number; $i++){
            $factorial = $factorial * $i;
        }
        return $factorial;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
   $s = IO::str();
   $a = str_split($s);
   $min = 'z';
   $mink = 99;
   foreach ($a as $k => $v) {
       if ($v <= $min) {
           $min = $v;
           $mink = $k;
       }
   }
   unset($a[$mink]);
   $s1 = $min;
   $s2 = implode('', $a);
   IO::line($s1 . ' ' . $s2);
}

?>


<?php

$array = [];
$t = (int)fgets(STDIN);
while ($t--) {

    $str = str_split(trim(fgets(STDIN)));

    $arr = [];
    $x = 0;
    $days = 0;
    for ($i = 0; $i < count($str); $i++) {

        if (!in_array($str[$i], $arr) and $x < 3) {
            array_push($arr, $str[$i]);
            $x++;
        } else {
            if ($x == 3) {
                if (!in_array($str[$i], $arr)) {
                    $arr = [];
                    $x = 0;
                    $days++;
                    $i--;
                }
            }
        }
    }
    array_push($array, $days + 1);
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();
?>

<?php

fscanf(STDIN, "%d", $case);

$result = "";

for($i=0; $i < $case; $i++){
	$string_array = str_split(trim(fgets(STDIN)));

	$string_count = count($string_array);

	$memory_count = 0; // 현재 기억한 갯수

	$now_memory = array(); // 현재 기억한 것

	$day_count = 0; // 걸린 날짜

	$already_exists = false;

	for($j=0; $j < $string_count; $j++){

		if($memory_count >= 3 && !in_array($string_array[$j], $now_memory)){ // 현재 기억한 것이 3 이상이면
			$memory_count = 0;
			$now_memory = array(); // 초기화
			$day_count++;
		}

		if(in_array($string_array[$j], $now_memory)){ // 이미 있으면
			// 아무것도 안 함
			$already_exists = true;
		}else{ // 없으면
			array_push($now_memory, $string_array[$j]);
			$memory_count++;
			$already_exists = false;
		}
	}

	if($memory_count > 0){
		$day_count++;
	}

	$result .= $day_count."\n";
}

echo $result;

<?php
function solve($st) {
    $arr = str_split($st) ;
    $temp = [] ;
    $days = 0 ;
    foreach($arr as $a) {
        if(!in_array($a,$temp)) {
            $temp[] = $a;
        }
        if(count($temp) > 3) {
            $days += 1 ;
            $temp = array($a) ;
        }
    }
    if(count($temp) > 0 ) {
        $days += 1 ;
    }
    return $days ;
}

$t = (int) fgets(STDIN);
$ans = [] ;
while($t--) {
    $st = trim(fgets(STDIN));
    $ans[] = solve($st);
}
print_r(implode("\n",$ans)) ;


<?php

    class Utils {

        public static function lowerBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }

        public static function upperBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }
    }

    list($n, $m) = explode(' ', trim(fgets(STDIN)));
    $a = explode(' ', trim(fgets(STDIN)));
    $before = array_fill(1, $n, 0);
    $before[$n] = -1;
    for ($i = $n - 1; $i > 0; $i--) {
      $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1];
    }

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $map[$a[$i]][] = $i + 1;
    }

    $ans = "";
    while ($m-- > 0) {
        list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));

        if (isset($map[$k])) {
            $cur = &$map[$k];
            $size = count($cur);
            $x = Utils :: lowerBound($cur, 0, $size, $l);
            $y = Utils :: upperBound($cur, 0, $size, $r) - 1;
            if ($x == $size || $cur[$x] > $l) $ans .= "$l" . "\n";
            else $ans .= ($before[$l] > $r ? '-1' : "$before[$l]") . "\n";

        } else $ans .= "$l" . "\n";
    }
    echo $ans;

<?php

    class Utils {

        public static function lowerBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }

        public static function upperBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }
    }

    list($n, $m) = explode(' ', trim(fgets(STDIN)));
    $a = explode(' ', trim(fgets(STDIN)));
    $before = array_fill(1, $n, 0);
    $before[$n] = -1;
    for ($i = $n - 1; $i > 0; $i--) {

      $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1];
    }

//   print_r($before);

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $v = $a[$i];
        $map[$v][] = $i + 1;
    }

//    print_r($map);

    $ans = "";
    while ($m-- > 0) {
        list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));

        if (isset($map[$k])) {
            $cur = $map[$k];
            $size = count($cur);
            $x = Utils :: lowerBound($cur, 0, $size, $l);
            $y = Utils :: upperBound($cur, 0, $size, $r) - 1;
//           echo $size . " " . $k . " " . $x . " " . $y . "\n";
            if ($x == $size || $cur[$x] > $l) $ans .= "$l" . "\n";
            elseif ($y - $x == $r - $l) $ans .= '-1' . "\n";
            else $ans .= ($before[$l] > $r ? '-1' : "$before[$l]") . "\n";

        } else $ans .= "$l" . "\n";
    }
    echo $ans;

<?php

    class Utils {

        public static function lowerBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }

        public static function upperBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }
    }

    list($n, $m) = explode(' ', trim(fgets(STDIN)));
    $a = explode(' ', trim(fgets(STDIN)));
    $before = array_fill(1, $n, 0);
    $before[$n] = -1;
    for ($i = $n - 1; $i > 0; $i--) {

      $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1];
    }

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $v = $a[$i];
        $map[$v][] = $i + 1;
    }

    $ans = "";
    while ($m-- > 0) {
        list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));

        if (isset($map[$k])) {
            $cur = $map[$k];
            $size = count($cur);
            $x = Utils :: lowerBound($cur, 0, $size, $l);
            $y = Utils :: upperBound($cur, 0, $size, $r) - 1;
            if ($x == $size || $cur[$x] > $l) $ans .= "$l" . "\n";
            else $ans .= ($before[$l] > $r ? '-1' : "$before[$l]") . "\n";

        } else $ans .= "$l" . "\n";
    }
    echo $ans;

<?php

    class Utils {

        public static function lowerBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }

        public static function upperBound($a, $l, $r, $k) {
            $ans = $r; $m = 0;
            while ($l < $r) {
                $m = $l + $r >> 1;
                if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;
            }
            return $ans;
        }
    }

    list($n, $m) = explode(' ', trim(fgets(STDIN)));
    $a = explode(' ', trim(fgets(STDIN)));
    $before = array_fill(1, $n, 0);
    $before[$n] = -1;
    for ($i = $n - 1; $i > 0; $i--) {

      $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1];
    }

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $v = $a[$i];
        $map[$v][] = $i + 1;
    }

    while ($m-- > 0) {
        list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));

        if (isset($map[$k])) {
            $cur = $map[$k];
            $size = count($cur);
            $x = Utils :: lowerBound($cur, 0, $size, $l);
            $y = Utils :: upperBound($cur, 0, $size, $r) - 1;
            if ($x == $size || $cur[$x] > $l) echo "$l" . "\n";
            else echo $before[$l] > $r ? '-1' : "$before[$l]" . "\n";

        } else echo "$l" . "\n";
    }


<?php

function kirksFunction($binaryString) {
    $zeros = 0;
    $ones = 0;
    for ($i = strlen($binaryString)-1; $i >= 0; $i--) {
        if ($binaryString[$i] == '0') {
            $zeros++;
        }
        else {
            $ones++;
            if ($ones > $zeros) {
                $binaryString[$i] = '0';
                $ones--;
            }
        }
    }
    return $binaryString;
}

function main() {
    $binaryString = readline();
    echo kirksFunction($binaryString);
}

main();
?>

<?php

function kirksFunction($binaryString) {
    // Keep track of zeros and ones in sequence
    $zeros = 0;
    $ones = 0;
    // Iteration starts at the end. If x = 1 then there are two cases.
    // LIS starts from 1, then x = 0 will not affect LIS length
    // LIS doesn't starts from 1, then x = 0 will affect LIS length
    //
    // If LIS ends with 1 then iterating from back we change change 1 to 0.
    // Assume that LIS ends with 1, then the number of zeros after 1 is bigger or equal than the number of ones.
    // This means that similar LIS can be obtain from zeros.
    // If $ones > $zeros it means that we can change LIS containing ones to LIS containing zeros.
    for ($i = strlen($binaryString)-1; $i >= 0; $i--) {
        if ($binaryString[$i] == '0') {
            $zeros++;
        }
        else {
            $ones++;
            if ($ones > $zeros) {
                $binaryString[$i] = '0';
                $ones--;
            }
        }
    }
    return $binaryString;
}

function main() {
    $binaryString = readline();
    echo kirksFunction($binaryString);
}

main();
?>


<?php

$t = (integer) readline();
while($t--)
{
    $line = readline();
    $line = explode(' ', $line);
    $n = (integer) $line[0];
    $l = (integer) $line[1];
    $r = (integer) $line[2];
    $flag = 1;
    $ans = [];
    for($i = 1;$i <= $n;$i++)
    {
        $x = ($l % $i == 0 ? $l : $l + ($i - ($l % $i)));
        $x = ($i >= $l ? $i : $x);
        if($x > $r)
        {
            $flag = 0;
            break;
        }
        array_push($ans, $x);
    }
    if(!$flag)
    {
        echo "NO\n";
    }
    else
    {
        echo "YES\n";
        foreach($ans as $c)
        {
            echo $c . ' ';
        }
        echo "\n";
    }
}

<?php

function read() {
  return trim(fgets(STDIN)) ;
}

function readInt() {
  return (int) read() ;
}

function readStrs() {
  return explode(" ",read()) ;
}

function readIntArray() {
  return array_map('intval', readStrs());
}

function readAsArray() {
  return str_split(read()) ;
}

function printLine($arg) {
  if($arg === false) {
    print_r("false") ;
  }
  elseif($arg === true) {
    print_r("true") ;
  }
  else {
    print_r($arg) ;
  }
  print_r("\n") ;
}

$t = readInt() ;

while($t--) {
	$ans = [] ;
	[$n,$l,$h] = readIntArray() ;
	for ($i=1; $i <= $n; $i++) {
		$temp = (int) ($h / $i) ;
		// printLine($temp);
		$ele = $temp*$i ;
		if($h >= $ele && $l <= $ele) $ans[] = $ele ;
	}
	// printLine($ans);
	if(count($ans) < $n) {
		printLine("NO") ;
	}
	else {
		printLine("YES");
		printLine(implode(' ', $ans));
	}
}

<?php

$t = (integer) readline();
while($t--)
{
    $line = readline();
    $line = explode(' ', $line);
    $n = (integer) $line[0];
    $l = (integer) $line[1];
    $r = (integer) $line[2];
    $flag = 1;
    $ans = [];
    for($i = 1;$i <= $n;$i++)
    {
        $x = ($l % $i == 0 ? $l : $l + ($l % $i));
        $x = ($i >= $l ? $i : $x);
        if($x > $r)
        {
            $flag = 0;
            break;
        }
        array_push($ans, $x);
    }
    if(!$flag)
    {
        echo "NO\n";
    }
    else
    {
        echo "YES\n";
        foreach($ans as $c)
        {
            echo $c . ' ';
        }
        echo "\n";
    }
}

<?php

$t = (integer) readline();
while($t--)
{
    $line = readline();
    $line = explode(' ', $line);
    $n = (integer) $line[0];
    $l = (integer) $line[1];
    $r = (integer) $line[2];
    if($r - $l + 1 < $n)
    {
        echo "NO\n";
        continue;
    }
    echo "YES\n";
    $mod = 0;
    if($l <= $n)
    {
        $mod = $n;
    }
    else
    {
        if($l % $n == 0)
        {
            $mod = $l;
        }
        else
        {
            $mod = (((integer)($l / $n)) + 1) * $n;
        }
    }
    for($i = $mod + ($n - ($mod - $l + 1));$i > $mod;$i--)
    {
        echo $i . ' ';
    }
    while($l <= $mod)
    {
        echo $l . ' ';
        $l++;
    }
    echo "\n";
}

<?php

$t = (integer) readline();
while($t--)
{
    $line = readline();
    $line = explode(' ', $line);
    $n = (integer) $line[0];
    $l = (integer) $line[1];
    $r = (integer) $line[2];
    if($r - $l + 1 < $n)
    {
        echo "NO\n";
        continue;
    }
    echo "YES\n";
    while($n--)
    {
        echo $l . ' ';
        $l++;
    }
    echo "\n";
}


<?php

function nOfPairs($v)
{
	return ($v * ($v - 1)) / 2;
}

fscanf(STDIN, "%d", $n);

$pd = array( );
$md = array( );

for($cnt = 0; $cnt < $n; $cnt++)
{
	fscanf(STDIN, "%d%d", $x, $y);
	$pd[$x - $y]++;
	$md[$x - ($n - $y)]++;
}

foreach ($pd as $k => $v) {
	$sum += nOfPairs($v);
}

foreach ($md as $k => $v) {
	$sum += nOfPairs($v);
}

echo $sum;

?>

<?php
$n = (int)fgets(STDIN);
$fwdDiagCount = $backDiagCount = [];

for ($i = 0; $i < $n; $i++) {
  list ($x, $y) = explode(" ", trim(fgets(STDIN)));
  @$fwdDiagCount[$y - $x]++;
  @$backDiagCount[$x + $y]++;
}

$pairCount = 0;

foreach ($fwdDiagCount as $count) {
  if ($count > 1) {
    $pairCount += $count * ($count - 1) / 2;
  }
}

foreach ($backDiagCount as $count) {
  if ($count > 1) {
    $pairCount += $count * ($count - 1) / 2;
  }
}

echo "$pairCount\n";


<?php
    $j = trim(fgets(STDIN));
    for($l = 0; $l < $j; $l++){
        $c = trim(fgets(STDIN));
        $a = explode(" ", trim(fgets(STDIN)));
        $b = explode(" ", trim(fgets(STDIN)));
        $bup = false;
        $bdown = false;

        foreach($a as $k => $v){

            if($bup && $bdown){
                echo "YES\n";
                continue 2;
            }
            if($v < $b[$k] && $bup == false){
                echo "NO\n";
                continue 2;
            }
            if($v > $b[$k] && $bdown == false){
                echo "NO\n";
                continue 2;
            }
            if($v == -1){
                $bdown = true;
            }
            if($v == 1){
                $bup = true;
            }
        }
        echo "YES\n";
    }

?>

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

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

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

        $arr_a = explode(" ", trim(fgets(STDIN))) ;
        $arr_b = explode(" ", trim(fgets(STDIN))) ;

        $f = array(
            array_fill(0, $n, false),  // 1
            array_fill(0, $n, false)   // -1
        ) ;

        for($i = 0; $i < $n; $i ++)
        {
            $arr_a[$i] = intval($arr_a[$i]) ;
            $arr_b[$i] = intval($arr_b[$i]) ;

            if($i > 0)
            {
                $f[0][$i] = $f[0][$i - 1] ;
                $f[1][$i] = $f[1][$i - 1] ;

                if($arr_a[$i - 1] == 1) $f[0][$i] = true ;
                else if($arr_a[$i - 1] == -1) $f[1][$i] = true ;
            }
        }

        if($arr_a[0] != $arr_b[0]) echo "NO\n" ;
        else
        {
            for($i = $n - 1; $i >= 1; $i --)
            {
                if($arr_b[$i] > $arr_a[$i] && !$f[0][$i]) break ;
                if($arr_b[$i] < $arr_a[$i] && !$f[1][$i]) break ;
            }

            echo $i >= 1 ? "NO\n" : "YES\n" ;
        }
    }
?>


<?php

$times = (int) trim(fgets(STDIN));
for ($idx = 0; $idx < $times; ++$idx) {
    $ni[] = trim(fgets(STDIN));
}
for ($idx = 0; $idx < $times; ++$idx) {
    $n = &$ni[$idx];
    $a = ceil(pow($n / 2, 1 / 3));
    for ($i = 1; $i <= $a; ++$i) {
        $b = $n - $i * $i * $i;
        if ($b < $i * $i * $i) {
            break;
        }
        $f = floor(pow($b, 1 / 3));
        for ($j = $f;; ++$j) {
            $j3 = $j * $j * $j;
            if ($b == $j3) {
                echo 'YES'.PHP_EOL;
                continue 3;
            } elseif ($b < $j3) {
                break;
            }
        }
    }
    echo 'NO'.PHP_EOL;
}

<?php

$times = (int) trim(fgets(STDIN));
for ($idx = 0; $idx < $times; ++$idx) {
    $ni[] = (int) trim(fgets(STDIN));
}
for ($idx = 0; $idx < $times; ++$idx) {
    $n = &$ni[$idx];
    $a = ceil(pow($n / 2, 1 / 3));
    for ($i = 1; $i <= $a; ++$i) {
        $b = $n - $i * $i * $i;
        if ($b < $i * $i * $i) {
            break;
        }
        $f = floor(pow($b, 1 / 3));
        for ($j = $f;; ++$j) {
            $j3 = $j * $j * $j;
            if ($b == $j3) {
                echo 'YES'.PHP_EOL;
                continue 3;
            } elseif ($b < $j3) {
                break;
            }
        }
    }
    echo 'NO'.PHP_EOL;
}


<?php
fscanf(STDIN, "%d %d %d %d", $x, $y, $x0, $y0);
$temp = str_split(trim(fgets(STDIN)));
$len = count($temp);
$ans = array_fill(0, $len + 1, 0);
$visit = array_fill(1, $x * $y, 0);
$step = 0;
$ans[0] = 1;
$visit[($x0-1)*$y+$y0] = 1;
foreach ($temp as $ch) {
    $step ++;
    switch ($ch) {
        case 'U':
            if ($x0 > 1) $x0 --;
            break;
        case 'R':
            if ($y0 < $y) $y0 ++;
            break;
        case 'D':
            if ($x0 < $x) $x0 ++;
            break;
        case 'L':
            if ($y0 > 1) $y0 --;
    }
    $tmp = ($x0 - 1) * $y + $y0;
    if ($visit[$tmp]==0) {
        $visit[$tmp] = 1;
        $ans[$step] = 1;
    }
}
$ans[$len] += $x * $y - array_sum($visit);
for ($i = 0;$i <= $len;$i ++) {
    if($i > 0) echo " ";
    echo $ans[$i];
}
echo "\n";
?>

<?php

$handle = fopen("php://stdin", "r");
fscanf($handle, "%d %d %d %d", $x, $y, $x0, $y0);
$cmd = trim(fgets($handle));
fclose($handle);
//echo $cmd, "\n";
//echo strlen($command), "\n";

$visited = array_fill(1, $x, array_fill(1, $y, false));
$t = $x * $y;

$visited[$x0][$y0] = true;
//echo $x0, " ", $y0, "\n";
echo "1 ";
$t--;

for($i = 0; $i < strlen($cmd); $i++) {
	//echo $cmd[$i], "\n";
	switch($cmd[$i]) {
		case "U":
			$x0 = ($x0 > 1) ? $x0 - 1 : $x0;
			break;
		case"D":
			$x0 = ($x0 < $x ) ? $x0 + 1 : $x0;
			break;
		case"L":
			$y0 = ($y0 > 1) ? $y0 - 1 : $y0;
			break;
		case "R":
			$y0 = ($y0 < $y ) ? $y0 + 1 : $y0;
			break;
	}
	//echo $x0, " ", $y0, "\n";
	if($i == strlen($cmd) - 1) { // last step
		echo $t, "\n";
	} else {
		if($visited[$x0][$y0]) {
			echo "0 ";
		} else {
			echo "1 ";
			$t --;
		}
	}
	$visited[$x0][$y0] = true;
}
?>

<?php
fscanf(STDIN, "%d %d %d %d", $x, $y, $x0, $y0);
$temp = str_split(fgets(STDIN));
$len = count($temp);
$ans = array_fill(0, $len, 0);
$visit = array_fill(1, $x * $y, 0);
$step = 0;
$ans[0] = 1;
$visit[($x0-1)*$y+$y0] = 1;
foreach ($temp as $ch) {
    $step ++;
    switch ($ch) {
        case 'U':
            if ($x0 > 1) $x0 --;
            break;
        case 'R':
            if ($y0 < $y) $y0 ++;
            break;
        case 'D':
            if ($x0 < $x) $x0 ++;
            break;
        case 'L':
            if ($y0 > 1) $y0 --;
    }
    $tmp = ($x0 - 1) * $y + $y0;
    if ($visit[$tmp]==0) {
        $visit[$tmp] = 1;
        $ans[$step] = 1;
    }
}
$ans[$len - 1] += $x * $y - array_sum($visit);
for ($i = 0;$i < $len;$i ++) {
    if($i > 0) echo " ";
    echo $ans[$i];
}
echo "\n";
?>


<?php
while($s = fgets(STDIN)){
    $input .= $s;
}
$input = explode("\r\n", $input);
$input[1]=explode(" ", $input[1]);
$n=$input[0];
$max=$res=2;
for($i=2;$i<$n;$i++) {
    if ($input[1][$i-2]+$input[1][$i-1] == $input[1][$i]) $res++;
    else {
        if ($res > $max) {
            $max=$res;
        }
        $res=2;
    }
}
if ($res > $max) {
    $max=$res;
}
echo $max<count($input[1])?$max:count($input[1]);
?>

<?php
while($s = fgets(STDIN)){
    $input .= $s;
}
$input = explode("\r\n", $input);
$input[1]=explode(" ", $input[1]);
$n=$input[0];
$max=$res=2;
for($i=2;$i<=$n;$i++) {
    if ($input[1][$i-2]+$input[1][$i-1] == $input[1][$i]) $res++;
    else {
        if ($res > $max) {
            $max=$res;
        }
        $res=2;
    }
}
echo $max;
?>

<?php
while($s = fgets(STDIN)){
    $input .= $s;
}
$input = explode("\r\n", $input);
$input[1]=explode(" ", $input[1]);
$n=$input[0];
$max=$res=2;
for($i=2;$i<=$n;$i++) {
    if ($input[1][$i-2]+$input[1][$i-1] == $input[1][$i]) $res++;
    else {
        if ($res > $max) {
            $max=$res;
        }
        $res=2;
    }
}

echo $max<count($input[1])?$max:count($input[1]);
?>


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

$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $a = IO::arr();
    $b = $c = [];
    $count = 0;
    foreach ($a as $v) {
        if ($v % 2 == 0) {
            $c[$count] = $v;
        } else {
            $b[$count] = $v;
        }
        $count++;
    }
    $res = array_merge($b + $c);
    IO::line(implode(' ', $res));

}

?>

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

$n = IO::str();
$res = array();
while ($n--) {
    $t = IO::str();
    $arr = IO::arr();
    $chet = array();
    $nchet = array();

    foreach ($arr as $ar) {
        if ($ar % 2 == 0) {
            $chet[] = $ar;
        } else {
            $nchet[] = $ar;
        }
    }

    $res[] = array_merge($chet, $nchet);
}

foreach ($res as $r) {
    foreach ($r as $z) {
        echo $z . ' ';
    }
    echo "\n";
}


<?php

	function find($a) {
		for ($i = 0; $i < count($a) - 2; $i++) {
			$ch = $a[$i];
			for ($j = $i + 2; $j < count($a); $j++) {
				if ($a[$j] == $ch)
					return true;
			}
		}
		return false;
	}

	$t = trim(fgets(STDIN));

	$ans = '';

	for ($o = 0; $o < $t; $o++) {
		$n = trim(fgets(STDIN));
		$a = explode(" ", trim(fgets(STDIN)));

		$ans .= find($a) ? "YES\n" : "NO\n";

	}
	print $ans;
?>

<?php
    $j = trim(fgets(STDIN));
    for($i = 0; $i < $j; $i++){
        $n = trim(fgets(STDIN));
        $a = explode(' ', trim(fgets(STDIN)));
        $bo = false;
        foreach($a as $k => $v){
            for($x = $k+2; $x < $n; $x++){
                if($a[$x] == $v){
                    $bo = true;
                    break 2;
                }
            }
        }

        if($bo){
            echo "YES\n";
        } else {
            echo "NO\n";
        }

    }

<?php

	function find($a) {
		for ($i = 0; $i < count($a)/2; $i++) {
			$ch = $a[$i];
			for ($j = count($a) - 1; $j >= count($a)/2; $j--) {
				if ($a[$j] == $ch && abs($i - $j) > 1 )
					return true;
			}
		}
		return false;
	}

	$t = trim(fgets(STDIN));

	$ans = '';

	for ($o = 0; $o < $t; $o++) {
		$n = trim(fgets(STDIN));
		$a = explode(" ", trim(fgets(STDIN)));

		$ans .= find($a) ? "YES\n" : "NO\n";

	}
	print $ans;
?>


<?php
#1190A
$start = microtime(1);
[$n, $m, $k] = explode(' ', trim(fgets(STDIN)));
$arr = explode(' ', trim(fgets(STDIN)));
$result = $off = 0;
$good = -1;
foreach ($arr as $i => $p) {
    if (bcdiv(bcsub($p, $off), $k) != $good) {
        $off = $i + 1;
        $good = bcdiv(bcsub($p, $off), $k);
        $result++;
    }
}
echo $result;

<?php
#1190A
$start = microtime(1);
[$n, $m, $k] = fscanf(STDIN, '%u %u %u');
$arr = explode(' ', trim(fgets(STDIN)));
$result = $off = 0;
$good = -1;
foreach ($arr as $i => $p) {
    if (bcdiv(bcsub($p, $off), $k) != $good) {
        $off = $i + 1;
        $good = bcdiv(bcsub($p, $off), $k);
        $result++;
    }
}
echo $result;


<?php

$t = readline();
for ($i = 0; $i < $t; ++$i) {
    $n = readline();
    $len = strlen($n);
    $result = [];
    for ($j = 0; $j < $len; ++$j) {
        if ($n[$j] == 0) {
            continue;
        }
        $result[] = $n[$j] . str_repeat('0', $len - $j - 1);
    }
    echo count($result) . "\n";
    echo implode(' ', $result) . "\n";
}

<?php

	//$input = fopen("input.txt", "r");
	//fscanf($input, "%d\n", $t);

	fscanf(STDIN, "%d\n", $t);
	while($t--){
		fscanf(STDIN, "%d\n", $n);
		$arr = array();
		$mul = 1;
		while($n){
            if($n%10)   $arr[] = $mul * ($n%10);
            $mul *= 10;
            $n /= 10;
		}
		echo count($arr) . "\n";
		foreach ($arr as $num)  echo "$num ";
		echo "\n";
	}

<?php

$t = readline();
for ($i = 0; $i < $t; ++$i) {
    $n = readline();
    $len = strlen($n);
    $result = [];
    for ($j = 0; $j < $len; ++$j) {
        if ($n[$j] == 0) {
            continue;
        }
        $result[] = $n[$j] . str_repeat('0', $len - $j - 1);
    }
    echo implode(' ', $result) . "\n";
}


<?php

error_reporting(0);
ob_end_clean();

solve();

function winner($A, $B){
	if ($A === $B) return 0;

	if ($A === 'R' && $B === 'S') return 1;
	elseif ($A === 'S' && $B === 'P') return 1;
	elseif ($A === 'P' && $B === 'R') return 1;
	else return -1;
}

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$N = $Scanner->Scan();
	$A = $Scanner->Scan();
	$B = $Scanner->Scan();
	$Alen = strlen($A);
	$Blen = strlen($B);
	$A_char = str_split($A);
	$B_char = str_split($B);
	$Acount = 0;
	$Bcount = 0;
	$cycle = $Alen * $Blen;
	$n = (int)($N / $cycle);
	$m = $N % $cycle;
	for ($i = 0; $i < min($cycle, $N); $i++) {
		$temp = winner($A_char[$i % $Alen], $B_char[$i % $Blen]);
		if ($temp === -1) $Acount++;
		elseif ($temp === 1) $Bcount++;

		if ($N > $cycle) {
			if ($i === $m - 1) {
				$Ac = $Acount;
				$Bc = $Bcount;
			}
		}
	}

	if ($N > $cycle) {
		$Acount = $Acount * $n + $Ac;
		$Bcount = $Bcount * $n + $Bc;
	}

	print($Acount. " ". $Bcount);

	$Scanner->Close();
}

class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);
		$contents = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	public function Scan(){
		return $this->Scanners[$this->Id++];
	}

	public function Close(){
		fclose($this->Stream);
	}
}

?>

<?php

function gcf($a, $b) {
  return ( $b == 0 ) ? ($a):( gcf($b, $a % $b) );
}
function lcm($a, $b) {
  return ( $a / gcf($a,$b) ) * $b;
}

function _main() {

$n = intval(fgets(STDIN));
$line1 = trim(fgets(STDIN));
$line2 = trim(fgets(STDIN));

$line1_len = strlen($line1);
$line2_len = strlen($line2);

$lcm_len = lcm($line1_len, $line2_len);
// print "lcm: $lcm_len\n";

$res = array(1 => 0, 2 => 0);
for($i=0;$i<min($n,$lcm_len);$i++) {
  if ($val = _cmp($line1[$i % $line1_len], $line2[$i % $line2_len])) {
    $res[$val]++;
  }
  // print " = $val\n";
  // sleep(1);
}

if ($n > $lcm_len) {
  $k = intval($n / $lcm_len);
  $res[1] *= $k;
  $res[2] *= $k;

  $tail_n = $n%$lcm_len;
  // print "tail_n: $tail_n | K = $k\n";
  for($i=0;$i<$tail_n;$i++) {
    if ($val = _cmp($line1[$i % $line1_len], $line2[$i % $line2_len])) {
      $res[$val]++;
    }
    // print " = $val\n";
    // sleep(1);
  }
}

return $res;
}

function _cmp($a, $b) {
// print "cmp $a <> $b";
  if ($a == $b) return 0;
  $w = array('R' => 0,'S' => 1,'P' => 2);

  return ($w[$a] + 1) % 3 == $w[$b]
    ? 1
    : 2;
}

function _test_cmp() {
  $a = 'RRRSSSPPP';
  $b = 'RSPRSPRSP';
  for($i=0;$i<strlen($a);$i++) {
    $res = _cmp($a[$i], $b[$i]);
    // print "_cmp($a[$i], $b[$i]) = $res\n";
  }
}

// _test_cmp();

$res = _main();
print $res[2] .' '. $res[1] ."\n";

<?php

error_reporting(0);
ob_end_clean();

solve();

function winner($A, $B){
	if ($A === $B) return 0;

	if ($A === 'R' && $B === 'S') return 1;
	elseif ($A === 'S' && $B === 'P') return 1;
	elseif ($A === 'P' && $B === 'R') return 1;
	else return -1;
}

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$N = $Scanner->Scan();
	$A = $Scanner->Scan();
	$B = $Scanner->Scan();
	$Alen = strlen($A);
	$Blen = strlen($B);
	$A_char = str_split($A);
	$B_char = str_split($B);
	$Acount = 0;
	$Bcount = 0;
	$cycle = $Alen * $Blen;
	$n = (int)($N / $cycle);
	$m = $N % $cycle;
	for ($i = 0; $i < min($cycle, $N); $i++) {
		$temp = winner($A_char[$i % $Alen], $B_char[$i % $Blen]);
		if ($temp === -1) $Acount++;
		elseif ($temp === 1) $Bcount++;

		if ($N > $cycle) {
			if ($i === $m - 1) {
				$Ac = $Acount;
				$Bc = $Bcount;
			}
		}
	}

	if ($N > $cycle) {
		$Acount = $Acount * $n + $Ac;
		$Bcount *= $Bcount * $n + $Bc;
	}

	print($Acount. " ". $Bcount);

	$Scanner->Close();
}

class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);
		$contents = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	public function Scan(){
		return $this->Scanners[$this->Id++];
	}

	public function Close(){
		fclose($this->Stream);
	}
}

?>

<?php

error_reporting(0);
ob_end_clean();

solve();

function winner($A, $B){
	if ($A === $B) return 0;

	if ($A === 'R' && $B === 'S') return 1;
	elseif ($A === 'S' && $B === 'P') return 1;
	elseif ($A === 'P' && $B === 'R') return 1;
	else return -1;
}

function solve(){
	//$Scanner = new Scanner("php://stdin");
	$Scanner = new Scanner("input.txt");

	$N = $Scanner->Scan();
	$A = $Scanner->Scan();
	$B = $Scanner->Scan();
	$Alen = strlen($A);
	$Blen = strlen($B);
	$A_char = str_split($A);
	$B_char = str_split($B);
	$Acount = 0;
	$Bcount = 0;
	for ($i = 0; $i < $N; $i++) {
		$temp = winner($A_char[$i % $Alen], $B_char[$i % $Blen]);
		if ($temp === -1) $Acount++;
		elseif ($temp === 1) $Bcount++;
	}

	print($Acount. " ". $Bcount);

	$Scanner->Close();
}

class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);
		$contents = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	public function Scan(){
		return $this->Scanners[$this->Id++];
	}

	public function Close(){
		fclose($this->Stream);
	}
}

?>

<?php

error_reporting(0);
ob_end_clean();

solve();

function winner($A, $B){
	if ($A === 'R' && $B === 'S') return 1;
	elseif ($A === 'R' && $B === 'P') return -1;
	elseif ($A === 'S' && $B === 'R') return -1;
	elseif ($A === 'S' && $B === 'P') return 1;
	elseif ($A === 'P' && $B === 'R') return 1;
	elseif ($A === 'P' && $B === 'S') return -1;
	else return 0;
}

function solve(){
	//$Scanner = new Scanner("php://stdin");
	$Scanner = new Scanner("input.txt");

	$N = $Scanner->Scan();
	$A = $Scanner->Scan();
	$B = $Scanner->Scan();
	$Alen = strlen($A);
	$Blen = strlen($B);

	$newA = $A;
	if ($N > $Alen) {
		$n = $N / $Alen + 1;
		for ($i = 2; $i <= $n; $i++) {
			$newA .= $A;
		}
	}

	$newB = $B;
	if ($N > $Blen) {
		$n = $N / $Blen + 1;
		for ($i = 2; $i <= $n; $i++) {
			$newB .= $B;
		}
	}

	$A_char = str_split($newA);
	$B_char = str_split($newB);
	$Acount = 0;
	$Bcount = 0;
	for ($i = 0; $i < $N; $i++) {
		$temp = winner($A_char[$i], $B_char[$i]);
		if ($temp === -1) $Acount++;
		elseif ($temp === 1) $Bcount++;
	}

	print($Acount. " ". $Bcount);

	$Scanner->Close();
}

class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);
		$contents = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	public function Scan(){
		return $this->Scanners[$this->Id++];
	}

	public function Close(){
		fclose($this->Stream);
	}
}

?>


<?php
$input_data = explode(" ", trim(fgets(STDIN)));
$input_n = $input_data[0];
$input_k = $input_data[1];
//$input_n = 7;
//$input_k = 2;

$result = array();
for ($i=0; $i<$input_n; $i++) {
	$result[] = $i+1;
}
if ($input_k != 1) {
	$i = 1;
	while ($input_k>0) {
		if ($i%2 == 0) {
			$result[$i] = $result[$i-1] - $input_k;
		} else {
			$result[$i] = $result[$i-1] + $input_k;
		}
		$input_k--;
		$i++;
	}
}
echo implode(" ", $result);
?>

<?php
$line = explode(" ", trim(fgets(STDIN)));
$length = $line[0];
$count = $line[1];
$res = array();
for ($i=0; $i<$length; $i++) {
	$res[] = $i+1;
}
if ($count != 1) {
	$counter = 1;
	while ($count>0) {
		if ($counter%2 == 0) {
			$res[$counter] = $res[$counter-1] - $count;
		} else {
			$res[$counter] = $res[$counter-1] + $count;
		}
		$count--;
		$counter++;
	}
}
echo implode(" ", $res);
?>