Vasya has his favourite number $$$n$$$. He wants to split it to some non-zero digits. It means, that he wants to choose some digits $$$d_1, d_2, \ldots, d_k$$$, such that $$$1 \leq d_i \leq 9$$$ for all $$$i$$$ and $$$d_1 + d_2 + \ldots + d_k = n$$$.Vasya likes beauty in everything, so he wants to find any solution with the minimal possible number of different digits among $$$d_1, d_2, \ldots, d_k$$$. Help him!

The first line contains a single integer $$$n$$$ — the number that Vasya wants to split ($$$1 \leq n \leq 1000$$$).

In the first line print one integer $$$k$$$ — the number of digits in the partition. Note that $$$k$$$ must satisfy the inequality $$$1 \leq k \leq n$$$. In the next line print $$$k$$$ digits $$$d_1, d_2, \ldots, d_k$$$ separated by spaces. All digits must satisfy the inequalities $$$1 \leq d_i \leq 9$$$. You should find a partition of $$$n$$$ in which the number of different digits among $$$d_1, d_2, \ldots, d_k$$$ will be minimal possible among all partitions of $$$n$$$ into non-zero digits. Among such partitions, it is allowed to find any. It is guaranteed that there exists at least one partition of the number $$$n$$$ into digits.

NoteIn the first test, the number $$$1$$$ can be divided into $$$1$$$ digit equal to $$$1$$$.In the second test, there are $$$3$$$ partitions of the number $$$4$$$ into digits in which the number of different digits is $$$1$$$. This partitions are $$$[1, 1, 1, 1]$$$, $$$[2, 2]$$$ and $$$[4]$$$. Any of these partitions can be found. And, for example, dividing the number $$$4$$$ to the digits $$$[1, 1, 2]$$$ isn't an answer, because it has $$$2$$$ different digits, that isn't the minimum possible number.

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


Polycarp must pay exactly $$$n$$$ burles at the checkout. He has coins of two nominal values: $$$1$$$ burle and $$$2$$$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.Thus, Polycarp wants to minimize the difference between the count of coins of $$$1$$$ burle and $$$2$$$ burles being used. Help him by determining two non-negative integer values $$$c_1$$$ and $$$c_2$$$ which are the number of coins of $$$1$$$ burle and $$$2$$$ burles, respectively, so that the total value of that number of coins is exactly $$$n$$$ (i. e. $$$c_1 + 2 \cdot c_2 = n$$$), and the absolute value of the difference between $$$c_1$$$ and $$$c_2$$$ is as little as possible (i. e. you must minimize $$$|c_1-c_2|$$$).

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one line. This line contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the number of burles to be paid by Polycarp.

For each test case, output a separate line containing two integers $$$c_1$$$ and $$$c_2$$$ ($$$c_1, c_2 \ge 0$$$) separated by a space where $$$c_1$$$ is the number of coins of $$$1$$$ burle and $$$c_2$$$ is the number of coins of $$$2$$$ burles. If there are multiple optimal solutions, print any one.

NoteThe answer for the first test case is "334 333". The sum of the nominal values of all coins is $$$334 \cdot 1 + 333 \cdot 2 = 1000$$$, whereas $$$|334 - 333| = 1$$$. One can't get the better value because if $$$|c_1 - c_2| = 0$$$, then $$$c_1 = c_2$$$ and $$$c_1 \cdot 1 + c_1 \cdot 2 = 1000$$$, but then the value of $$$c_1$$$ isn't an integer.The answer for the second test case is "10 10". The sum of the nominal values is $$$10 \cdot 1 + 10 \cdot 2 = 30$$$ and $$$|10 - 10| = 0$$$, whereas there's no number having an absolute value less than $$$0$$$.

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

?>


Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color ci, connecting vertex ai and bi.Mr. Kitayuta wants you to process the following q queries.In the i-th query, he gives you two integers — ui and vi.Find the number of the colors that satisfy the following condition: the edges of that color connect vertex ui and vertex vi directly or indirectly.

