<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$n = intval($n);
$bFlag =false;
if($n>1){
    for($i =2; $i <10; $i++){
        if($n % $i == 0) {
            $iNum = $i;
            $bFlag = true;
        }
    }
    if(!$bFlag){
        echo $n. "\n";
        for($i =1; $i <=$n; $i++){
            echo "1 ";
        }
    } else {
        $counter = $n/$iNum;
        echo $counter ."\n";
        for($i = 1; $i<=$counter; $i++){
            echo $iNum . " ";
        }
    }
} else {
    echo "1 \n1";
}

<?php
$a = trim(fgets(STDIN));
$b = array_fill(1, $a, 1);
print count($b) . "\n";
print implode(" ", $b);
?>

<?php

$str = trim(fgets(STDIN));

$n = (int)$str;
echo $n.PHP_EOL;
echo '1';
for ($i = 1; $i < $n; $i++) {
    echo ' 1';
}

<?php
$a = trim(fgets(STDIN));
$b = array_fill(1, $a, 1);
print implode(" ", $b);
?>

<?php
$a = trim(fgets(STDIN));
print "1\n";
print $a;
?>

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$n = intval($n);
$bFlag =false;
if($n>1){
    for($i =2; $i <$n; $i++){
        if($n % $i == 0) {
            $iNum = $i;
            $bFlag = true;
        }
    }

    if(!$bFlag){
        echo $n. "\n";
        for($i =1; $i <=$n; $i++){
            echo "1 ";
        }
    } else {
        $counter = $n/$iNum;
        echo $counter ."\n";
        for($i = 1; $i<=$counter; $i++){
            echo $iNum . " ";
        }
    }
} else {
    echo '1';
}

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$n = intval($n);
$bFlag =false;
if($n>1){
    for($i =2; $i <$n; $i++){
        if($n % $i == 0) {
            $iNum = $i;
            $bFlag = true;
        }
    }

    if(!$bFlag){
        echo $n. "\n";
        for($i =1; $i <=$n; $i++){
            echo "1 ";
        }
    } else {
        $counter = $n/$iNum;
        echo $counter ."\n";
        for($i = 1; $i<=$counter; $i++){
            echo $iNum . " ";
        }
    }
} else {
    echo "1 \n1";
}


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

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $x = floor($n / 3);
    $two = $x;
    $one = $x * 2;
    $t = $n - $two - $one;
    if ($t == 1) {
        $x++;
    } elseif ($t == 2) {
        $two++;
    }
    IO::line($x . ' ' . $two);
}

?>

<?php

$tc = trim(fgets(STDIN));

while ($tc-- > 0) {
    $n = trim(fgets(STDIN));
    $n3 = floor($n / 3);

    switch ($n % 3) {
        case 0:
            echo $n3 . ' ' . $n3 . PHP_EOL;
            break;
        case 1:
            echo ($n3 + 1) . ' ' . $n3 . PHP_EOL;
            break;
        case 2:
            echo $n3 . ' ' . ($n3 + 1) . PHP_EOL;
            break;
    }
}

?>

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

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

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

  $c1 = round($a / 3);
  $c2 = $a - ($c1 * 2);

  echo $c2.' '.$c1.PHP_EOL;
}

?>


<?php
error_reporting(0);
ini_set('display_errors',0);
$str1 = trim(fgets(STDIN));
$arr = explode(" ",$str1);
$n = $arr[0];
$m = $arr[1];
$map = array();
for($i=0;$i<$m;$i++) {
        $str1 = trim(fgets(STDIN));
        $arr = explode(" ",$str1);
        $u = $arr[0];$v = $arr[1];$c = $arr[2];
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}
$q = trim(fgets(STDIN));
for($i=0;$i<$q;$i++) {
        $uv = explode(" ",trim(fgets(STDIN)));
        $u1 = $uv[0];
        $v1 = $uv[1];

        foreach($map[$u1] as $c => $vs) {
                $visited = array();
                dfs($map,$u1,$visited,$c);
                $arr = array_keys($visited);
                $cnt = count($arr);
                for($j=0;$j<$cnt;$j++) {
                        for($kl=0;$kl<$j;$kl++) {
                                if($map[$arr[$j]][$arr[$kl]]!=1)
                                        add($map,$arr[$j],$arr[$kl],$c);
                        }
                }
        }
        $count = 0;
        foreach($map[$u1] as $c => $vs) {
                if($vs[$v1] == 1) ++$count;
        }
        echo "$count\n";
}

function add(&$map,$u,$v,$c) {
        if($u==$v) return;
        //echo "$u $v c = $c\n";
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}

function dfs($map,$u,&$visited,$c) {
        if(!isset($visited[$u])) {
        $visited[$u] = 1;
        $nbrs = $map[$u][$c];
        foreach($nbrs as $n => $v) {
                dfs($map,$n,$visited,$c);
        }
    }
}

<?php
error_reporting(0);
ini_set('display_errors',0);
$str1 = trim(fgets(STDIN));
$arr = explode(" ",$str1);
$n = $arr[0];
$m = $arr[1];
$map = array();
for($i=0;$i<$m;$i++) {
        $str1 = trim(fgets(STDIN));
        $arr = explode(" ",$str1);
        $u = $arr[0];$v = $arr[1];$c = $arr[2];
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}
$q = trim(fgets(STDIN));
for($i=0;$i<$q;$i++) {
        $uv = explode(" ",trim(fgets(STDIN)));
        $u1 = $uv[0];
        $v1 = $uv[1];

        foreach($map[$u1] as $c => $vs) {
                $visited = array();
                dfs($map,$u1,$visited,$c);
                $arr = array_keys($visited);
                $cnt = count($arr);
                for($j=0;$j<$cnt;$j++) {
                        for($kl=0;$kl<$j;$kl++) {
                                if($map[$arr[$j]][$arr[$kl]]!=1)
                                        add($map,$arr[$j],$arr[$kl],$c);
                        }
                }
        }
        $count = 0;
        foreach($map[$u1] as $c => $vs) {
                if($vs[$v1] == 1) ++$count;
        }
        echo "$count\n";
}

function add(&$map,$u,$v,$c) {
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}

function dfs($map,$u,&$visited,$c) {
        if($visited[$u] == 1) return;
        $visited[$u] = 1;
        $nbrs = $map[$u][$c];
        foreach($nbrs as $n => $v) {
                dfs($map,$n,$visited,$c);
        }
}

<?php
error_reporting(0);
ini_set('display_errors',0);
$str1 = trim(fgets(STDIN));
$arr = explode(" ",$str1);
$n = $arr[0];
$m = $arr[1];
$map = array();
for($i=0;$i<$m;$i++) {
        $str1 = trim(fgets(STDIN));
        $arr = explode(" ",$str1);
        $u = $arr[0];$v = $arr[1];$c = $arr[2];
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}
$q = trim(fgets(STDIN));
for($i=0;$i<$q;$i++) {
        $uv = explode(" ",trim(fgets(STDIN)));
        $u1 = $uv[0];
        $v1 = $uv[1];

        foreach($map[$u1] as $c => $vs) {
                $visited = array();
                dfs($map,$u1,$visited,$c);
                $arr = array_keys($visited);
                $cnt = count($arr);
                for($j=0;$j<$cnt;$j++) {
                        for($kl=0;$kl<$j;$kl++) {
                                if($map[$arr[$j]][$arr[$kl]]!=1)
                                        add($map,$arr[$j],$arr[$kl],$c);
                        }
                }
        }
        $count = 0;
        foreach($map[$u1] as $c => $vs) {
                if($vs[$v1] == 1) ++$count;
        }
        echo "$count\n";
}

function add(&$map,$u,$v,$c) {
        if($u==$v) return;
        //echo "$u $v c = $c\n";
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}

function dfs($map,$u,&$visited,$c) {
        if($visited[$u] == 1) return;
        $visited[$u] = 1;
        $nbrs = $map[$u][$c];
        foreach($nbrs as $n => $v) {
                dfs($map,$n,$visited,$c);
        }
}

<?php
error_reporting(0);
ini_set('display_errors',0);
$arr = explode(" ",trim(fgets(STDIN)));
$n = $arr[0];
$m = $arr[1];
$map = array();
for($i=0;$i<$m;$i++) {
        $arr = explode(" ",trim(fgets(STDIN)));
        $u = $arr[0];$v = $arr[1];$c = $arr[2];
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}
$q = trim(fgets(STDIN));
for($i=0;$i<$q;$i++) {
        $uv = explode(" ",trim(fgets(STDIN)));
        $u1 = $uv[0];
        $v1 = $uv[1];

        foreach($map[$u1] as $c => $vs) {
                $visited = array();
                dfs($map,$u1,$visited,$c);
                $arr = array_keys($visited);
                $cnt = count($arr);
                for($j=0;$j<$cnt;$j++) {
                        for($kl=0;$kl<$j;$kl++) {
                                if($map[$arr[$j]][$arr[$kl]]!=1)
                                        add($map,$arr[$j],$arr[$kl],$c);
                        }
                }
        }
        $count = 0;
        foreach($map[$u1] as $c => $vs) {
                if($vs[$v1] == 1) ++$count;
        }
        echo "$count\n";
}

function add(&$map,$u,$v,$c) {
        if($u==$v) return;
        //echo "$u $v c = $c\n";
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}

function dfs($map,$u,&$visited,$c) {
        if(!isset($visited[$u])) {
        $visited[$u] = 1;
        $nbrs = $map[$u][$c];
        foreach($nbrs as $n => $v) {
                dfs($map,$n,$visited,$c);
        }
    }
}

<?php
error_reporting(0);
ini_set('display_errors',0);
$str1 = trim(fgets(STDIN));
$arr = explode(" ",$str1);
$n = $arr[0];
$m = $arr[1];
$map = array();
for($i=0;$i<$m;$i++) {
        $str1 = trim(fgets(STDIN));
        $arr = explode(" ",$str1);
        $u = $arr[0];$v = $arr[1];$c = $arr[2];
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}
$q = trim(fgets(STDIN));
for($i=0;$i<$q;$i++) {
        $uv = explode(" ",trim(fgets(STDIN)));
        $u1 = $uv[0];
        $v1 = $uv[1];

        foreach($map[$u1] as $c => $vs) {
                $visited = array();
                dfs($map,$u1,$visited,$c);
        //      print_r("for u = $u and c= $c visited=");
        //      print_r($visited);
                $arr = array();
                foreach($visited as $k => $v) {
                        $arr[] = $k;
                }
                for($j=0;$j<count($arr);$j++) {
                        for($kl=0;$kl<$j;$kl++) {
                                add($map,$arr[$j],$arr[$kl],$c);
                        }
                }
        }
        $count = 0;
        foreach($map[$u1] as $c => $vs) {
                if($vs[$v1] == 1) ++$count;
        }
        echo "$count\n";
}

function add(&$map,$u,$v,$c) {
        if($u==$v) return;
        //echo "$u $v c = $c\n";
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}

function dfs($map,$u,&$visited,$c) {
    if($visited[$u] == 1) return;
        $visited[$u] = 1;
        $nbrs = $map[$u][$c];
        foreach($nbrs as $n => $v) {
                dfs($map,$n,$visited,$c);
        }
}