The first line of the input contains space-separated two integers — n and m (2 ≤ n ≤ 100, 1 ≤ m ≤ 100), denoting the number of the vertices and the number of the edges, respectively. The next m lines contain space-separated three integers — ai, bi (1 ≤ ai < bi ≤ n) and ci (1 ≤ ci ≤ m). Note that there can be multiple edges between two vertices. However, there are no multiple edges of the same color between two vertices, that is, if i ≠ j, (ai, bi, ci) ≠ (aj, bj, cj). The next line contains a integer — q (1 ≤ q ≤ 100), denoting the number of the queries. Then follows q lines, containing space-separated two integers — ui and vi (1 ≤ ui, vi ≤ n). It is guaranteed that ui ≠ vi.

For each query, print the answer in a separate line.

NoteLet's consider the first sample.     The figure above shows the first sample.    Vertex 1 and vertex 2 are connected by color 1 and 2.  Vertex 3 and vertex 4 are connected by color 3.  Vertex 1 and vertex 4 are not connected by any single color.

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


A and B are preparing themselves for programming contests.B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.Can you help B find out exactly what two errors he corrected?

The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time.  The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.  The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.

Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.

NoteIn the first test sample B first corrects the error number 8, then the error number 123.In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.

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

    ?>


Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of milk that they can give. A cow facing left sees all the cows with lower indices than her index, and a cow facing right sees all the cows with higher indices than her index. A cow that got scared once can get scared again (and lose one more unit of milk). A cow that has been milked once cannot get scared and lose any more milk. You can assume that a cow never loses all the milk she can give (a cow gives an infinitely amount of milk).Iahub can decide the order in which he milks the cows. But he must milk each cow exactly once. Iahub wants to lose as little milk as possible. Print the minimum amount of milk that is lost.

The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.

Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost.

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


Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any other one. Pavel doesn't like it when his maze has too little walls. He wants to turn exactly k empty cells into walls so that all the remaining cells still formed a connected area. Help him.

The first line contains three integers n, m, k (1 ≤ n, m ≤ 500, 0 ≤ k < s), where n and m are the maze's height and width, correspondingly, k is the number of walls Pavel wants to add and letter s represents the number of empty cells in the original maze. Each of the next n lines contains m characters. They describe the original maze. If a character on a line equals ".", then the corresponding cell is empty and if the character equals "#", then the cell is a wall.

Print n lines containing m characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#"). It is guaranteed that a solution exists. If there are multiple solutions you can output any of them.

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


Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another.The cell of the field is under rook's attack, if there is at least one rook located in the same row or in the same column with this cell. If there is a rook located in the cell, this cell is also under attack.You are given the positions of the board where Vasya will put rooks. For each rook you have to determine the number of cells which are not under attack after Vasya puts it on the board.

The first line of the input contains two integers n and m (1 ≤ n ≤ 100 000, 1 ≤ m ≤ min(100 000, n2)) — the size of the board and the number of rooks.  Each of the next m lines contains integers xi and yi (1 ≤ xi, yi ≤ n) — the number of the row and the number of the column where Vasya will put the i-th rook. Vasya puts rooks on the board in the order they appear in the input. It is guaranteed that any cell will contain no more than one rook.

Print m integer, the i-th of them should be equal to the number of cells that are not under attack after first i rooks are put.

NoteOn the picture below show the state of the board after put each of the three rooks. The cells which painted with grey color is not under the attack.