<?php
error_reporting(0);
ini_set('display_errors',0);
$str1 = trim(fgets(STDIN));
$arr = explode(" ",$str1);
$n = $arr[0];
$m = $arr[1];
$map = array();
for($i=0;$i<$m;$i++) {
        $str1 = trim(fgets(STDIN));
        $arr = explode(" ",$str1);
        $u = $arr[0];$v = $arr[1];$c = $arr[2];
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}
$q = trim(fgets(STDIN));
$dfs_done = array();
for($i=0;$i<$q;$i++) {
        $uv = explode(" ",trim(fgets(STDIN)));
        $u1 = $uv[0];
        $v1 = $uv[1];
        if(!isset($dfs_done[$u1]) && !isset($dfs_done[$v1])) {
            foreach($map[$u1] as $c => $vs) {
                    $visited = array();
                    dfs($map,$u1,$visited,$c);
                    $dfs_done[$u1] = 1;
                    $arr = array_keys($visited);
                    $cnt = count($arr);
                    for($j=0;$j<$cnt;$j++) {
                            for($kl=0;$kl<$j;$kl++) {
                                    if($map[$arr[$j]][$arr[$kl]]!=1)
                                            add($map,$arr[$j],$arr[$kl],$c);
                            }
                    }
            }
        }
        $count = 0;
        foreach($map[$u1] as $c => $vs) {
                if($vs[$v1] == 1) ++$count;
        }
        echo "$count\n";
}

function add(&$map,$u,$v,$c) {
        if($u==$v) return;
        //echo "$u $v c = $c\n";
        $map[$u][$c][$v] = 1;
        $map[$v][$c][$u] = 1;
}

function dfs($map,$u,&$visited,$c) {
        if($visited[$u] == 1) return;
        $visited[$u] = 1;
        $nbrs = $map[$u][$c];
        foreach($nbrs as $n => $v) {
                dfs($map,$n,$visited,$c);
        }
}


<?php
fscanf(STDIN, "%d\n", $n);
$a = array();
$line = fgets(STDIN);
$line = explode(' ', $line);
for ( $i = 0; $i < $n; $i+= 1 )
{
    $tmp = (int)$line[$i];
    if ( array_key_exists($tmp, $a) )
        $a[$tmp]+= 1;
    else
        $a[$tmp] = 1;
}
$n-= 1;
$b = $a;
$line = fgets(STDIN);
$line = explode(' ', $line);
for ( $i = 0; $i < $n; $i+= 1 )
{
    $tmp = (int)$line[$i];
    $b[$tmp]-= 1;
    if ( $b[$tmp] == 0 )
        unset($b[$tmp]);
}
reset($b);
#$r = fwrite(STDOUT, printf("%d\n", key($b)));
echo key($b), PHP_EOL;

$a[key($b)]-= 1;
if ( $a[key($b)] == 0 )
    unset($a[key($b)]);

$n-= 1;
$b = $a;
$line = fgets(STDIN);
$line = explode(' ', $line);
for ( $i = 0; $i < $n; $i+= 1 )
{
    $tmp = (int)$line[$i];
    $b[$tmp]-= 1;
    if ( $b[$tmp] == 0 )
        unset($b[$tmp]);
}
reset($b);
#$r = fwrite(STDOUT, printf("%d\n", key($b)));
echo key($b), PHP_EOL;
?>

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

<?php
// 519B     A и B и ошибки компиляции
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$n = (int) $input_line;

$input_line = fgets($in);
$arr1 = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$input_line = fgets($in);
$arr2 = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$input_line = fgets($in);
$arr3 = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

sort($arr1);
sort($arr2);
sort($arr3);

$err2 = $err3 = 0;

for ($i=0; $i < $n-1; $i++) {
    if ($arr1[$i] !== $arr2[$i]) {
        $err2 = $arr1[$i];
        break;
    }
}

if ($err2 == 0) $err2 = $arr1[$n-1];

for ($i=0; $i < $n-2; $i++) {
    if ($arr2[$i] !== $arr3[$i]) {
        $err3 = $arr2[$i];
        break;
    }
}

if ($err3 == 0) $err3 = $arr2[$n-2];

echo "$err2\n$err3\n";

?>

<?php
    $line1 = trim(fgets(STDIN));
    $line2 = explode(" ", trim(fgets(STDIN)));
    $line3 = explode(" ", trim(fgets(STDIN)));
    $line4 = explode(" ", trim(fgets(STDIN)));

$res1[0] = array_diff_assoc( array_count_values($line2), array_count_values($line3) );
$res2[0] = array_diff_assoc( array_count_values($line3), array_count_values($line4) );

function errorSearch($var){
    foreach ($GLOBALS[3] as $val){
        if ($var == $val) {
           $res1++;
        }
    }
}

echo key($res1[0]) . PHP_EOL . key($res2[0]);

<?php
        function getcount($array){
            $result = array();
            foreach ($array as $one){
                if(!isset($result[$one])){
                    $result[$one] = 0;
                }
                $result[$one]++;
            }
            return $result;
        }

        $numOfErr = trim(fgets(STDIN));

        $err1 = explode(' ',trim(fgets(STDIN)));
        $err2 = explode(' ',trim(fgets(STDIN)));
        $err3 = explode(' ',trim(fgets(STDIN)));

        $err1 = getcount($err1);
        $err2 = getcount($err2);
        $err3 = getcount($err3);

        foreach ($err1 as $key => $value){
            if(!isset($err2[$key])){
                fwrite(STDOUT, $key);
                break;
            }
            if($err2[$key] < $value){
                fwrite(STDOUT, $key);
                break;
            }
        }
        fwrite(STDOUT, "\n");
        foreach ($err2 as $key => $value){
            if(!isset($err3[$key])){
                fwrite(STDOUT, $key);
                break;
            }
            if($err3[$key] < $value){
                fwrite(STDOUT, $key);
                break;
            }
        }

    ?>

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

<?php
// 519B     A и B и ошибки компиляции
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$n = (int) $input_line;

$input_line = fgets($in);
$arr1 = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$input_line = fgets($in);
$arr2 = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$input_line = fgets($in);
$arr3 = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

sort($arr1);
sort($arr2);
sort($arr3);

$err2 = $err3 = 0;

for ($i=0; $i < $n-1; $i++) {
    if ($arr1[$i] !== $arr2[$i]) {
        $err2 = $arr1[$i];
        break;
    }
}

if ($err2 == 0) $err2 = $arr1[$n-1];

for ($i=0; $i < $n-2; $i++) {
    if ($arr1[$i] !== $arr3[$i]) {
        $err3 = $arr1[$i];
        break;
    }
}

if ($err3 == 0) {
    if ($arr1[$n-2] !== $err2) {
        $err3 = $arr1[$n-2];
    } else {
        $err3 = $arr1[$n-1];
    }
}

echo "$err2\n$err3\n";

?>

<?php
$wWeight = 0;
$bWeight= 0;
for($i=0; $i < 8; $i++){
    $line[$i] = trim(fgets(STDIN));
    for($j=0; $j < 8; $j++){

        if($line[$i][$j] == 'Q'){
            $wWeight = $wWeight + 9;
        }
        if($line[$i][$j] == 'R'){
            $wWeight = $wWeight+ 5;
        }
        if($line[$i][$j] == 'B' or $line[$i][$j] == 'N'){
            $wWeight = $wWeight + 3;
        }
        if($line[$i][$j] == 'P'){
            $wWeight++;
        }

        if($line[$i][$j] == 'q'){
            $bWeight = $bWeight + 9;
        }
        if($line[$i][$j] == 'r'){
            $bWeight = $bWeight + 5;
        }
        if($line[$i][$j] == 'b' or $line[$i][$j] == 'n'){
            $bWeight = $bWeight + 3;
        }
        if($line[$i][$j] == 'p'){
            $bWeight++;
        }

    }
}

if($wWeight > $bWeight){
    echo "White";
}
if($wWeight < $bWeight){
    echo "Black";
}
if($wWeight == $bWeight){
    echo "Draw";
}

<?php
        function getcount($array){
            $result = array();
            foreach ($array as $one){
                if(!isset($result[$one])){
                    $result[$one] = 0;
                }
                $result[$one]++;
            }
            return $result;
        }

        $numOfErr = trim(fgets(STDIN));

        $err1 = explode(' ',trim(fgets(STDIN)));
        $err2 = explode(' ',trim(fgets(STDIN)));
        $err3 = explode(' ',trim(fgets(STDIN)));

        $err1 = getcount($err1);
        $err2 = getcount($err2);
        $err3 = getcount($err3);

        foreach ($err1 as $key => $value){
            if(!isset($err2[$key])){
                fwrite(STDOUT, $key);
                break;
            }
            if($err2[$key] < $value){
                fwrite(STDOUT, $key);
                break;
            }
        }
        fwrite(STDOUT, '\n');
        foreach ($err2 as $key => $value){
            if(!isset($err3[$key])){
                fwrite(STDOUT, $key);
                break;
            }
            if($err3[$key] < $value){
                fwrite(STDOUT, $key);
                break;
            }
        }

    ?>

<?php
        function getcount($array){
            $result = array();
            foreach ($array as $one){
                if(!isset($result[$one])){
                    $result[$one] = 0;
                }
                $result[$one]++;
            }
            return $result;
        }

        $numOfErr = trim(fgets(STDIN));

        $err1 = explode(' ',trim(fgets(STDIN)));
        $err2 = explode(' ',trim(fgets(STDIN)));
        $err3 = explode(' ',trim(fgets(STDIN)));

        $err1 = getcount($err1);
        $err2 = getcount($err2);
        $err3 = getcount($err3);

        foreach ($err1 as $key => $value){
            if(!isset($err2[$key])){
                fwrite(STDOUT, $key);
                break;
            }
            if($err2[$key] < $value){
                fwrite(STDOUT, $key);
                break;
            }
        }
        fwrite(STDOUT, '\r\n');
        foreach ($err2 as $key => $value){
            if(!isset($err3[$key])){
                fwrite(STDOUT, $key);
                break;
            }
            if($err3[$key] < $value){
                fwrite(STDOUT, $key);
                break;
            }
        }

    ?>


<?php
    $n = fgets(STDIN);
    $ones = 0; $ans = 0;
    $a = explode(' ', trim(fgets(STDIN)));
    for ($i = 0; $i < $n; $i++) if ($a[$i] == 1) $ones++; else $ans = bcadd($ans, $ones);
    echo $ans;


<?php

use SplStack as Stack;

// Maze

function dd($t) {
    var_dump($t);
    die;
}

function printSolution($data)
{
    foreach ($data as $row) {
        foreach ($row as $val) {
            echo $val;
        }
        echo "\n";
    }
}

function getStrSolution($data)
{
    $str = "";
    foreach ($data as $row) {
        foreach ($row as $val) {
            $str .= $val;
        }
        $str .= "\n";
    }
    return $str;
}

function getSolution($data, $rows, $cols, $k)
{
    // Find first .
    foreach ($data as $i => $row) {
        foreach ($row as $j => $value) {
            if ($value == '.') {
                break 2;
            }
        }
    }

    performDFS($data, $i, $j, $k);
    return $data;
}

function performDFS(&$data, $i, $j, $k, $tracker = [])
{
    $step = 0;
    $stack = new Stack();
    $stack->push([$i, $j]);
    $parent = null;
    while (!$stack->isEmpty() && $k > 0) {
        $step++;

        list($i, $j) = $stack->pop();

        if (!isset($tracker[$i][$j])) {
            $tracker[$i][$j]['parent'] = $parent;
        }

        $up = $i - 1;
        $right = $j + 1;
        $down = $i + 1;
        $left = $j - 1;
        $parent = [$i, $j];
        // Right
        if (isset($data[$i][$right]) && $data[$i][$right] == '.' && !isset($tracker[$i][$right])) {
            $stack->push([$i, $right]);
            continue;
        }
        // Down
        if (isset($data[$down][$j]) && $data[$down][$j] == '.' && !isset($tracker[$down][$j])) {
            $stack->push([$down, $j]);
            continue;
        }
        // Left
        if (isset($data[$i][$left]) && $data[$i][$left] == '.' && !isset($tracker[$i][$left])) {
            $stack->push([$i, $left]);
            continue;
        }
        // Up
        if (isset($data[$up][$j]) && $data[$up][$j] == '.' && !isset($tracker[$up][$j])) {
            $stack->push([$up, $j]);
            continue;
        }

        // If come this far we got no other way just write X and decrease K, go back to parent
        $k--;
        $data[$i][$j] = 'X';
        $stack->push($tracker[$i][$j]['parent']);
    }
}