Tomorrow is a difficult day for Polycarp: he has to attend $$$a$$$ lectures and $$$b$$$ practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.While preparing for the university, Polycarp wonders whether he can take enough writing implements to write all of the lectures and draw everything he has to during all of the practical classes. Polycarp writes lectures using a pen (he can't use a pencil to write lectures!); he can write down $$$c$$$ lectures using one pen, and after that it runs out of ink. During practical classes Polycarp draws blueprints with a pencil (he can't use a pen to draw blueprints!); one pencil is enough to draw all blueprints during $$$d$$$ practical classes, after which it is unusable.Polycarp's pencilcase can hold no more than $$$k$$$ writing implements, so if Polycarp wants to take $$$x$$$ pens and $$$y$$$ pencils, they will fit in the pencilcase if and only if $$$x + y \le k$$$.Now Polycarp wants to know how many pens and pencils should he take. Help him to determine it, or tell that his pencilcase doesn't have enough room for all the implements he needs tomorrow!Note that you don't have to minimize the number of writing implements (though their total number must not exceed $$$k$$$).

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then the test cases follow. Each test case is described by one line containing five integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ and $$$k$$$, separated by spaces ($$$1 \le a, b, c, d, k \le 100$$$) — the number of lectures Polycarp has to attend, the number of practical classes Polycarp has to attend, the number of lectures which can be written down using one pen, the number of practical classes for which one pencil is enough, and the number of writing implements that can fit into Polycarp's pencilcase, respectively. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.

For each test case, print the answer as follows: If the pencilcase can't hold enough writing implements to use them during all lectures and practical classes, print one integer $$$-1$$$. Otherwise, print two non-negative integers $$$x$$$ and $$$y$$$ — the number of pens and pencils Polycarp should put in his pencilcase. If there are multiple answers, print any of them. Note that you don't have to minimize the number of writing implements (though their total number must not exceed $$$k$$$).

NoteThere are many different answers for the first test case; $$$x = 7$$$, $$$y = 1$$$ is only one of them. For example, $$$x = 3$$$, $$$y = 1$$$ is also correct.$$$x = 1$$$, $$$y = 3$$$ is the only correct answer for the third test case.

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


Madoka is a very strange girl, and therefore she suddenly wondered how many pairs of integers $$$(a, b)$$$ exist, where $$$1 \leq a, b \leq n$$$, for which $$$\frac{\operatorname{lcm}(a, b)}{\operatorname{gcd}(a, b)} \leq 3$$$.In this problem, $$$\operatorname{gcd}(a, b)$$$ denotes the greatest common divisor of the numbers $$$a$$$ and $$$b$$$, and $$$\operatorname{lcm}(a, b)$$$ denotes the smallest common multiple of the numbers $$$a$$$ and $$$b$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Description of the test cases follows. The first and the only line of each test case contains the integer $$$n$$$ ($$$1 \le n \le 10^8$$$).

For each test case output a single integer — the number of pairs of integers satisfying the condition.

NoteFor $$$n = 1$$$ there is exactly one pair of numbers — $$$(1, 1)$$$ and it fits.For $$$n = 2$$$, there are only $$$4$$$ pairs — $$$(1, 1)$$$, $$$(1, 2)$$$, $$$(2, 1)$$$, $$$(2, 2)$$$ and they all fit.For $$$n = 3$$$, all $$$9$$$ pair are suitable, except $$$(2, 3)$$$ and $$$(3, 2)$$$, since their $$$\operatorname{lcm}$$$ is $$$6$$$, and $$$\operatorname{gcd}$$$ is $$$1$$$, which doesn't fit the condition.

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


You are given a string $$$s$$$. Each character is either 0 or 1.You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 0101, 100001 or 11111111111101, then this condition is not met.You may erase some (possibly none) 0's from the string. What is the minimum number of 0's that you have to erase?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ lines follow, each representing a test case. Each line contains one string $$$s$$$ ($$$1 \le |s| \le 100$$$); each character of $$$s$$$ is either 0 or 1.

Print $$$t$$$ integers, where the $$$i$$$-th integer is the answer to the $$$i$$$-th testcase (the minimum number of 0's that you have to erase from $$$s$$$).

NoteIn the first test case you have to delete the third and forth symbols from string 010011 (it turns into 0111).

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

}

?>


Nastia has $$$2$$$ positive integers $$$A$$$ and $$$B$$$. She defines that:  The integer is good if it is divisible by $$$A \cdot B$$$;  Otherwise, the integer is nearly good, if it is divisible by $$$A$$$. For example, if $$$A = 6$$$ and $$$B = 4$$$, the integers $$$24$$$ and $$$72$$$ are good, the integers $$$6$$$, $$$660$$$ and $$$12$$$ are nearly good, the integers $$$16$$$, $$$7$$$ are neither good nor nearly good.Find $$$3$$$ different positive integers $$$x$$$, $$$y$$$, and $$$z$$$ such that exactly one of them is good and the other $$$2$$$ are nearly good, and $$$x + y = z$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10\,000$$$) — the number of test cases. The first line of each test case contains two integers $$$A$$$ and $$$B$$$ ($$$1 \le A \le 10^6$$$, $$$1 \le B \le 10^6$$$) — numbers that Nastia has.

For each test case print:    "YES" and $$$3$$$ different positive integers $$$x$$$, $$$y$$$, and $$$z$$$ ($$$1 \le x, y, z \le 10^{18}$$$) such that exactly one of them is good and the other $$$2$$$ are nearly good, and $$$x + y = z$$$.  "NO" if no answer exists.  YES NO If there are multiple answers, print any.

NoteIn the first test case: $$$60$$$ — good number; $$$10$$$ and $$$50$$$ — nearly good numbers.In the second test case: $$$208$$$ — good number; $$$169$$$ and $$$39$$$ — nearly good numbers.In the third test case: $$$154$$$ — good number; $$$28$$$ and $$$182$$$ — nearly good numbers.

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

?>


Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows:   $$$f(0) = a$$$;  $$$f(1) = b$$$;  $$$f(n) = f(n-1) \oplus f(n-2)$$$ when $$$n > 1$$$, where $$$\oplus$$$ denotes the bitwise XOR operation. You are given three integers $$$a$$$, $$$b$$$, and $$$n$$$, calculate $$$f(n)$$$.You have to answer for $$$T$$$ independent test cases.

The input contains one or more independent test cases. The first line of input contains a single integer $$$T$$$ ($$$1 \le T \le 10^3$$$), the number of test cases. Each of the $$$T$$$ following lines contains three space-separated integers $$$a$$$, $$$b$$$, and $$$n$$$ ($$$0 \le a, b, n \le 10^9$$$) respectively.

NoteIn the first example, $$$f(2) = f(0) \oplus f(1) = 3 \oplus 4 = 7$$$.


You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters. Suitability of string s is calculated by following metric:Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulting strings s, you choose the one with the largest number of non-intersecting occurrences of string t. Suitability is this number of occurrences.You should replace all '?' characters with small Latin letters in such a way that the suitability of string s is maximal.

The first line contains string s (1 ≤ |s| ≤ 106). The second line contains string t (1 ≤ |t| ≤ 106).

Print string s with '?' replaced with small Latin letters in such a way that suitability of that string is maximal. If there are multiple strings with maximal suitability then print any of them.

NoteIn the first example string "baab" can be transformed to "abab" with swaps, this one has suitability of 2. That means that string "baab" also has suitability of 2.In the second example maximal suitability you can achieve is 1 and there are several dozens of such strings, "azbz" is just one of them.In the third example there are no '?' characters and the suitability of the string is 0.

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


Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration?