$in = fopen( 'php://stdin', 'r' );
$lineArr = explode(' ', trim(fgets($in)));
$rows = intval($lineArr[0]);
$cols = intval($lineArr[1]);
$k = intval($lineArr[2]);
$data = [];
for ($i=0; $i<$rows; $i++) {
    $line = str_replace("\n", "", fgets($in));
    $data[] = str_split($line);
}
fclose($in);

// $lineArr = explode(' ', "3 4 4");
// $rows = intval($lineArr[0]);
// $cols = intval($lineArr[1]);
// $k = intval($lineArr[2]);

// $data = [
//     ['#', '.', '.', '#'],
//     ['.', '.', '#', '.'],
//     ['#', '.', '.', '.'],
// ];

$out = fopen('php://stdout', 'w');
$answer = getSolution($data, $rows, $cols, $k);
// printSolution($answer);
// die;
// dd(getStrSolution($answer));
fputs($out, getStrSolution($answer));
fclose($out);

<?php

use SplStack as Stack;

// Maze

function dd($t) {
    var_dump($t);
    die;
}

function printSolution($data)
{
    foreach ($data as $row) {
        foreach ($row as $val) {
            echo $val;
        }
        echo "\n";
    }
}

function getSolution($data, $rows, $cols, $k)
{
    // Find first .
    foreach ($data as $i => $row) {
        foreach ($row as $j => $value) {
            if ($value == '.') {
                break 2;
            }
        }
    }

    performDFS($data, $i, $j, $k);
    return $data;
}

function performDFS(&$data, $i, $j, $k, $tracker = [])
{
    $step = 0;
    $stack = new Stack();
    $stack->push([$i, $j]);
    $parent = null;
    while (!$stack->isEmpty() && $k > 0) {
        $step++;

        list($i, $j) = $stack->pop();

        if (!isset($tracker[$i][$j])) {
            $tracker[$i][$j]['parent'] = $parent;
        }

        $up = $i - 1;
        $right = $j + 1;
        $down = $i + 1;
        $left = $i - 1;
        $parent = [$i, $j];
        // Right
        if (isset($data[$i][$right]) && $data[$i][$right] == '.' && !isset($tracker[$i][$right])) {
            $stack->push([$i, $right]);
            continue;
        }
        // Down
        if (isset($data[$down][$j]) && $data[$down][$j] == '.' && !isset($tracker[$down][$j])) {
            $stack->push([$down, $j]);
            continue;
        }
        // Left
        if (isset($data[$i][$left]) && $data[$i][$left] == '.' && !isset($tracker[$i][$left])) {
            $stack->push([$i, $left]);
            continue;
        }
        // Up
        if (isset($data[$up][$j]) && $data[$up][$j] == '.' && !isset($tracker[$up][$j])) {
            $stack->push([$up, $j]);
            continue;
        }

        // If come this far we got no other way just write X and decrease K, go back to parent
        $k--;
        $data[$i][$j] = 'X';
        $stack->push($tracker[$i][$j]['parent']);
    }
}

$in = fopen( 'php://stdin', 'r' );
$lineArr = explode(' ', trim(fgets($in)));
$rows = intval($lineArr[0]);
$cols = intval($lineArr[1]);
$k = intval($lineArr[2]);
$data = [];
for ($i=0; $i<$rows; $i++) {
    $line = str_replace("\n", "", fgets($in));
    $data[] = str_split($line);
}
fclose($in);

// $lineArr = explode(' ', "3 4 4");
// $rows = intval($lineArr[0]);
// $cols = intval($lineArr[1]);
// $k = intval($lineArr[2]);

// $data = [
//     ['#', '.', '.', '#'],
//     ['.', '.', '#', '.'],
//     ['#', '.', '.', '.'],
// ];

$out = fopen('php://stdout', 'w');
$answer = getSolution($data, $rows, $cols, $k);
// printSolution($answer);
// die;
fputs($out, $answer);
fclose($out);

<?php

use SplStack as Stack;

// Maze

function dd($t) {
    var_dump($t);
    die;
}

function printSolution($data)
{
    foreach ($data as $row) {
        foreach ($row as $val) {
            echo $val;
        }
        echo "\n";
    }
}

function getStrSolution($data)
{
    $str = "";
    foreach ($data as $row) {
        foreach ($row as $val) {
            $str .= $val;
        }
        $str .= "\n";
    }
    return $str;
}

function getSolution($data, $rows, $cols, $k)
{
    // Find first .
    foreach ($data as $i => $row) {
        foreach ($row as $j => $value) {
            if ($value == '.') {
                break 2;
            }
        }
    }

    performDFS($data, $i, $j, $k);
    return $data;
}

function performDFS(&$data, $i, $j, $k, $tracker = [])
{
    $step = 0;
    $stack = new Stack();
    $stack->push([$i, $j]);
    $parent = null;
    while (!$stack->isEmpty() && $k > 0) {
        $step++;

        list($i, $j) = $stack->pop();

        if (!isset($tracker[$i][$j])) {
            $tracker[$i][$j]['parent'] = $parent;
        }

        $up = $i - 1;
        $right = $j + 1;
        $down = $i + 1;
        $left = $i - 1;
        $parent = [$i, $j];
        // Right
        if (isset($data[$i][$right]) && $data[$i][$right] == '.' && !isset($tracker[$i][$right])) {
            $stack->push([$i, $right]);
            continue;
        }
        // Down
        if (isset($data[$down][$j]) && $data[$down][$j] == '.' && !isset($tracker[$down][$j])) {
            $stack->push([$down, $j]);
            continue;
        }
        // Left
        if (isset($data[$i][$left]) && $data[$i][$left] == '.' && !isset($tracker[$i][$left])) {
            $stack->push([$i, $left]);
            continue;
        }
        // Up
        if (isset($data[$up][$j]) && $data[$up][$j] == '.' && !isset($tracker[$up][$j])) {
            $stack->push([$up, $j]);
            continue;
        }

        // If come this far we got no other way just write X and decrease K, go back to parent
        $k--;
        $data[$i][$j] = 'X';
        $stack->push($tracker[$i][$j]['parent']);
    }
}

$in = fopen( 'php://stdin', 'r' );
$lineArr = explode(' ', trim(fgets($in)));
$rows = intval($lineArr[0]);
$cols = intval($lineArr[1]);
$k = intval($lineArr[2]);
$data = [];
for ($i=0; $i<$rows; $i++) {
    $line = str_replace("\n", "", fgets($in));
    $data[] = str_split($line);
}
fclose($in);

// $lineArr = explode(' ', "3 4 4");
// $rows = intval($lineArr[0]);
// $cols = intval($lineArr[1]);
// $k = intval($lineArr[2]);

// $data = [
//     ['#', '.', '.', '#'],
//     ['.', '.', '#', '.'],
//     ['#', '.', '.', '.'],
// ];

$out = fopen('php://stdout', 'w');
$answer = getSolution($data, $rows, $cols, $k);
// printSolution($answer);
// die;
fputs($out, getStrSolution($answer));
fclose($out);


<?php
$t = fgets(STDIN);

while ($t) {
	$t = $t - 1;
	$input = explode(" ", fgets(STDIN));

	$x = intdiv($input[0] + $input[2] - 1, $input[2]);
	$y = intdiv($input[1] + $input[3] - 1, $input[3]);

	if ($x + $y <= $input[4]) {
		echo $x, " ", $y, "\n";
	} else {
		echo "-1\n";
	}
}
?>

<?php

while(! feof(STDIN)){
    $arr[]=fgets(STDIN);
}

for($i=0; $i<$arr[0]; $i++){
    $v=explode(" ", $arr[1+$i]);
    $pen=ceil($v[0]/$v[2]);
    $pencil=ceil($v[1]/$v[3]);

    if($pen+$pencil<=$v[4]) echo "$pen $pencil";
    else echo -1;
    if($i!=$arr[0]-1) echo "\n";
}
?>


  <?php

    $tc = (int) readline("");
    for ($i = 0; $i < $tc; $i++) {
        $n = (int)readline("");
        $res = (int) $n;
        $res2 = (int)((int)$n / 2) + ((int)$n / 3);
        $res2 = (int) $res2 * 2;
        $res += $res2;
        print $res;
        print "\n";
    }
    ?>

 <?php

    $tc = (int) readline("");
    for ($i = 0; $i < $tc; $i++) {
        $n = (int)readline("");
        $res = (int) $n;
        $res2 = (int)((int)$n / 2) + ((int)$n / 3);
        $res2 = (int) $res2 * 2;
        $res += $res2;
        print $res;
        print "<br>";
    }
    ?>


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

    for($i=0; $i<$t; $i++) {
        $s = trim(fgets(STDIN));
        $n = 0;
        $iStart = 0;
        $iLast = 0;

        $pos = strpos($s, '1');
        if ($pos === false) {
            echo $n ."\n";
        } else {
           $iStart = $pos;

           $iLast = strripos($s, '1');

           if($iStart == $iLast) {
               echo $n ."\n";
           } else {
               for($j = $iStart; $j < $iLast; $j++ ) {
                   if($s[$j] == '0') {
                       $n++;
                   }
               }
                echo $n."\n";
           }
        }

    }

<?php
fscanf(STDIN,"%d",$n);
while ($n--) {
	$str=trim(fgets(STDIN));
	if ($str==0)
			echo "0\n";
		else
		{
			$rmvZero=trim($str,0);
			$count=0;
			for($i=0;$i<strlen($rmvZero);$i++)
			{

				if($rmvZero[$i]=='0')
					$count++;
			}
			echo "$count\n";

		}

}

<?php
/*dskhbfjkhs*/
$server = "php://stdin";
$handle = fopen($server, "r");
$t = trim(fgets($handle));
for($j=0;$j<$t;$j++)
{
    $s = trim(fgets($handle));
    $first=0;$last=-1;$count=0;
    for ($i=0;$i<strlen($s);$i++)
    {
        if($s[$i]=='1')
        {
            $first=$i;
            break;
        }
    }
    for ($i=strlen($s)-1;$i>=0;$i--)
    {
        if($s[$i]=='1')
        {
            $last=$i;
            break;
        }
    }
    for ($i=$first;$i<=$last;$i++)
    {
        if($s[$i]=='0')
        {
           $count++;
        }
    }
    echo $count."\n";

}

?>


<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    if($b == 1){
        echo sprintf("NO\n");
    }

    else{
        echo sprintf("YES\n");
        echo sprintf("%s %s %s\n", $a * $b, $a, $a * $b + $a);
    }

}

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($b == 1) {
    echo 'NO'.PHP_EOL;
  } else {
    if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
    else { echo 'NO'.PHP_EOL; }
  }
}