The first line contains integer n (1 ≤ n ≤ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n.

Print the total minimum number of moves.


Your company was appointed to lay new asphalt on the highway of length $$$n$$$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.Skipping the repair is necessary because of the climate. The climate in your region is periodical: there are $$$g$$$ days when the weather is good and if you lay new asphalt these days it becomes high-quality pavement; after that, the weather during the next $$$b$$$ days is bad, and if you lay new asphalt these days it becomes low-quality pavement; again $$$g$$$ good days, $$$b$$$ bad days and so on.You can be sure that you start repairing at the start of a good season, in other words, days $$$1, 2, \dots, g$$$ are good.You don't really care about the quality of the highway, you just want to make sure that at least half of the highway will have high-quality pavement. For example, if the $$$n = 5$$$ then at least $$$3$$$ units of the highway should have high quality; if $$$n = 4$$$ then at least $$$2$$$ units should have high quality.What is the minimum number of days is needed to finish the repair of the whole highway?

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains three integers $$$n$$$, $$$g$$$ and $$$b$$$ ($$$1 \le n, g, b \le 10^9$$$) — the length of the highway and the number of good and bad days respectively.

Print $$$T$$$ integers — one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.

NoteIn the first test case, you can just lay new asphalt each day, since days $$$1, 3, 5$$$ are good.In the second test case, you can also lay new asphalt each day, since days $$$1$$$-$$$8$$$ are good.

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d) = explode(" ", trim(fgets(STDIN)));
     if($b <= $c)
     {
         print $b . "\n";
     }
     else
     {
         $e = ceil($b / 2);
         $f = floor($e / $c);
         $g = bcmod($e, $c);
         $h = bcmul(bcadd($c, $d), $f);
         if($g == 0)
         {
              $h = bcsub($h, $d);
         }
         else
         {
              $h = bcadd($h, $g);
         }
         print max($b, $h) . "\n";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d) = explode(" ", trim(fgets(STDIN)));
     if($b <= $c)
     {
         print $b . "\n";
     }
     else
     {
         $e = ceil(bcdiv($b, 2));
         $f = floor(bcdiv($e, $c));
         $g = bcmod($e, $c);
         $h = bcmul(bcadd($c, $d), $f);
         if($g == 0)
         {
              $h = bcsub($h, $d);
         }
         else
         {
              $h = bcadd($h, $g);
         }
         print max($b, $h) . "\n";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d) = explode(" ", trim(fgets(STDIN)));
     if($b <= $c)
     {
         print $b . "\n";
     }
     else
     {
         $e = ceil(bcdiv($b, 2));
         $f = floor(bcdiv($e, $c));
         $g = bcmod($e, $c);
         $h = bcmul(bcadd($c, $d), $f);
         if($g == 0)
         {
              $h = bcsub($h, $d);
         }
         else
         {
              $h = bcadd($h, $g);
         }
         $i = max($b, $h) . "\n";
         print number_format($i, 0, ".", "") . "\n";
     }
}
?>


Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs to one cycle only — a funny ring — and does not belong to any other cycles. A funny ring is a cycle that goes through all the vertices just once. Moreover, loops are funny rings too.She has already drawn the apples and some of the graph edges. But now it is not clear, how to connect the rest of the vertices to get an interesting graph as a result. The answer should contain the minimal amount of added edges. And furthermore, the answer should be the lexicographically smallest one. The set of edges (x1, y1), (x2, y2), ..., (xn, yn), where xi ≤ yi, is lexicographically smaller than the set (u1, v1), (u2, v2), ..., (un, vn), where ui ≤ vi, provided that the sequence of integers x1, y1, x2, y2, ..., xn, yn is lexicographically smaller than the sequence u1, v1, u2, v2, ..., un, vn. If you do not cope, Hexadecimal will eat you. ...eat you alive.

The first line of the input data contains a pair of integers n and m (1 ≤ n ≤ 50, 0 ≤ m ≤ 2500) — the amount of vertices and edges respectively. The following lines contain pairs of numbers xi and yi (1 ≤ xi, yi ≤ n) — the vertices that are already connected by edges. The initial graph may contain multiple edges and loops.

In the first line output «YES» or «NO»: if it is possible or not to construct an interesting graph. If the answer is «YES», in the second line output k — the amount of edges that should be added to the initial graph. Finally, output k lines: pairs of vertices xj and yj, between which edges should be drawn. The result may contain multiple edges and loops. k can be equal to zero.

<?php

class Graph {
	private function add($a, $b, $store = false) {
		array_push($this->g[$a], $b);
		array_push($this->g[$b], $a);
		if ($store)
			array_push($this->answer, array($a, $b));
	}

	public function __construct() {
		fscanf(STDIN, "%d %d", $this->n, $this->m);
		$this->g = array_fill(0, $this->n, array());
		for ($i = 0; $i < $this->m; $i++) {
			fscanf(STDIN, "%d %d", $a, $b);
			$this->add($a - 1, $b - 1);
		}
		$this->answer = array();
	}

	private function dfs($v, $cc) {
		if ($this->u[$v] != -1)
			return;
		$this->u[$v] = $cc;
		foreach ($this->g[$v] as $x) {
			// printf("dfs from %d to %d\n", $v, $x);
			$this->dfs($x, $cc);
		}
	}

	private function check() {
		$this->u = array_fill(0, $this->n, -1);
		$cc = 0;
		for ($i = 0; $i < $this->n; $i++) {
			if ($this->u[$i] == -1) {
				$this->dfs($i, $cc);
				$cc++;
			}
		}
		return $cc;
	}

	public function solve() {
		for ($run = true; $run; ) {
			$run = false;
			$this->check();
			// print_r($this->u);
			for ($i = 0; $i < $this->n; $i++)
				for ($j = $i; $j < $this->n; $j++)
					if (count($this->g[$i]) <= 1 && count($this->g[$j]) <= 1 && ($this->u[$i] != $this->u[$j] || $this->m == $this->n - 1) && ($i != $j || $this->n == 1)) {
						// printf("pair %d %d is good\n", $i, $j);
						$run = true;
						$this->add($i, $j, true);
						$this->m += 1;
						break 2;
					}
		}
	}

	public function output() {
		$maxDegree = max(array_map(function ($a) { return count($a); }, $this->g));
		if ($this->check() == 1 && $this->n == $this->m && $maxDegree == 2) {
			print("YES\n");
			print(count($this->answer)."\n");
			foreach ($this->answer as $pair)
				printf("%d %d\n", $pair[0] + 1, $pair[1] + 1);

		} else {
			print("NO\n");
		}
	}
}

$g = new Graph();
$g->solve();
$g->output();

?>

<?php

class Graph {
	private function add($a, $b, $store = false) {
		array_push($this->g[$a], $b);
		array_push($this->g[$b], $a);
		if ($store)
			array_push($this->answer, array($a, $b));
	}

	public function __construct() {
		fscanf(STDIN, "%d %d", $this->n, $this->m);
		$this->g = array_fill(0, $this->n, array());
		for ($i = 0; $i < $this->m; $i++) {
			fscanf(STDIN, "%d %d", $a, $b);
			$this->add($a - 1, $b - 1);
		}
		$this->answer = array();
	}

	private function dfs($v, $cc) {
		if ($this->u[$v] != -1)
			return;
		$this->u[$v] = $cc;
		foreach ($this->g[$v] as $x) {
			// printf("dfs from %d to %d\n", $v, $x);
			$this->dfs($x, $cc);
		}
	}

	private function check() {
		$this->u = array_fill(0, $this->n, -1);
		$cc = 0;
		for ($i = 0; $i < $this->n; $i++) {
			if ($this->u[$i] == -1) {
				$this->dfs($i, $cc);
				$cc++;
			}
		}
		return $cc;
	}

	public function solve() {
		for ($run = true; $run; ) {
			$run = false;
			$this->check();
			// print_r($this->u);
			for ($i = 0; $i < $this->n; $i++)
				for ($j = $i + 1; $j < $this->n; $j++)
					if (count($this->g[$i]) <= 1 && count($this->g[$j]) <= 1 && ($this->u[$i] != $this->u[$j] || $this->m == $this->n - 1)) {
						// printf("pair %d %d is good\n", $i, $j);
						$run = true;
						$this->add($i, $j, true);
						$this->m += 1;
						break 2;
					}
		}
	}

	public function output() {
		$maxDegree = max(array_map(function ($a) { return count($a); }, $this->g));
		if ($this->check() == 1 && $this->n >= 3 && $this->n == $this->m && $maxDegree == 2) {
			print("YES\n");
			print(count($this->answer)."\n");
			foreach ($this->answer as $pair)
				printf("%d %d\n", $pair[0] + 1, $pair[1] + 1);

		} else {
			print("NO\n");
		}
	}
}

$g = new Graph();
$g->solve();
$g->output();