?>

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    if($b == 1){
        echo sprintf("NO\n");
    }

    else{
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", $a * $b, $a, $a * $b + $a);
    }

}

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    if($b == 1){
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", 2 * $a, $a, 3 * $a);
    }

    else{
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", $a * $b, $a, $a * $b + $a);
    }

}

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    if($b == 1){
        echo sprintf("no\n");
        echo sprintf("%d %d %d\n", 2 * $a, $a, 3 * $a);
    }

    else{
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", $a * $b, $a, $a * $b + $a);
    }

}

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    if($b === 1){
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", 2 * $a, $a, 3 * $a);
    }

    else{
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", $a * $b, $a, $a * $b + $a);
    }

}

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", $a * $b, $a, $a * $b + $a);

}

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    if($a % $b === 0)
        echo sprintf("NO\n");

    else{
        echo sprintf("YES\n");
        echo sprintf("%d %d %d\n", $a * $b, $a, $a * $b + $a);
    }

}

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($b == 1) {
    echo 'NO'.PHP_EOL;
    return;
  } else {
    if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
    else { echo 'NO'.PHP_EOL; }
  }
}

?>

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($b == 1) {
    echo 'NO'.PHP_EOL;
    return;
  }

  if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
  else { echo 'NO'.PHP_EOL; }
}

?>

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($b == 1) {
    $x = $a;
    $y = 95 * 2;
    $z = $x + $y;
    echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL;
    return;
  }

  if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
  else { echo 'NO'.PHP_EOL; }
}

?>

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($b == 1) {
    $x = $a;
    $y = 95;
    $z = $x + $y;
    echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL;
    return;
  }

  if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
  else { echo 'NO'.PHP_EOL; }
}

?>

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($b == 1) {
    $x = $a * 2;
    $y = 0;
    $z = $x + $y;
    echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL;
    return;
  }

  if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
  else { echo 'NO'.PHP_EOL; }
}

?>

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

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

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

  $k = $a * $b;
  $c = ($k - $a) / $a;
  if ($c == 1) { $c = 3; }
  $x = $a; $y = $c * $a; $z = $x + $y;

  if ($z % $k == 0) { echo 'YES'.PHP_EOL; echo $x.' '.$y.' '.$z.PHP_EOL; }
  else { echo 'NO'.PHP_EOL; }
}

?>


<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = 'abababababababab???????????ca';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'abb';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();
$mas2 = array();

$auto = '';

for ($i = 0; $i < strlen($t); $i++)
{
	$auto .= '?';

	$mas[$t[$i]] = 0;
	if (!$mas2[$t[$i]])
		$mas2[$t[$i]] = 1;
	else
		$mas2[$t[$i]] += 1;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//var_export($mas);

//найдем наименьший делитель
$d = false;
foreach ($mas2 as $k=>$v)
{
	if ($d === false || floor($mas[$k]/$mas2[$k]) < $d) $d = floor($mas[$k]/$mas2[$k]);
}

//Уберем символы из которых уже можно составить слова
foreach ($mas as $k=>$v)
{
	$mas[$k] -= $mas2[$k] * $d;
}

//echo $d;
//var_export($mas);

$rep_cnt = 0;
//считаем вхождения
$flag = true;
if (sizeof($mas2) <= 0) $flag = false;
while ($flag)
{
	//бежим по всем буквам и забираем их
	$reserv = false;
	foreach($mas2 as $k=>$v)
	{
		$mas[$k] -= $v;
		if ($mas[$k] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			//echo "no lit $rep_cnt \n";
			/*if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}*/
			for ($i = $mas[$k]; $i < 0; $i++)
			{
				if (isset($rep[$rep_cnt]))
				{
					$pos = $rep[$rep_cnt];
					$mas[$k] ++;
					$rep_cnt ++;
					$out[$pos] = $k;
				}
				else
				{
					$flag = false;
					break 2;
				}
			}

		}
		else
		{
			$reserv = true;
		}
	}
	/*
	//Eсли нет ни одной буквы в резерве, меняем вопросики пучками
	if (!$reserv)
	{
		//echo "RESERV OUT\n";
		//echo $out." ";
		$out = str_replace($auto, $t, $out);
		//echo "|".$out."|\n";
		$out = str_replace('?', $t[0], $out);
		//echo "|".$out."|\n";
		$flag = false;
	}*/
}

echo $out;
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = 'abababababababab???????????ca';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'abb';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();
$mas2 = array();

$auto = '';

for ($i = 0; $i < strlen($t); $i++)
{
	$auto .= '?';

	$mas[$t[$i]] = 0;
	if (!$mas2[$t[$i]])
		$mas2[$t[$i]] = 1;
	else
		$mas2[$t[$i]] += 1;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//var_export($mas);

//найдем наименьший делитель
$d = false;
foreach ($mas2 as $k=>$v)
{
	if ($d === false || floor($mas[$k]/$mas2[$k]) < $d) $d = floor($mas[$k]/$mas2[$k]);
}

//Уберем символы из которых уже можно составить слова
foreach ($mas as $k=>$v)
{
	$mas[$k] -= $mas2[$k] * $d;
}

//echo $d;
//var_export($mas);

//$rep_cnt = sizeof($rep);
$rep_cnt = 0;
//считаем вхождения
$flag = true;
if (sizeof($mas2) <= 0) $flag = false;
while ($flag)
{
	//бежим по всем буквам и забираем их
	$reserv = false;
	foreach($mas2 as $k=>$v)
	{
		$mas[$k] -= $v;
		if ($mas[$k] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			//echo "no lit $rep_cnt \n";
			/*
			for ($i = $mas[$k]; $i < 0; $i++)
			{
				if ($rep_cnt > 0)
				{
					$rep_cnt --;
					$mas[$k] ++;
					//$out = preg_replace('@\?@', $k, $out, 1);
					$pos = strpos($out, '?');
					$out[$pos] = $k;
				}
				else
				{
					$flag = false;
					break;
				}
			}*/

			for ($i = $mas[$k]; $i < 0; $i++)
			{
				if (isset($rep[$rep_cnt]))
				{
					$pos = $rep[$rep_cnt];
					$mas[$k] ++;
					$rep_cnt ++;
					$out[$pos] = $k;
				}
				else
				{
					$flag = false;
					break 2;
				}
			}

		}
		else
		{
			$reserv = true;
		}
	}

	//Eсли нет ни одной буквы в резерве, меняем вопросики пучками
	if (!$reserv)
	{
		//echo "RESERV OUT\n";
		//echo $out." ";
		$cnt = 0;
		$out = str_replace($auto, $t, $out, $cnt);
		$rep_cnt += $cnt * strlen($t);
		//echo "|".$out."|\n";
		//$out = str_replace('?', $t[0], $out);
		//echo "|".$out."|\n";
		//$flag = false;
	}
}

echo $out;
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = '?aa?';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'ab';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();
$mas2 = array();

$auto = '';

for ($i = 0; $i < strlen($t); $i++)
{
	$auto .= '?';

	$mas[$t[$i]] = 0;
	if (!$mas2[$t[$i]])
		$mas2[$t[$i]] = 1;
	else
		$mas2[$t[$i]] += 1;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//найдем наименьший делитель
$d = false;
foreach ($mas2 as $k=>$v)
{
	if ($d === false || floor($mas[$k]/$mas2[$k]) < $d) $d = floor($mas[$k]/$mas2[$k]);
}

//Уберем символы из которых уже можно составить слова
foreach ($mas as $k=>$v)
{
	$mas[$k] -= $mas2[$k] * $d;
}

$rep_cnt = 0;
//считаем вхождения
$flag = true;
while ($flag)
{
	//бежим по всем буквам и забираем их
	$reserv = false;
	foreach($mas2 as $k=>$v)
	{
		$mas[$k] -= 1;
		if ($mas[$k] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			//echo "no lit $rep_cnt \n";
			/*if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}*/

			if (isset($rep[$rep_cnt]))
			{
				$pos = $rep[$rep_cnt];
				$mas[$k] ++;
				$rep_cnt ++;
				$out[$pos] = $k;
			}
			else
			{
				$flag = false;
				break;
			}

		}
		else
		{
			$reserv = true;
		}
	}

	//Eсли нет ни одной буквы в резерве, меняем вопросики пучками
	if (!$reserv)
	{
		//echo "RESERV OUT\n";
		//echo $out." ";
		$out = str_replace($auto, $t, $out);
		//echo "|".$out."|\n";
		$out = str_replace('?', $t[0], $out);
		//echo "|".$out."|\n";
		$flag = false;
	}
}

echo $out;

function get_min($mas)
{
	$res = false;
	foreach($mas as $k=>$v)
	{
		if ($res === false || $mas[$k] < $mas[$res]) $res = $k;
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = '?aa?';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'ab';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();

for ($i = 0; $i < strlen($t); $i++)
{
	$mas[$t[$i]] = 0;
}

$rep_cnt = 0;

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//считаем вхождения
$flag = true;
while ($flag)
{
	//бежим по всем буквам и забираем их
	for ($i = 0; $i < strlen($t); $i++)
	{
		$mas[$t[$i]] -= 1;
		if ($mas[$t[$i]] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				echo "{$t[$i]}=> {$mas[$t[$i]]} \n";
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}
		}
	}
}

echo $out;

function get_min($mas)
{
	$res = false;
	foreach($mas as $k=>$v)
	{
		if ($res === false || $mas[$k] < $mas[$res]) $res = $k;
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = '?aa?';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'ab';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();

for ($i = 0; $i < strlen($t); $i++)
{
	$mas[$t[$i]] = 0;
}

$rep_cnt = 0;

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (strpos($t, $s[$i]) === false) continue;

	if ($mas[$s[$i]])
		$mas[$s[$i]] += 1;
	else
		$mas[$s[$i]] = 1;
}

//расходуем вопросики на символы
for ($i = 0; $i < $rep_cnt; $i++)
{
	//Взять самую необходимую букву
	$a = get_min($mas);
	$mas[$a] ++;
	$out = preg_replace('@\?@', $a, $out, 1);
}

echo $out;

function get_min($mas)
{
	$res = false;
	foreach($mas as $k=>$v)
	{
		if ($res === false || $mas[$k] < $mas[$res]) $res = $k;
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = '?aa?';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'ab';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();
$mas2 = array();

$auto = '';

for ($i = 0; $i < strlen($t); $i++)
{
	$auto .= '?';

	$mas[$t[$i]] = 0;
	if (!$mas2[$t[$i]])
		$mas2[$t[$i]] = 1;
	else
		$mas2[$t[$i]] += 1;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//var_export($mas);

//найдем наименьший делитель
$d = false;
foreach ($mas2 as $k=>$v)
{
	if ($d === false || floor($mas[$k]/$mas2[$k]) < $d) $d = floor($mas[$k]/$mas2[$k]);
}

//Уберем символы из которых уже можно составить слова
foreach ($mas as $k=>$v)
{
	$mas[$k] -= $mas2[$k] * $d;
}

//echo $d;
//var_export($mas);

$rep_cnt = 0;
//считаем вхождения
$flag = true;
while ($flag)
{
	//бежим по всем буквам и забираем их
	$reserv = false;
	foreach($mas2 as $k=>$v)
	{
		$mas[$k] -= $v;
		if ($mas[$k] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			//echo "no lit $rep_cnt \n";
			/*if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}*/
			for ($i = $mas[$k]; $i < 0; $i++)
			{
				if (isset($rep[$rep_cnt]))
				{
					$pos = $rep[$rep_cnt];
					$mas[$k] ++;
					$rep_cnt ++;
					$out[$pos] = $k;
				}
				else
				{
					$flag = false;
					break 2;
				}
			}

		}
		else
		{
			$reserv = true;
		}
	}

	//Eсли нет ни одной буквы в резерве, меняем вопросики пучками
	if (!$reserv)
	{
		//echo "RESERV OUT\n";
		//echo $out." ";
		$out = str_replace($auto, $t, $out);
		//echo "|".$out."|\n";
		$out = str_replace('?', $t[0], $out);
		//echo "|".$out."|\n";
		$flag = false;
	}
}

echo $out;

function get_min($mas)
{
	$res = false;
	foreach($mas as $k=>$v)
	{
		if ($res === false || $mas[$k] < $mas[$res]) $res = $k;
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = '?aa?';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'ab';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();

for ($i = 0; $i < strlen($t); $i++)
{
	$mas[$t[$i]] = 0;
}

for ($i = 0; $i < strlen($s); $i++)
{
	//Если буква нет во второй строке, мне она не нужна
	if (strpos($t, $s[$i]) === false && $s[$i] != '?') continue;

	if ($mas[$s[$i]])
		$mas[$s[$i]] += 1;
	else
		$mas[$s[$i]] = 1;
}

//расходуем вопросики на символы
for ($i = 0; $i < $mas['?']; $i++)
{
	//Взять самую необходимую букву
	$a = get_min($mas);
	$mas[$a] ++;
	$out = preg_replace('@\?@', $a, $out, 1);
}

echo $out;

function get_min($mas)
{
	$res = false;
	foreach($mas as $k=>$v)
	{
		if ($res === false || $mas[$k] < $mas[$res]) $res = $k;
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = '?aa?';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'ab';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();

for ($i = 0; $i < strlen($t); $i++)
{
	$mas[$t[$i]] = 0;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

$size_t = strlen($t);
$rep_cnt = 0;
//считаем вхождения
$flag = true;
while ($flag)
{
	//бежим по всем буквам и забираем их
	for ($i = 0; $i < $size_t; $i++)
	{
		$mas[$t[$i]] -= 1;
		if ($mas[$t[$i]] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			/*
			if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}*/

			if ($rep[$rep_cnt] > 0)
			{
				$pos = $rep[$rep_cnt];
				$mas[$t[$i]] ++;
				$rep_cnt ++;
				$out[$pos] = $t[$i];
			}
			else
			{
				$flag = false;
				break;
			}

		}
	}
}

echo $out;

function get_min($mas)
{
	$res = false;
	foreach($mas as $k=>$v)
	{
		if ($res === false || $mas[$k] < $mas[$res]) $res = $k;
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = 'abababababababab???????????ca';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'abb';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();
$mas2 = array();

$auto = '';

for ($i = 0; $i < strlen($t); $i++)
{
	$auto .= '?';

	$mas[$t[$i]] = 0;
	if (!$mas2[$t[$i]])
		$mas2[$t[$i]] = 1;
	else
		$mas2[$t[$i]] += 1;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//var_export($mas);

//найдем наименьший делитель
$d = false;
foreach ($mas2 as $k=>$v)
{
	if ($d === false || floor($mas[$k]/$mas2[$k]) < $d) $d = floor($mas[$k]/$mas2[$k]);
}

//Уберем символы из которых уже можно составить слова
foreach ($mas as $k=>$v)
{
	$mas[$k] -= $mas2[$k] * $d;
}

//echo $d;
//var_export($mas);

$rep_cnt = 0;
//считаем вхождения
$flag = true;
while ($flag)
{
	//бежим по всем буквам и забираем их
	$reserv = false;
	foreach($mas2 as $k=>$v)
	{
		$mas[$k] -= $v;
		if ($mas[$k] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			//echo "no lit $rep_cnt \n";
			/*if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}*/
			for ($i = $mas[$k]; $i < 0; $i++)
			{
				if (isset($rep[$rep_cnt]))
				{
					$pos = $rep[$rep_cnt];
					$mas[$k] ++;
					$rep_cnt ++;
					$out[$pos] = $k;
				}
				else
				{
					$flag = false;
					break 2;
				}
			}

		}
		else
		{
			$reserv = true;
		}
	}

	//Eсли нет ни одной буквы в резерве, меняем вопросики пучками
	if (!$reserv)
	{
		//echo "RESERV OUT\n";
		//echo $out." ";
		$out = str_replace($auto, $t, $out);
		//echo "|".$out."|\n";
		$out = str_replace('?', $t[0], $out);
		//echo "|".$out."|\n";
		$flag = false;
	}
}

echo $out;
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $s = trim(fgets($fp));
else
	$s = 'abababababababab???????????ca';

if (!_DEBUG) $t = trim(fgets($fp));
else
	$t = 'abb';

$out = $s;
//набираем массив, какими буквами можем пользоваться
$mas = array();
$mas2 = array();

$auto = '';

for ($i = 0; $i < strlen($t); $i++)
{
	$auto .= '?';

	$mas[$t[$i]] = 0;
	if (!$mas2[$t[$i]])
		$mas2[$t[$i]] = 1;
	else
		$mas2[$t[$i]] += 1;
}

$rep_cnt = 0;
$rep = array();

for ($i = 0; $i < strlen($s); $i++)
{
	if ($s[$i] == '?') $rep[] = $i;
	//if ($s[$i] == '?') $rep_cnt ++;
	//Если буква нет во второй строке, мне она не нужна
	if (!isset($mas[$s[$i]])) continue;

	$mas[$s[$i]] += 1;
}

//var_export($mas);

//найдем наименьший делитель
$d = false;
foreach ($mas2 as $k=>$v)
{
	if ($d === false || floor($mas[$k]/$mas2[$k]) < $d) $d = floor($mas[$k]/$mas2[$k]);
}

//Уберем символы из которых уже можно составить слова
foreach ($mas as $k=>$v)
{
	$mas[$k] -= $mas2[$k] * $d;
}

//echo $d;
//var_export($mas);

$rep_cnt = 0;
//считаем вхождения
$flag = true;
if (sizeof($mas2) <= 0) $flag = false;
while ($flag)
{
	//бежим по всем буквам и забираем их
	$reserv = false;
	foreach($mas2 as $k=>$v)
	{
		$mas[$k] -= $v;
		if ($mas[$k] < 0)
		{//буквы кончились, смотрим есть ли символы замены
			//echo "no lit $rep_cnt \n";
			/*if ($rep_cnt > 0)
			{
				$rep_cnt --;
				$mas[$t[$i]] ++;
				$out = preg_replace('@\?@', $t[$i], $out, 1);
			}
			else
			{
				$flag = false;
				break;
			}*/
			for ($i = $mas[$k]; $i < 0; $i++)
			{
				if (isset($rep[$rep_cnt]))
				{
					$pos = $rep[$rep_cnt];
					$mas[$k] ++;
					$rep_cnt ++;
					$out[$pos] = $k;
				}
				else
				{
					$flag = false;
					break 2;
				}
			}

		}
		else
		{
			$reserv = true;
		}
	}

	//Eсли нет ни одной буквы в резерве, меняем вопросики пучками
	if (!$reserv)
	{
		//echo "RESERV OUT\n";
		//echo $out." ";
		$out = str_replace($auto, $t, $out);
		//echo "|".$out."|\n";
		$out = str_replace('?', $t[0], $out);
		//echo "|".$out."|\n";
		$flag = false;
	}
}

echo $out;
?>


<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$x= trim(fgets($handle));
$a = trim(fgets($handle));
$p = explode(' ', $a);
$y= trim(fgets($handle));
$a1 = trim(fgets($handle));
$p1 = explode(' ', $a1);
rsort($p);
rsort($p1);
echo $p[0]." ".$p1[0]."\n";
?>

<?php

$n = rtrim(fgets(STDIN));
$a = rtrim(fgets(STDIN));
$m = rtrim(fgets(STDIN));
$b = rtrim(fgets(STDIN));

$a = explode(" ", $a);
$b = explode(" ", $b);

sort($a);
sort($b);

echo $a[$n-1]. " " . $b[$m-1];

?>


<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    $odd = 0;
    foreach ($arr = fgetcsv(STDIN, 0, ' ') as $value) {
        $odd += $value & 1;
    }
    printf("%d\n", min($odd, $n-$odd));
}

<?php
$iter = InOutPut::get();

for($i=0; $i <$iter; $i++) {
       $ans = 12;
       $n = InOutPut::get();
       $a = InOutPut::getArr();

       $even = 0; $odd = 0;

       for($j=0; $j < $n; $j++){
           if($a[$j]%2==0){
             $even++;
           } else {
             $odd++;
           }
       }
       $ans = $even > $odd ? $odd : $even;
       InOutPut::print($ans);
}

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

     public static function getArr()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function print($string)
     {
      echo $string . "\n";
     }
 }
 ?>

<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";
define("INTMAXVALUE",     2147483646);

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

 function solve()
 {

     $n = IO::getInt();
     $a = IO::getArray();
     $ans = 0;
     $count= 0;
     for($i=0; $i<$n; $i++) {
        if($a[$i] % 2 == 1) {
             $count++;
        }  else {
            $ans++;
        }
     }
     //  var_dump($a);
       IO::pr(IO::getMinValue($count, $ans));
 }

 class IO {
      public static function getInt()
      {
          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;
     }
 }

 class Algor {
     public static function efclidLcm($a, $b) {
         return ($a  / self::efclidGcd($a, $b)) * $b;
     }
     public static function efclidGcd($a, $b) {
             return $b > 0 ? self::efclidGcd($b, $a % $b) : $a;
     }
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

     public static function fabicon($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];
     }

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

}

class bigOperation {
     public static function efclidLcm($a, $b) {
         return bcmul(bcdiv($a,  self::efclidGcd($a, $b)), $b);
     }
     public static function efclidGcd($a, $b) {
             return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a;
     }
    public static function  isBigNumber($n)
    {
        return bccomp($n, INTMAXVALUE) == 1;
    }
    // bcadd — Сложить 2 числа произвольной точности
    public static function  bcAdd($x, $y)
    {
        return bcadd($x, $y);
    }
// bccomp — Сравнение двух чисел произвольной точности
//return 1 if x>y, 0= x==y, -1 x < y
    public static function  bcComp($x, $y)
    {
        return bccomp($x, $y);
    }
// bcdiv — Операция деления для чисел произвольной точности
    public static function  bcDiv($x, $y)
    {
        return bcdiv($x, $y);
    }
// bcmod — Получает остаток от деления чисел с произвольной точностью
    public static function  bcMod($x, $y)
    {
        return bcmod($x, $y);
    }
// bcmul — Умножение двух чисел с произвольной точностью
    public static function  bcMul($x, $y)
    {
        return bcmul($x, $y);
    }
// bcpow — Возведение в степень чисел с произвольной точностью
    public static function  bcPow($x, $y)
    {
        return bcpow($x, $y);
    }
// bcpowmod — Возводит одно число в степень другого и возвращает остаток от деления результата на третье число
// bcscale — Задает количество чисел после десятичной точки по умолчанию для всех bc math функций.
// bcsqrt — Извлекает квадратный корень из числа с произвольной точностью
    public static function  bcSqrt($x, $y)
    {
        return bcsqrt($x, $y);
    }
// bcsub — Вычитает одно число с произвольной точностью из другого
    public static function  bcSub($x, $y)
    {
        return bcsub($x, $y);
    }
    public static function getMaxValue($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    public static function getMinValue($x, $y) {
        return bccomp($x, $y) == 1 ? $y : $x;
    }

    public static function getDareje($n, $k) {
        if($k == 0) {
            return 1;
        }
        return bcmul($n, self::getDareje($n, $k-1));
    }
}

class Sorting
{
    public static function mergeSort($aArray) {
        if(count($aArray) <= 1) {
            return $aArray;
        }
        $aLeft = [];
        $aRight = [];
        $n =floor(count($aArray) / 2);
        for($i = 0; $i <$n; $i++) {
            $aLeft[] = $aArray[$i];
        }
        for($i = $n; $i <count($aArray); $i++) {
            $aRight[] = $aArray[$i];
        }

        return self::merge(self::mergeSort($aLeft), self::mergeSort($aRight));
    }

    public static function merge($aLeft, $aRight) {
        $aResult = [];
        $iL = 0;
        $iR = 0;

        while($iL < count($aLeft) && $iR < count($aRight)) {
            if($aLeft[$iL] <= $aRight[$iR]) {
                $aResult[] = $aLeft[$iL];
                $iL++;
            } else {
                $aResult[] = $aRight[$iR];
                $iR++;
            }
        }

        while($iL < count($aLeft)) {
            $aResult[] = $aLeft[$iL];
            $iL++;
        }
        while($iR < count($aRight)) {
            $aResult[] = $aRight[$iR];
            $iR++;
        }

        return $aResult;

    }
}

class SolveArchive
{

}

<?php
$iter = InOutPut::get();

for($i=0; $i <$iter; $i++) {
       $ans = 12;
       $n = InOutPut::get();
       $a = InOutPut::getArr();

       $even = 0; $odd = 0;

       for($j=0; $j < $n; $j++){
	       	if($a[$j]%2==0){
	       		$even++;
	       	} else {
	       		$odd++;
	       	}
	       	if($even==$n || $odd==$n){
	       		$ans=0;
	       		break;
	       	} else if (abs($even-$odd) <= 1 ){
	       		$ans = abs($even-$odd);
	       	}

       }

       InOutPut::print($ans);
}

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

     public static function getArr()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function print($string)
     {
      echo $string . "\n";
     }
 }
 ?>


<?php

$n = (int)trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

$n = count($a);

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

while (true) {
  $done = true;
  for ($i = 0; $i+1 < $n; $i ++) {
    if ($a[$i] > 0) {
      $done = false;
      print 'P';
      $a[$i] --;
    }
    print 'R';
  }
  for ($i = $n-1; $i-1 >= 0; $i --) {
    if ($a[$i] > 0) {
      $done = false;
      print 'P';
      $a[$i] --;
    }
    print 'L';
  }
  if ($done) break;
}

<?php

$arr = array();
while ($line = trim(fgets(STDIN)))
    $arr[] = $line;

$current= explode(' ', $arr[1]);

$count = $arr[0];
$pos_last = $arr[0] - 1;
$count_puts = 0;
for( $i = 0; $i < $count; $i++){
    $count_puts += $current[$i];
}
$pos = 0;
$puts = 0;
while( true ){
    if(++$count_steps > 1000000)
        exit;
    if($current[ $pos ] > 0){
        $current[ $pos ]--;
        $puts++;
        echo 'P';
    }
    if($puts == $count_puts){
        exit;
    }
    if($pos > 0){
        if($current[ $pos - 1 ]  > 0){
            $pos--;
            echo 'L';
            continue;
        }
    }
    if ($pos_last > $pos) {
        echo 'R';
        $pos++;
        continue;
    }
    if ($pos_last == $pos) {
        echo 'L';
        $pos--;
        continue;
    }
}


<?php

function solve($q,$st) {
    $ans = [] ;
    $n = (int) $q[0] ;
    $l = (int) $q[1] ;
    $posf = array() ;
    $posl = array() ;
    $arr = array_map('intval',explode(" ",$st));
    for($i=0; $i<$n; $i++) {
        if($posf[$arr[$i]] === null) {
            $posf[$arr[$i]] = $i ;
        }
    }
    for($j=$n-1; $j > -1; $j--) {
        if($posl[$arr[$j]] === null) {
            $posl[$arr[$j]] = $j ;
        }
    }
//    print_r($posf);
//    print_r($posl);
    while($l--) {
        [$lo,$up] = array_map('intval',explode(" ",trim(fgets(STDIN)))) ;
        if( ($posf[$lo] !== null & $posl[$up] !== null ) && ($posf[$lo] < $posl[$up])) {
            $ans[] = "YES" ;
        }
        else {
            $ans[] = "NO" ;
        }
    }

    print_r(implode("\n",$ans)) ;
}

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

<?php

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

while ($tc-- > 0) {
    fgets(STDIN); // discard one line

    $n = 0; $q = 0;

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

    $instr = trim(fgets(STDIN));
    $stations = array_map('intval', explode(' ', $instr));

    $l = array(); $r = array();
    foreach($stations as $id => $st) {
        if (!array_key_exists($st, $l)) {
            $l[$st] = $id;
        }
        $r[$st] = $id;
    }

    $s1; $s2;
    for ($i = 0; $i < $q; $i++) {
        fscanf(STDIN, "%d %d", $s1, $s2);
        $reachable = false;
        if (array_key_exists($s1, $r) && array_key_exists($s2, $r)) {
            if ($l[$s1] < $r[$s2]) $reachable = true;
        }
        if ($reachable) echo "YES\n";
        else echo "NO\n";
    }
}

<?php

function solve($q,$st) {
    $ans = [] ;
    $n = (int) $q[0] ;
    $l = (int) $q[1] ;
    $posf = array() ;
    $posl = array() ;
    $arr = array_map('intval',explode(" ",$st));
    for($i=0; $i<$n; $i++) {
        if($posf[$arr[$i]] === null) {
            $posf[$arr[$i]] = $i ;
        }
    }
    for($j=$n-1; $j > -1; $j--) {
        if($posl[$arr[$j]] === null) {
            $posl[$arr[$j]] = $j ;
        }
    }
//    print_r($posf);
//    print_r($posl);
    while($l--) {
        [$lo,$up] = array_map('intval',explode(" ",trim(fgets(STDIN)))) ;
        if($posf[$lo] < $posl[$up]) {
            $ans[] = "YES" ;
        }
        else {
            $ans[] = "NO" ;
        }
    }

    print_r(implode("\n",$ans)) ;
}

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

<?php

function brings($a,$b,$arr) {
    /*
    if($arr[$a] === 0) {
        return false ;
    }
    if($arr[$a] === $b) {
        return true ;
    }
    else {
        return brigns($arr[$a],$b,$arr) ;
    }
    */
    $cur = $a ;
    $mark = [];
    //print_r($a);
    //print_r($b);
    while(true) {
//        print_r($cur);
        if($arr[$cur] === null || $mark[$cur] === true) {
            return false ;
        }
        else if(in_array($b,$arr[$cur])) {
            return true ;
        }
        else {
            $mark[$cur] = true;
            $cur = $arr[$cur][0] ;
        }
    }

}
function solve($q,$st) {
    $ans = [] ;
    $n = (int) $q[0] ;
    $l = (int) $q[1] ;
    $lok = array();
    $arr = array_map('intval',explode(" ",$st));
//    var_dump($lok);
    for($i=1;$i<$n;$i++) {
        //print_r($i);
        if(!isset($lok[$arr[$i-1]])) {
            $lok[$arr[$i-1]] = array() ;
            if((!in_array($arr[$i],$lok[$arr[$i-1]])) && $arr[$i] !== $arr[$i-1]) {
                array_push($lok[$arr[$i-1]],$arr[$i]) ;
            }
//            print_r($lok[$arr[$i-1]]);
        }
        else {
            if((!in_array($arr[$i],$lok[$arr[$i-1]])) && $arr[$i] !== $arr[$i-1]) {
                array_push($lok[$arr[$i-1]],$arr[$i]) ;
            }
        }
        //print_r("okay");
//        print_r($lok[$arr[$i-1]]);
    }
//    print_r($lok);
    //print_r($arr) ;
    //print_r($n) ;
    //print_r($l) ;

    for($i=0;$i<$l;$i++) {
        $inp1 = array_map('intval',explode(" ",trim(fgets(STDIN)))) ;
        //print_r($inp1[0]);
        //print_r($inp1[1]);

        if(brings($inp1[0],$inp1[1],$lok)) {
            $ans[] = "YES" ;
        }
        else {
            $ans[] = "NO" ;
        }
    }
    print_r(implode("\n",$ans)) ;
}

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


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

<?php
    fscanf(STDIN,"%d",$n);
    for($i=$n ; $i<$n*2 ; $i++)
        fprintf(STDOUT,"%d ",$i);
?>

<?

error_reporting(false);
//error_reporting(E_ALL);

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

if (file_exists("in.txt")) {
    $handle = fopen('in.txt', 'r');
    set_time_limit(0);
};

$map = array();

$n = 0;

$num = trim(fgets($handle));;
$i = $num;

while(1){

    $i++;
    $n++;

    echo $i." ";

    //$map[$i] = 1;
    //del($i);

    if ($n >= $num) break;
}


<?php

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

     $input = fopen($in,"r");
     list($i)=explode(" ",trim(fgets($input)));
     $c=str_split(trim(fgets($input)),1);
     $k=0;
     $str="0000000000";
     $count=0;
     foreach($c as $item)
     {
          if($item=='L'){
               while($count<10)
               {
                    if($str[$count] == 1)
                    {
                                             $count++;
                    }else
                    {
                        $str[$count] = 1;
                        break;
                    }

               }
          }
          if($item=='R'){
               $count = 9;
               while($count>=0)
               {
                    if($str[$count] == 1)
                    {
                         $count--;
                    }else
                    {
                        $str[$count] = 1;
                        break;
                    }

               }
          }
          if(($item<>'L')&&($item<>'R'))
          {
               $str[$item]= 0 ;
          }
          $count = 0;
     }
     echo $str;

     // // $output = explode(" ",trim(fgets($input)));
     // $output = str_split($input);
     // foreach ($output as $key){
     //      echo $key." ";
     // }
     ?>

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$aArrays = trim(fgets(STDIN));
$aTest = [];
for ($i = 0; $i < 10; $i++){
    $aTest[$i] = 0;
}
for ($i = 0; $i < strlen($aArrays); $i++){
    if($aArrays[$i] == 'L') {
        $iKey = array_search(0,$aTest);
        $aTest[$iKey] = 1;
    } elseif($aArrays[$i] == 'R'){
        $aTest = array_reverse($aTest);
        $iKey = array_search(0,$aTest);
        $aTest[$iKey] = 1;
        $aTest = array_reverse($aTest);
    } else {
        $aTest[$aArrays[$i]] = 0;
    }
}

echo implode($aTest);
//1010000011
//1100000010

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$aArrays = trim(fgets(STDIN));
$aTest = [];
for ($i = 0; $i < 10; $i++){
    $aTest[$i] = 0;
}
echo array_search(0,$aTest) . "\n";
for ($i = 0; $i < strlen($aArrays); $i++){
    if($aArrays[$i] == 'L') {
        $iKey = array_search(0,$aTest);
        $aTest[$iKey] = 1;
    } elseif($aArrays[$i] == 'R'){
        $aTest = array_reverse($aTest);
        $iKey = array_search(0,$aTest);
        $aTest[$iKey] = 1;
        $aTest = array_reverse($aTest);
    } else {
        $aTest[$aArrays[$i]] = 0;
    }
}

echo implode($aTest);
//1010000011
//1100000010

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$aArrays = trim(fgets(STDIN));
$aTest = [];
for ($i = 0; $i < $n; $i++){
    $aTest[$i] = 0;
}
echo array_search(0,$aTest) . "\n";
for ($i = 0; $i < strlen($aArrays); $i++){
    if($aArrays[$i] == 'L') {
        $iKey = array_search(0,$aTest);
        $aTest[$iKey] = 1;
    } elseif($aArrays[$i] == 'R'){
        $aTest = array_reverse($aTest);
        $iKey = array_search(0,$aTest);
        $aTest[$iKey] = 1;
        $aTest = array_reverse($aTest);
    } else {
        $aTest[$aArrays[$i]] = 0;
    }
}

echo implode($aTest);


<?php
$a = trim(fgets(STDIN));
$b = str_split($a);
$c = 1;
$d = array();
for($x = 0; $x < count($b); $x++)
{
    if($b[$x] == $b[$x + 1])
    {
        $c++;
        array_push($d, $c);
    }
    else
    {
        $c = 1;
        array_push($d, $c);
    }
}
rsort($d);
print $d[0];
?>


<?php

namespace io {
	$input_file_content = file_get_contents("php://stdin");
	$input_buf = explode("\r\n", $input_file_content);
	unset($input_file_content);
}

namespace main {
	error_reporting(E_ALL);
	ini_set('display_errors', true);
	ini_set('html_errors', false);

	use function io\next_line as next_line;
	use function io\next_ as next;
	use function io\next_int as next_int;
	use function io\next_double as next_double;

	$n = next_int();
	$a = next_int();
	$b = next_int();
	$k = next_int();

	$hh = [];
	$z = $a + $b;
	for($i=0; $i<$n; $i++) {
		$h = next_int();
		$t = (($h - 1) % $z) + 1;
		$hh[] = intdiv($t-1, $a);
	}

	sort($hh);

	$c = 0; $ans = 0;
	for($i=0; $i<$n; $i++) {
		if($c + $hh[$i] <= $k) {
			$c += $hh[$i];
			$ans++;
		}
		else break;
	}

	printf("%d\n", $ans);
}

namespace io {
	function next_line() {
		static $cnt = 0;
		global $input_buf;
		// while($input_buf[$cnt] == "") $cnt++;
		return $input_buf[$cnt++];
		// return trim($input_buf[$cnt++]);
	}
	function next_() {
		static $tk = [];
		static $tk_cnt = 0;
		if($tk_cnt == count($tk)) {
			$tk = explode(" ", next_line());
			$tk_cnt = 0;
		}
		return $tk[$tk_cnt++];
	}
	function next_int() {
		return (int)next_();
	}
	function next_double() {
		return (double)next_();
	}
}

?>

<?
$consoleInput = fopen('php://stdin','r');
$variables = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));
$monsters = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));

//$variables = array(7,4,2,1);
//$monsters = array(1,3,5,4,2,7,6);

$n = $variables[0];
$a = $variables[1];
$b = $variables[2];
$k = $variables[3];
$killCount = 0;
$m = array();

foreach ($monsters as $monster){
  $m[ceil((($monster % ($a+$b)))/$a)-1] ++;
}
if (array_key_exists(-1,$m)){
    //print "hello";
    $m[ceil($b/$a)] += $m[-1];
    unset($m[-1]);
}
ksort($m);

foreach ($m as $keyPerMonster => $numberOfMonsters){
    //print $keyPerMonster . "   " . $numberOfMonsters . "\n";
    if($k<$keyPerMonster*$numberOfMonsters){
        $killCount += floor($k/$keyPerMonster);
        break;
    }
    $k -= $keyPerMonster*$numberOfMonsters;
    $killCount += $numberOfMonsters;
    //print "k count is: " . $k . "\n";
    //print "kill count is: " . $killCount . "\n";
}
print $killCount;
?>

<?
$consoleInput = fopen('php://stdin','r');
$variables = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));
$monsters = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));

//$variables = array(7,4,2,1);
//$monsters = array(1,3,5,4,2,7,6);

$n = $variables[0];
$a = $variables[1];
$b = $variables[2];
$k = $variables[3];
$killCount = 0;
$m = array();

foreach ($monsters as $monster){
  $m[ceil((($monster % ($a+$b)))/$a)-1] ++;
}
if (array_key_exists(-1,$m)){
    //print "hello";
    $m[ceil($b/$a)] += $m[-1];
    unset($m[-1]);
}
ksort($m);

foreach ($m as $keyPerMonster => $numberOfMonsters){
    //print $keyPerMonster . "   " . $numberOfMonsters . "\n";
    if($k<$keyPerMonster*$numberOfMonsters){
        $killCount += floor($k/$keyPerMonster);
        break;
    }
    $k -= $keyPerMonster*$numberOfMonster;
    $killCount += $numberOfMonsters;
}
print $killCount;
?>

<?
$consoleInput = fopen('php://stdin','r');
$variables = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));
$monsters = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));

//$variables = array(7,4,2,1);
//$monsters = array(1,3,5,4,2,7,6);

$n = $variables[0];
$a = $variables[1];
$b = $variables[2];
$k = $variables[3];
$killCount = 0;
$m = array();

foreach ($monsters as $monster){
  $m[ceil((($monster % ($a+$b)))/$a)-1] ++;
}

$m[ceil($b/$a)] += $m[-1];
unset($m[-1]);
ksort($m);

foreach ($m as $keyPerMonster => $numberOfMonsters){
    if($k<$keyPerMonster*$numberOfMonsters){
        $killCount += floor($k/$keyPerMonster);
        break;
    }
    $k -= $keyPerMonster*$numberOfMonster;
    $killCount += $numberOfMonsters;
}

print $killCount;
?>

<?
$consoleInput = fopen('php://stdin','r');
$variables = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));
$monsters = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));