?>

<?php

class Graph {
	private function add($a, $b, $store = false) {
		array_push($this->g[$a], $b);
		array_push($this->g[$b], $a);
		if ($store)
			array_push($this->answer, array($a, $b));
	}

	public function __construct() {
		fscanf(STDIN, "%d %d", $this->n, $this->m);
		$this->g = array_fill(0, $this->n, array());
		for ($i = 0; $i < $this->m; $i++) {
			fscanf(STDIN, "%d %d", $a, $b);
			$this->add($a - 1, $b - 1);
		}
		$this->answer = array();
	}

	private function dfs($v, $cc) {
		if ($this->u[$v] != -1)
			return;
		$this->u[$v] = $cc;
		foreach ($this->g[$v] as $x) {
			// printf("dfs from %d to %d\n", $v, $x);
			$this->dfs($x, $cc);
		}
	}

	private function check() {
		$this->u = array_fill(0, $this->n, -1);
		$cc = 0;
		for ($i = 0; $i < $this->n; $i++) {
			if ($this->u[$i] == -1) {
				$this->dfs($i, $cc);
				$cc++;
			}
		}
		return $cc;
	}

	public function solve() {
		for ($run = true; $run; ) {
			$run = false;
			$this->check();
			// print_r($this->u);
			for ($i = 0; $i < $this->n; $i++)
				for ($j = $i + 1; $j < $this->n; $j++)
					if (count($this->g[$i]) <= 1 && count($this->g[$j]) <= 1 && ($this->u[$i] != $this->u[$j] || $this->m == $this->n - 1)) {
						// printf("pair %d %d is good\n", $i, $j);
						$run = true;
						$this->add($i, $j, true);
						$this->m += 1;
						break 2;
					}
		}
	}

	public function output() {
		$maxDegree = max(array_map(function ($a) { return count($a); }, $this->g));
		if ($this->check() == 1 && $this->n == $this->m && $maxDegree == 2) {
			print("YES\n");
			print(count($this->answer)."\n");
			foreach ($this->answer as $pair)
				printf("%d %d\n", $pair[0] + 1, $pair[1] + 1);

		} else {
			print("NO\n");
		}
	}
}

$g = new Graph();
$g->solve();
$g->output();

?>


Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.The park can be represented as a connected graph with $$$n$$$ nodes and $$$m$$$ bidirectional edges. Initially Bob is at the node $$$1$$$ and he records $$$1$$$ on his notebook. He can wander from one node to another through those bidirectional edges. Whenever he visits a node not recorded on his notebook, he records it. After he visits all nodes at least once, he stops wandering, thus finally a permutation of nodes $$$a_1, a_2, \ldots, a_n$$$ is recorded.Wandering is a boring thing, but solving problems is fascinating. Bob wants to know the lexicographically smallest sequence of nodes he can record while wandering. Bob thinks this problem is trivial, and he wants you to solve it.A sequence $$$x$$$ is lexicographically smaller than a sequence $$$y$$$ if and only if one of the following holds:   $$$x$$$ is a prefix of $$$y$$$, but $$$x \ne y$$$ (this is impossible in this problem as all considered sequences have the same length);  in the first position where $$$x$$$ and $$$y$$$ differ, the sequence $$$x$$$ has a smaller element than the corresponding element in $$$y$$$.

The first line contains two positive integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^5$$$), denoting the number of nodes and edges, respectively. The following $$$m$$$ lines describe the bidirectional edges in the graph. The $$$i$$$-th of these lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the nodes the $$$i$$$-th edge connects. Note that the graph can have multiple edges connecting the same two nodes and self-loops. It is guaranteed that the graph is connected.

Output a line containing the lexicographically smallest sequence $$$a_1, a_2, \ldots, a_n$$$ Bob can record.