//$variables = array(7,4,2,1);
//$monsters = array(1,3,5,4,2,7,6);

$n = $variables[0];
$a = $variables[1];
$b = $variables[2];
$k = $variables[3];
$killCount = 0;
$m = array();

foreach ($monsters as $monster){
  $m[ceil((($monster % ($a+$b)))/$a)-1] ++;
}
if (array_key_exists(-1,$m)){
    $m[ceil($b/$a)] += $m[-1];
    unset($m[-1]);
}
ksort($m);

foreach ($m as $keyPerMonster => $numberOfMonsters){
    if($k<$keyPerMonster*$numberOfMonsters){
        $killCount += floor($k/$keyPerMonster);
        break;
    }
    $k -= $keyPerMonster*$numberOfMonster;
    $killCount += $numberOfMonsters;
}
print $killCount;
?>

<?
$consoleInput = fopen('php://stdin','r');
$variables = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));
$monsters = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));

//$variables = array(7,4,2,1);
//$monsters = array(1,3,5,4,2,7,6);

$n = $variables[0];
$a = $variables[1];
$b = $variables[2];
$k = $variables[3];
$killCount = 0;
$m = array();

foreach ($monsters as $monster){
    //print "attacks are " . ($a+$b) . "\n";
    //print "Mod is " . ($monster % ($a+$b)) . "\n";
    //print "Ceil is: " . ceil((($monster % ($a+$b)))/$a) . "\n";
  $kNeeded = ceil((($monster % ($a+$b)))/$a)-1;
  //print $kNeeded;
  if ($kNeeded == -1){
      $kNeeded = ceil($b/$a);
  }
  $m[$kNeeded] ++;
  print $kNeeded . "  " . $m[$kNeeded] . "\n";
}

for ($i=0;$k>$i*$m[$i];$i++){
    $k -= $m[$i]*$i;
    $killCount += $m[$i];
    if ($killCount == $n){
        $k = 0;
        break;
    }
}
$killCount += floor($k/$i);
print $killCount;
?>

<?
$consoleInput = fopen('php://stdin','r');
$variables = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));
$monsters = explode(" ",rtrim(fgets($consoleInput)," \t\n\r\0\x0B"));

//$variables = array(7,4,2,1);
//$monsters = array(1,3,5,4,2,7,6);

$n = $variables[0];
$a = $variables[1];
$b = $variables[2];
$k = $variables[3];
$killCount = 0;
$m = array();

foreach ($monsters as $monster){
  $m[ceil((($monster % ($a+$b)))/$a)-1] ++;
}
if (array_key_exists($m[-1])){
    $m[ceil($b/$a)] += $m[-1];
    unset($m[-1]);
}
ksort($m);

foreach ($m as $keyPerMonster => $numberOfMonsters){
    print $keyPerMonster . "  " . $numberOfMonsters . "\n";
    if($k<$keyPerMonster*$numberOfMonsters){
        $killCount += floor($k/$keyPerMonster);
        break;
    }
    $k -= $keyPerMonster*$numberOfMonster;
    $killCount += $numberOfMonsters;
}

print $killCount;
?>


<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$m = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));

sort($a);
sort($b);

function is_pair($a, $b){
    if (($a+1 == $b) or ($a == $b+1) or ($a == $b)) {
        return true;
    }
    return false;
}

$count = 0;
$used = -1;
for ($i = 0; $i < $n; $i++) {
    for ($j = $used+1; $j < $m; $j++) {
        if (is_pair($a[$i], $b[$j])) {
            $count++;
            $used = $j;
            break;
        }
    }
}
echo $count;
?>

<?php
$n = trim(fgets(STDIN));
$ar = explode(" ", trim(fgets(STDIN)));
$m = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));

sort($ar);
sort($b);

function isPair($ar,$b){
if (($ar+1==$b)||($ar==$b+1)||($ar==$b))
return true;
return false;
}

$pairs = 0;
$used = -1;
for($i=0;$i<$n;$i++){
for($j=$used+1;$j<$m;$j++)
if ( isPair($ar[$i],$b[$j]) ){
$pairs++;
$used = $j;
break;
}
}
echo $pairs;
?>

 <?php

$n = intval(trim(fgets(STDIN)));
$boySkills = strval(trim(fgets(STDIN)));
$boySkills = explode(" ",$boySkills);
$m = intval(trim(fgets(STDIN)));
$girlSkills = strval(trim(fgets(STDIN)));
$girlSkills = explode(" ",$girlSkills);

sort($boySkills);
sort($girlSkills);

$bannedCols=[];
$pairCnt = 0;

for ($i=0; $i < $n; $i++) {
	for ($j=0; $j < $m; $j++) {
		if(abs($boySkills[$i]-$girlSkills[$j])<=1&&!in_array($j, $bannedCols)){
			$pairCnt++;
			$bannedCols[]=$j;
			break;
		}
	}
}

echo $pairCnt;

<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$m = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));

sort($a);
sort($b);

function isPair($a,$b){
	if (($a+1==$b)||($a==$b+1)||($a==$b))
		return true;
	return false;
}

$pairs = 0;
$used = -1;
for($i=0;$i<$n;$i++){
	for($j=$used+1;$j<$m;$j++)
		if ( isPair($a[$i],$b[$j]) ){
			$pairs++;
			$used = $j;
			break;
		}
}
echo $pairs;
?>

<?php

$n = (int) trim(fgets(STDIN));
$boys = array_map('intval', explode(' ', trim(fgets(STDIN))));
$m = (int) trim(fgets(STDIN));
$girls = array_map('intval', explode(' ', trim(fgets(STDIN))));

sort($boys);
sort($girls);

$gi = 0;
$bi =0;
$matches =0;
while($gi < $m && $bi < $n){
    if($boys[$bi] < $girls[$gi] - 1){
        $bi++;
    }elseif($boys[$bi] -1 > $girls[$gi]){
        $gi++;
    }else{
        $matches++;
        $bi++;
        $gi++;
    }

}
echo $matches;

 <?php

$n = intval(trim(fgets(STDIN)));
$boySkills = strval(trim(fgets(STDIN)));
$boySkills = explode(" ",$boySkills);
$m = intval(trim(fgets(STDIN)));
$girlSkills = strval(trim(fgets(STDIN)));
$girlSkills = explode(" ",$girlSkills);

$bannedCols=[];
$pairCnt = 0;

for ($i=0; $i < $n; $i++) {
	for ($j=0; $j < $m; $j++) {
		if(abs($boySkills[$i]-$girlSkills[$j])<=1&&!in_array($j, $bannedCols)){
			$pairCnt++;
			$bannedCols[]=$j;
			break;
		}
	}
}

echo $pairCnt;

<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$m = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));

sort($a);
sort($b);

function isPair($a,$b){
	if (($a+1==$b)||($a==$b+1)||($a==$b))
		return true;
	return false;
}