NoteIn the first sample, Bob's optimal wandering path could be $$$1 \rightarrow 2 \rightarrow 1 \rightarrow 3$$$. Therefore, Bob will obtain the sequence $$$\{1, 2, 3\}$$$, which is the lexicographically smallest one.In the second sample, Bob's optimal wandering path could be $$$1 \rightarrow 4 \rightarrow 3 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 1 \rightarrow 5$$$. Therefore, Bob will obtain the sequence $$$\{1, 4, 3, 2, 5\}$$$, which is the lexicographically smallest one.


Vasya has gotten interested in programming contests in TCMCF+++ rules. On the contest n problems were suggested and every problem had a cost — a certain integral number of points (perhaps, negative or even equal to zero). According to TCMCF+++ rules, only accepted problems can earn points and the overall number of points of a contestant was equal to the product of the costs of all the problems he/she had completed. If a person didn't solve anything, then he/she didn't even appear in final standings and wasn't considered as participant. Vasya understood that to get the maximal number of points it is not always useful to solve all the problems. Unfortunately, he understood it only after the contest was finished. Now he asks you to help him: find out what problems he had to solve to earn the maximal number of points.

The first line contains an integer n (1 ≤ n ≤ 100) — the number of the suggested problems. The next line contains n space-separated integers ci ( - 100 ≤ ci ≤ 100) — the cost of the i-th task. The tasks' costs may coinсide.

Print space-separated the costs of the problems that needed to be solved to get the maximal possible number of points. Do not forget, please, that it was necessary to solve at least one problem. If there are several solutions to that problem, print any of them.


You are given an array $$$A$$$, consisting of $$$n$$$ positive integers $$$a_1, a_2, \dots, a_n$$$, and an array $$$B$$$, consisting of $$$m$$$ positive integers $$$b_1, b_2, \dots, b_m$$$. Choose some element $$$a$$$ of $$$A$$$ and some element $$$b$$$ of $$$B$$$ such that $$$a+b$$$ doesn't belong to $$$A$$$ and doesn't belong to $$$B$$$. For example, if $$$A = [2, 1, 7]$$$ and $$$B = [1, 3, 4]$$$, we can choose $$$1$$$ from $$$A$$$ and $$$4$$$ from $$$B$$$, as number $$$5 = 1 + 4$$$ doesn't belong to $$$A$$$ and doesn't belong to $$$B$$$. However, we can't choose $$$2$$$ from $$$A$$$ and $$$1$$$ from $$$B$$$, as $$$3 = 2 + 1$$$ belongs to $$$B$$$.It can be shown that such a pair exists. If there are multiple answers, print any.Choose and print any such two numbers.

The first line contains one integer $$$n$$$ ($$$1\le n \le 100$$$) — the number of elements of $$$A$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 200$$$) — the elements of $$$A$$$. The third line contains one integer $$$m$$$ ($$$1\le m \le 100$$$) — the number of elements of $$$B$$$. The fourth line contains $$$m$$$ different integers $$$b_1, b_2, \dots, b_m$$$ ($$$1 \le b_i \le 200$$$) — the elements of $$$B$$$. It can be shown that the answer always exists.

Output two numbers $$$a$$$ and $$$b$$$ such that $$$a$$$ belongs to $$$A$$$, $$$b$$$ belongs to $$$B$$$, but $$$a+b$$$ doesn't belong to nor $$$A$$$ neither $$$B$$$. If there are multiple answers, print any.

NoteIn the first example, we can choose $$$20$$$ from array $$$[20]$$$ and $$$20$$$ from array $$$[10, 20]$$$. Number $$$40 = 20 + 20$$$ doesn't belong to any of those arrays. However, it is possible to choose $$$10$$$ from the second array too.In the second example, we can choose $$$3$$$ from array $$$[3, 2, 2]$$$ and $$$1$$$ from array $$$[1, 5, 7, 7, 9]$$$. Number $$$4 = 3 + 1$$$ doesn't belong to any of those arrays.In the third example, we can choose $$$1$$$ from array $$$[1, 3, 5, 7]$$$ and $$$1$$$ from array $$$[7, 5, 3, 1]$$$. Number $$$2 = 1 + 1$$$ doesn't belong to any of those arrays.

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

$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";
?>