$pairs = 0;

for($i=0;$i<$n;$i++){
	for($j=0;$j<$m;$j++)
		if ( isPair($a[$i],$b[$j]) ){
			$pairs++;
			$b[$j] = null;
			break;
		}
}
echo $pairs;
/*
1 2 4 6
1 5 5 7 9

*/
?>

<?php

$n = (int) trim(fgets(STDIN));
$boys = array_map('intval', explode(' ', trim(fgets(STDIN))));
$m = (int) trim(fgets(STDIN));
$girls = array_map('intval', explode(' ', trim(fgets(STDIN))));

sort($boys);
sort($girls);

$gi = 0;
$matches =0;

foreach($boys as $boy){
    if(abs($boy - $girls[$gi]) <= 1){
        $matches++;
    }
    $gi ++;
    if($gi >= $m){
        break;
    }
}

echo $matches;


<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", trim(fgets(STDIN)));

asort($a);
list($k, $v) = each($a);

if ($n == 1) {
    echo "-1";
} else if ($n == 2 && $a[0] == $a[1]) {
    echo "-1";
} else {
    echo 1 . "\n";
    echo $k + 1;
}

<?php
	$dir                    = fopen("php://stdin", 'r');
	$contents               = stream_get_contents($dir);
	$inputs                 = explode("\n",$contents);
	$packetsCount           = explode(' ', $inputs[0])[0];
	$ballonsForEachPacket   = array_map('intval', explode(' ', $inputs[1]));
	getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket);

	function getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket)
	{
	    if($packetsCount == 2 && $ballonsForEachPacket[0] == $ballonsForEachPacket[1]) {
		echo -1;
	    }elseif($packetsCount <= 1) {
		echo -1;
	    } else {
		$minimumNumber  = min($ballonsForEachPacket);
		$numbersSum     = array_sum($ballonsForEachPacket);
		if($minimumNumber != $numbersSum - $minimumNumber)
		{
		     echo 1;
		     echo PHP_EOL;
		     echo array_keys($ballonsForEachPacket, $minimumNumber)[0] + 1;
		}
	    }
	}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
if($a == 1)
{
     print "-1";
}
elseif(($a == 2) && ($b[0] == $b[1]))
{
     print "-1";
}
else
{
     asort($b);
     $c = array_keys($b);
     print "1\n";
     print $c[0] + 1;
}
?>

<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", trim(fgets(STDIN)));

rsort($a);
if ($n == 1) {
    echo "-1";
} else if ($n == 2 && $a[0] == $a[1]) {
    echo "-1";
} else {
    echo 1 . "\n";
    echo $a[0];
}

<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", trim(fgets(STDIN)));

rsort($a);
if ($n == 1) {
    echo "-1";
} else if ($n == 2 && $a[0] == $a[1]) {
    echo "-1";
} else {
    echo $n - 1 . "\n";
    array_pop($a);
    echo implode(" ", $a);
}

<?php
$dir                    = fopen("php://stdin", 'r');
$contents               = stream_get_contents($dir);
$inputs                 = explode("\n",$contents);
$packetsCount           = explode(' ', $inputs[0])[0];
$ballonsForEachPacket   = array_map('intval', explode(' ', $inputs[1]));
getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket);

function getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket)
{
    $firstPlayerPackets['count'] = 0;
    $firstPlayerPackets['ballonsConut'] = 0;
    $firstPlayerPackets['ballons'] = [];
    $secondPlayerPackets['count'] = 0;
    $secondPlayerPackets['ballonsConut'] = 0;
    $secondPlayerPackets['ballons'] = [];
    if($packetsCount <= 1)
    {
        echo -1;
    } else {
        for($i=0; $i < $packetsCount; $i++)
        {
            if($i+1 == 1 || ($packetsCount!=2 && $firstPlayerPackets['ballonsConut'] + $ballonsForEachPacket[$i] == $secondPlayerPackets['ballonsConut'])){
                $secondPlayerPackets['count']++;
                $secondPlayerPackets['ballonsConut'] += $ballonsForEachPacket[$i] ;
                $secondPlayerPackets['ballons'] = [$i => $ballonsForEachPacket[$i]];
            } else {
                //echo $i;
                $firstPlayerPackets['count']++;
                $firstPlayerPackets['ballonsConut'] += $ballonsForEachPacket[$i] ;
                $firstPlayerPackets['ballons'][$i] = $ballonsForEachPacket[$i];

            }
        }

        if($secondPlayerPackets['count'] == $firstPlayerPackets['count'])
        {
            echo -1;
        } else{
            echo $firstPlayerPackets['count'].PHP_EOL;
            foreach($firstPlayerPackets['ballons'] as  $key=>$ballons)
            {
                echo ($key+1).' ';
            }
        }
    }
}
?>

<?php
$dir                    = fopen("php://stdin", 'r');
$contents               = stream_get_contents($dir);
$inputs                 = explode("\n",$contents);
$packetsCount           = explode(' ', $inputs[0])[0];
$ballonsForEachPacket   = array_map('intval', explode(' ', $inputs[1]));
getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket);

function getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket)
{
    $firstPlayerPackets['count'] = 0;
    $firstPlayerPackets['ballonsConut'] = 0;
    $firstPlayerPackets['ballons'] = [];
    $secondPlayerPackets['count'] = 0;
    $secondPlayerPackets['ballonsConut'] = 0;
    $secondPlayerPackets['ballons'] = [];
    if($packetsCount <= 1)
    {
        echo -1;
    } else {
        for($i=0; $i < $packetsCount; $i++)
        {
            if($i+1 == 1 || ($packetsCount!=2 && $firstPlayerPackets['ballonsConut'] + $ballonsForEachPacket[$i] == $secondPlayerPackets['ballonsConut'])){
                $secondPlayerPackets['count']++;
                $secondPlayerPackets['ballonsConut'] += $ballonsForEachPacket[$i] ;
                $secondPlayerPackets['ballons'] = [$i => $ballonsForEachPacket[$i]];
            } else {
                //echo $i;
                $firstPlayerPackets['count']++;
                $firstPlayerPackets['ballonsConut'] += $ballonsForEachPacket[$i] ;
                $firstPlayerPackets['ballons'][$i] = $ballonsForEachPacket[$i];

            }
        }

        if($secondPlayerPackets['ballonsConut']  === $firstPlayerPackets['ballonsConut'])
        {
            echo -1;
        } else{
            echo $firstPlayerPackets['count'].PHP_EOL;
            foreach($firstPlayerPackets['ballons'] as  $key=>$ballons)
            {
                echo ($key+1).' ';
            }
        }
    }
}
?>

<?php
	$dir                    = fopen("php://stdin", 'r');
	$contents               = stream_get_contents($dir);
	$inputs                 = explode("\n",$contents);
	$packetsCount           = explode(' ', $inputs[0])[0];
	$ballonsForEachPacket   = array_map('intval', explode(' ', $inputs[1]));
	getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket);

	function getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket)
	{
	    if($packetsCount == 2 && $ballonsForEachPacket[0] == $ballonsForEachPacket[1]) {
		echo -1;
	    }elseif($packetsCount <= 1) {
		echo -1;
	    } else {
		$minimumNumber  = min($ballonsForEachPacket);
		$numbersSum     = array_sum($ballonsForEachPacket);
		if($minimumNumber != $numbersSum - $minimumNumber)
		{
		     echo $minimumNumber;
		     echo PHP_EOL;
		     echo array_keys($ballonsForEachPacket, $minimumNumber)[0] + 1;
		}
	    }
	}
?>

<?php
$dir                    = fopen("php://stdin", 'r');
$contents               = stream_get_contents($dir);
$inputs                 = explode("\n",$contents);
$packetsCount           = explode(' ', $inputs[0])[0];
$ballonsForEachPacket   = array_map('intval', explode(' ', $inputs[1]));
getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket);

function getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket)
{
    $firstPlayerPackets['count'] = 0;
    $firstPlayerPackets['ballons'] = [];
    $secondPlayerPackets['count'] = 0;
    $secondPlayerPackets['ballons'] = [];
    if($packetsCount <= 1)
    {
        echo -1;
    } else {
        for($i=0; $i < $packetsCount; $i++)
        {
            if($i+1 == 1){
                $secondPlayerPackets['count']++;
                $secondPlayerPackets['ballons'] = [$i => $ballonsForEachPacket[$i]];
            } else {
                //echo $i;
                $firstPlayerPackets['count']++;
                $firstPlayerPackets['ballons'][] = $ballonsForEachPacket[$i];

            }
        }

        if($secondPlayerPackets['count'] == $firstPlayerPackets['count'])
        {
            echo -1;
        } else{
            echo $firstPlayerPackets['count'].PHP_EOL;
            for($i = 0; $i < count($firstPlayerPackets['ballons']); $i++)
            {
                echo $firstPlayerPackets['ballons'][$i].' ';
            }
        }
    }
}
?>

<?php
$dir                    = fopen("php://stdin", 'r');
$contents               = stream_get_contents($dir);
$inputs                 = explode("\n",$contents);
$packetsCount           = explode(' ', $inputs[0])[0];
$ballonsForEachPacket   = array_map('intval', explode(' ', $inputs[1]));
getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket);

function getPacketsNumberForFirstPlayer($packetsCount, $ballonsForEachPacket)
{
    $firstPlayerPackets['count'] = 0;
    $firstPlayerPackets['ballonsConut'] = 0;
    $firstPlayerPackets['ballons'] = [];
    $secondPlayerPackets['count'] = 0;
    $secondPlayerPackets['ballonsConut'] = 0;
    $secondPlayerPackets['ballons'] = [];
    if($packetsCount <= 1)
    {
        echo -1;
    } else {
        for($i=0; $i < $packetsCount; $i++)
        {
            if($i+1 == 1 || ($packetsCount!=2 && $firstPlayerPackets['ballonsConut'] + $ballonsForEachPacket[$i] == $secondPlayerPackets['ballonsConut'])){
                $secondPlayerPackets['count']++;
                $secondPlayerPackets['ballonsConut'] += $ballonsForEachPacket[$i] ;
                $secondPlayerPackets['ballons'] = [$i => $ballonsForEachPacket[$i]];
            } else {
                //echo $i;
                $firstPlayerPackets['count']++;
                $firstPlayerPackets['ballonsConut'] += $ballonsForEachPacket[$i] ;
                $firstPlayerPackets['ballons'][] = $ballonsForEachPacket[$i];

            }
        }

        if($secondPlayerPackets['count'] == $firstPlayerPackets['count'])
        {
            echo -1;
        } else{
            echo $firstPlayerPackets['count'].PHP_EOL;
            for($i = 0; $i < count($firstPlayerPackets['ballons']); $i++)
            {
                echo $firstPlayerPackets['ballons'][$i].' ';
            }
        }
    }
}
?>


<?php
    fscanf(STDIN, "%s", $s);

    $arr = str_split($s);
    $len = count($arr);

    $w = "Bulbasaur";
    $arrW = str_split($w);
    $sample = array();
    // var_dump($arrW);

    for ($i = 0; $i < count($arrW); $i++) {
        $sample[$arrW[$i]]++;
    }
    // var_dump($sample);

    $sum = array();
    $curr = $arrW;

    $ans = PHP_INT_MAX;

    for ($i = 0; $i < $len; $i++) {
        $sum[$arr[$i]]++;
    }
    // var_dump($sum);

    foreach ($sample as $key => $val) {
        // echo "key:{$key} val:{$val}\n";
        $tmp = floor($sum[$key] / $sample[$key]);
        $ans = min($tmp, $ans);
    }

    echo $ans;