Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers a, b (1 ≤ a ≤ b ≤ n - k + 1, b - a ≥ k) and sign all laws with numbers lying in the segments [a; a + k - 1] and [b; b + k - 1] (borders are included).As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.

The first line contains two integers n and k (2 ≤ n ≤ 2·105, 0 < 2k ≤ n) — the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x1, x2, ..., xn — the absurdity of each law (1 ≤ xi ≤ 109).

Print two integers a, b — the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [a; a + k - 1] and [b; b + k - 1]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.

NoteIn the first sample mr. Boosch signs laws with numbers from segments [1;2] and [4;5]. The total absurdity of the signed laws equals 3 + 6 + 1 + 6 = 16.In the second sample mr. Boosch signs laws with numbers from segments [1;2] and [3;4]. The total absurdity of the signed laws equals 1 + 1 + 1 + 1 = 4.

<?php
/** SECTION 0: NOTES **/
/*
Problem:
Codeforces Contest 193 Div 2 (Unofficial Participant) Problem B

Author          : chaotic_iak (http://chaoticiak.comlu.com/)
Language        : PHP 5.4
Released under  : CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
Template version: 20130720 (http://chaoticiak.comlu.com/prog/assorted/templates.phps)
                           (http://ideone.com/AV2T2U)
*/

/** SECTION 1: SET UP INPUT HANDLER **/
// 0: Don't output format at all
// 1: Trim newline characters only
// 2: Assume \x00..\x20 (accaw) as delimiters and output as array

if (isset($inputstream)) {$stdin = $inputstream;} else {$stdin = fopen("php://stdin", "r");}
function g($format = 2) {
    global $stdin;
    $input = fgets($stdin);
    if ($format == 0) {return $input;}
    $input = trim($input, "\n\r");
    if ($format == 1) {return $input;}
    $input = trim($input, "\x00..\x20");
    $input = preg_replace("/[\\x00-\\x20]+/", " ", $input);
    return explode(" ", $input);
}

/** SECTION 2: IMPORT FUNCTIONS FROM chaotic_iak'S LIBRARY **/
// none

/** SECTION 3: SOLVING THE PROBLEM **/
$raw = g();
$n = $raw[0];
$k = $raw[1];
$x = g();

$currl = 0; $currr = 0;
for ($j = 0; $j < $k; $j++) {
	$currl += $x[$j];
	$currr += $x[$n-1-$j];
}
$left = array($currl); $right = array($currr);
$leftindex = array(0); $rightindex = array(0);
for ($i = 1; $i <= $n - (2*$k); $i++) {
	$currl = $currl - $x[$i-1] + $x[$i-1+$k];
	$currr = $currr - $x[$n-$i] + $x[$n-$i-$k];
	if ($left[$i-1] < $currl) {$left[] = $currl; $leftindex[] = $i;} else {$left[] = $left[$i-1]; $leftindex[] = $leftindex[$i-1];}
	if ($right[$i-1] <= $currr) {$right[] = $currr; $rightindex[] = $i;} else {$right[] = $right[$i-1]; $rightindex[] = $rightindex[$i-1];}
}
// print_r($left); print_r($right); print_r($leftindex); print_r($rightindex);

$max = 0; $a = 0; $b = $n;
for ($i = 0; $i <= $n - (2*$k); $i++) {
	$sum = $left[$i] + $right[$n-2*$k-$i];
	if ($max < $sum) {$max = $sum; $a = $leftindex[$i]; $b = $n-$k - $rightindex[$n-2*$k-$i];}
}
echo ($a+1) . " " . ($b+1);

<?php
/** SECTION 0: NOTES **/
/*
Problem:
Codeforces Contest 193 Div 2 (Unofficial Participant) Problem B

Author          : chaotic_iak (http://chaoticiak.comlu.com/)
Language        : PHP 5.4
Released under  : CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
Template version: 20130720 (http://chaoticiak.comlu.com/prog/assorted/templates.phps)
                           (http://ideone.com/AV2T2U)
*/

/** SECTION 1: SET UP INPUT HANDLER **/
// 0: Don't output format at all
// 1: Trim newline characters only
// 2: Assume \x00..\x20 (accaw) as delimiters and output as array

if (isset($inputstream)) {$stdin = $inputstream;} else {$stdin = fopen("php://stdin", "r");}
function g($format = 2) {
    global $stdin;
    $input = fgets($stdin);
    if ($format == 0) {return $input;}
    $input = trim($input, "\n\r");
    if ($format == 1) {return $input;}
    $input = trim($input, "\x00..\x20");
    $input = preg_replace("/[\\x00-\\x20]+/", " ", $input);
    return explode(" ", $input);
}

/** SECTION 2: IMPORT FUNCTIONS FROM chaotic_iak'S LIBRARY **/
// none

/** SECTION 3: SOLVING THE PROBLEM **/
$raw = g();
$n = $raw[0];
$k = $raw[1];
$x = g();

$left = array(-1 => 0); $right = array(-1 => 0);
$leftindex = array(); $rightindex = array();
for ($i = 0; $i <= $n - (2*$k); $i++) {
	$currl = 0;
	$currr = 0;
	for ($j = 0; $j < $k; $j++) {
		$currl += $x[$i+$j];
		$currr += $x[$n-1-$i-$j];
	}
	if ($left[$i-1] < $currl) {$left[] = $currl; $leftindex[] = $i;} else {$left[] = $left[$i-1]; $leftindex[] = $leftindex[$i-1];}
	if ($right[$i-1] <= $currr) {$right[] = $currr; $rightindex[] = $i;} else {$right[] = $right[$i-1]; $rightindex[] = $rightindex[$i-1];}
}

$max = 0; $a = 0; $b = $n;
for ($i = 0; $i <= $n-(2*$k); $i++) {
	$sum = $left[$i] + $right[$n-2*$k-$i];
	if ($max < $sum) {$max = $sum; $a = $leftindex[$i]; $b = $rightindex[$n-2*$k-$i];}
}
echo ($a+1) . " " . ($b+1);


You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right.To cyclically shift a table row one cell to the right means to move the value of each cell, except for the last one, to the right neighboring cell, and to move the value of the last cell to the first cell. A cyclical shift of a row to the left is performed similarly, but in the other direction. For example, if we cyclically shift a row "00110" one cell to the right, we get a row "00011", but if we shift a row "00110" one cell to the left, we get a row "01100".Determine the minimum number of moves needed to make some table column consist only of numbers 1.

The first line contains two space-separated integers: n (1 ≤ n ≤ 100) — the number of rows in the table and m (1 ≤ m ≤ 104) — the number of columns in the table. Then n lines follow, each of them contains m characters "0" or "1": the j-th character of the i-th line describes the contents of the cell in the i-th row and in the j-th column of the table. It is guaranteed that the description of the table contains no other characters besides "0" and "1".

Print a single number: the minimum number of moves needed to get only numbers 1 in some column of the table. If this is impossible, print -1.

NoteIn the first sample one way to achieve the goal with the least number of moves is as follows: cyclically shift the second row to the right once, then shift the third row to the left twice. Then the table column before the last one will contain only 1s.In the second sample one can't shift the rows to get a column containing only 1s.


Two players play a game.Initially there are $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. $$$n - 1$$$ turns are made. The first player makes the first move, then players alternate turns.The first player wants to minimize the last number that would be left on the board, while the second player wants to maximize it.You want to know what number will be left on the board after $$$n - 1$$$ turns if both players make optimal moves.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of numbers on the board. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^6$$$).

Print one number that will be left on the board.

NoteIn the first sample, the first player erases $$$3$$$ and the second erases $$$1$$$. $$$2$$$ is left on the board.In the second sample, $$$2$$$ is left on the board regardless of the actions of the players.

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
sort($b);
$c = 0;
for($x = 0; $x < $a - 1; $x++)
{
     $d = $c % 2;
     $c++;
     if($d == 0)
     {
          array_splice($b, -1);
     }
     else
     {
          array_splice($b, 0, 1);
     }
}
print $b[0]
?>

<?php

$n = readline();
$ara = explode(' ', readline());

rsort($ara);

echo (($n/2==0)?$ara[intval($n/2)-1]:$ara[floor($n/2)]);

<?php
  $w = fgets(STDIN);
  $s = explode(' ', trim(fgets(STDIN)));

  sort($s);
  if(!($w%2)) echo $s[$w/2 -1];
  else        echo $s[$w/2];
?>

<?php
$n =  (int)fgets(STDIN);

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

sort($numbers);

$m = floor(($n - 1)/2);

echo $numbers[$m];

<?php

$n = (int) fgets(STDIN);
$nums = array_map('intval', explode(' ', fgets(STDIN)));

rsort($nums);

$id = (int) (count($nums) / 2);

echo $nums[$id];

<?php
$board = array ();
$n  = null;          // Number of elements in board
$p1 = true;          // Wants to minimize the last number = select the maximum
                     // p2 Wants to maximize the last number = select the minimum

/* Input */
$n                = intval (readline ());
$string_of_values = readline ();
// Fill board
$board = explode (" ", $string_of_values);
unset ($string_of_values);

/* Process */
sort ($board);
while ($n > 1)
{
        if ($p1)
        {
                $p1 = false;
                array_pop ($board);
        }
        else
        {
                $p1 = true;
                array_shift ($board);
        }
        --$n;
}

/* Output */
echo $board[0];

<?php

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

fscanf($handle, "%i", $d);

$numbers = array_map('intval', explode(' ', trim(fgets($handle))));

sort($numbers);

echo $numbers[floor(($d - 1) / 2)];

<?php
$n =  (int)fgets(STDIN);

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

sort($numbers);

if (count($numbers) > 1) {
    echo $numbers[1];
} else {
    echo $numbers[0];
}

<?php
$n =  (int)fgets(STDIN);

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

sort($numbers);

$m = floor($n/2);

echo $numbers[$m];

<?php

$n = (int) fgets(STDIN);
$nums = array_map('intval', explode(' ', fgets(STDIN)));

sort($nums);

$middle = (int) ceil(count($nums) / 2);

echo $nums[$middle];

<?php

$n = (int) fgets(STDIN);
$nums = array_map('intval', explode(' ', fgets(STDIN)));

sort($nums);

$id = (int) (count($nums) / 2);

echo $nums[$id];

// 38 82 23 37 96 4 81 60 67 86
// 1 2 3 4

<?php

$n = (int) fgets(STDIN);
$nums = array_map('intval', explode(' ', fgets(STDIN)));

sort($nums);

$middle = (int) floor(count($nums) / 2);

echo $nums[$middle];

<?php

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

fscanf($handle, "%i", $d);

$numbers = array_map('intval', explode(' ', trim(fgets($handle))));

sort($numbers);

echo $numbers[floor($d / 2)];

<?php

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

fscanf($handle, "%i %i", $n, $m);

$field = [];
$bombs = [];

$totalSum = 0;

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

    $row = str_split(trim(fgets($handle)));

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

        if ($row[$j] == '*') {

            if (!isset($bombs[$i])) {
                $bombs[$i] = [];
            }

            $bombs[$i][] = $j;
        } elseif ($row[$j] != '.') {

            $row[$j] = intval($row[$j]);;
            $totalSum += $row[$j];
        }
    }

    $field[] = $row;
}

$result = 'YES';

foreach ($bombs as $row => $cols) {

    foreach ($cols as $col) {

        $numCount = 0;

        for ($i = -1; $i < 2; $i++) {

            for ($j = -1; $j < 2; $j++) {

                if ($i != 0 || $j != 0) {

                    if (isset($field[$row + $i][$col + $j])) {

                        $val = $field[$row + $i][$col + $j];

                        if ($val == '.' || ($val != '*' && $val == 0)) {

                            $result = 'NO';
                            break;
                        } elseif ($val != '*') {

                            $numCount++;
                            $field[$row + $i][$col + $j]--;
                            $totalSum--;
                        }
                    }
                }
            }
        }
    }

    if ($result == 'NO') {
        break;
    }
}

if ($totalSum != 0) {
    $result = 'NO';
}

echo $result;


As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.Let's consider a set of functions of the following form:  Let's define a sum of n functions y1(x), ..., yn(x) of the given type as function s(x) = y1(x) + ... + yn(x) for any x. It's easy to show that in this case the graph s(x) is a polyline. You are given n functions of the given type, your task is to find the number of angles that do not equal 180 degrees, in the graph s(x), that is the sum of the given functions.Valeric and Valerko really want to watch the next Euro Championship game, so they asked you to help them.

The first line contains integer n (1 ≤ n ≤ 105) — the number of functions. Each of the following n lines contains two space-separated integer numbers ki, bi ( - 109 ≤ ki, bi ≤ 109) that determine the i-th function.

Print a single number — the number of angles that do not equal 180 degrees in the graph of the polyline that equals the sum of the given functions.

<?php
// Retrieve input and show output
$stream = fopen("php://stdin", "r");
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 123 Division 2 Problem D
function func($in) {
$lines = $in[0];
for ($x = 0; $x < $lines; $x++) {
	$slope[$x] = $in[2 * $x + 1];
	$ycut[$x] = $in[2 * $x + 2];
}

$count = 0;
for ($x = 0; $x < $lines; $x++) {
	if ($slope[$x] != 0) {
		$slopea = $slope[$x] / gcd($slope[$x], $ycut[$x]);
		$ycuta = $ycut[$x] / gcd($slope[$x], $ycut[$x]);
		if ($slopea < 0) {
			$slopea = -$slopea;
			$ycuta = -$ycuta;
		}
		if ($cuts[-$ycuta][$slopea] == 0) {
			$cuts[-$ycuta][$slopea] = 1;
			$count += 1;
		}
	}
}

return $count;
}

function gcd($a, $b) {
$a = abs($a);
$b = abs($b);
if ($a < $b) {
	$max = $b;
	$min = $a;
} else {
	$max = $a;
	$min = $b;
}
while ($min != 0) {
	$max = $max % $min;
	if ($max < $min) {
		$t = $max;
		$max = $min;
		$min = $t;
	}
}

return $max;
}

// End of submission file
// Submission by chaotic_iak
?>

<?php
// Retrieve input and show output
$stream = fopen("php://stdin", "r");
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 123 Division 2 Problem D
function func($in) {
$lines = $in[0];
for ($x = 0; $x < $lines; $x++) {
	$slope[$x] = $in[2 * $x + 1];
	$ycut[$x] = $in[2 * $x + 2];
}

for ($x = 0; $x < $lines; $x++) {
	if ($slope[$x] != 0) {
		$cuts[(string) (-$ycut[$x] / $slope[$x])] = 1;
	}
}

return count($cuts);
}

// End of submission file
// Submission by chaotic_iak
?>

<?php
// Retrieve input and show output
$stream = fopen("php://stdin", "r");
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 123 Division 2 Problem D
function func($in) {
$lines = $in[0];
for ($x = 0; $x < $lines; $x++) {
	$slope[$x] = $in[2 * $x + 1];
	$ycut[$x] = $in[2 * $x + 2];
}

$count = 0;
for ($x = 0; $x < $lines; $x++) {
	if ($slope[$x] != 0) {
		$slopea = $slope[$x] / gcd($slope[$x], $ycut[$x]);
		$ycuta = $ycut[$x] / gcd($slope[$x], $ycut[$x]);
		if ($cuts[-$ycuta][$slopea] == 0) {
			$cuts[-$ycuta][$slopea] = 1;
			$count += 1;
		}
	}
}

return $count;
}

function gcd($a, $b) {
$a = abs($a);
$b = abs($b);
if ($a < $b) {
	$max = $b;
	$min = $a;
} else {
	$max = $a;
	$min = $b;
}
while ($min != 0) {
	$max -= $min;
	if ($max < $min) {
		$t = $max;
		$max = $min;
		$min = $t;
	}
}

return $max;
}

// End of submission file
// Submission by chaotic_iak
?>


Polycarp has n dice d1, d2, ..., dn. The i-th dice shows numbers from 1 to di. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values d1, d2, ..., dn. However, she finds it enough to make a series of statements of the following type: dice i couldn't show number r. For example, if Polycarp had two six-faced dice and the total sum is A = 11, then Agrippina can state that each of the two dice couldn't show a value less than five (otherwise, the remaining dice must have a value of at least seven, which is impossible).For each dice find the number of values for which it can be guaranteed that the dice couldn't show these values if the sum of the shown values is A.

The first line contains two integers n, A (1 ≤ n ≤ 2·105, n ≤ A ≤ s) — the number of dice and the sum of shown values where s = d1 + d2 + ... + dn. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 106), where di is the maximum value that the i-th dice can show.

Print n integers b1, b2, ..., bn, where bi is the number of values for which it is guaranteed that the i-th dice couldn't show them.

NoteIn the first sample from the statement A equal to 8 could be obtained in the only case when both the first and the second dice show 4. Correspondingly, both dice couldn't show values 1, 2 or 3.In the second sample from the statement A equal to 3 could be obtained when the single dice shows 3. Correspondingly, it couldn't show 1, 2, 4 or 5.In the third sample from the statement A equal to 3 could be obtained when one dice shows 1 and the other dice shows 2. That's why the first dice doesn't have any values it couldn't show and the second dice couldn't show 3.

<?php

error_reporting(0);
main();

function main() {
    $scn = new Scanner();
    $dice = array();
    $grand = 0;

    $n = (int) $scn->in();
    $sum = (double) $scn->in();
    for ($i = 0; $i <= $n - 1; $i++) {
        $dice[$i] = (double) $scn->in();
        $grand += $dice[$i];
    }
    for ($i = 0; $i <= $n - 1; $i++) {
        $temp = ($sum - $n) + 1;
        $high = ($temp >= $dice[$i]) ? $dice[$i] : $temp;

        $temp = $grand - $dice[$i];
        $low = ($temp >= $sum) ? 1 : $sum - $temp;
        printf("%.0lf\n", $dice[$i] - (($high - $low) + 1));
    }
}

class Scanner {
    private $handle = "";
    private $values = array();
    private $index = 0;

    public function __construct($localfile){
        if (is_file($localfile)) {
            $this->handle = fopen($localfile, "r");
            $contents = stream_get_contents($this->handle);
        }
        else
            $contents = stream_get_contents(STDIN);
        $no_newlines = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
        $this->values = explode(" ", $no_newlines);
    }
    public function in(){
        return $this->values[$this->index++];
    }
    public function close(){
        if (is_file($localfile) && feof($this->handle))
            fclose($this->handle);
    }
}
?>

<?php
    define("stdin", fopen("php://stdin", 'r'), true);
    $dice = array();
    $grand = 0;

    fscanf(stdin, "%d %lf", $n, $sum);
    for ($i = 0; $i <= $n - 1; $i++) {
        fscanf(stdin, "%lf", $dice[i]);
        $grand += $dice[i];
    }
    for ($i = 0; $i <= $n - 1; $i++) {
        $temp = ($sum - $n) + 1;
        $high = ($temp >= $dice[i]) ? $dice[i] : $temp;

        $temp = $grand - $dice[i];
        $low = ($temp >= $sum) ? 1 : $sum - $temp;
        printf("%.0lf ", $dice[i] - (($high - $low) + 1));
    }
?>


Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed to help if Rostislav solves a simple task (and if he doesn't, then why would he need Splay trees anyway?)Given integers l, r and k, you need to print all powers of number k within range from l to r inclusive. However, Rostislav doesn't want to spent time doing this, as he got interested in playing a network game called Agar with Gleb. Help him!

The first line of the input contains three space-separated integers l, r and k (1 ≤ l ≤ r ≤ 1018, 2 ≤ k ≤ 109).

Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).

NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.

<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
$d = array();
$e = 0;
$f = 0;
while(TRUE)
{
    $g = bcpow($c, $e);
    if(($g >= $a) && ($g <= $b))
    {
        $d[$f] = $g;
        $e = bcadd($e, 1);
        $f = bcadd($f, 1);
    }
    elseif($g < $a)
    {
        $e = bcadd($e, 1);
    }
    elseif($g > $b)
    {
        break;
    }
}
if(count($d) == 0)
{
    print "-1";
}
else
{
    print implode(" ", $d);
}
?>


The robot is placed in the top left corner of a grid, consisting of $$$n$$$ rows and $$$m$$$ columns, in a cell $$$(1, 1)$$$.In one step, it can move into a cell, adjacent by a side to the current one:   $$$(x, y) \rightarrow (x, y + 1)$$$;  $$$(x, y) \rightarrow (x + 1, y)$$$;  $$$(x, y) \rightarrow (x, y - 1)$$$;  $$$(x, y) \rightarrow (x - 1, y)$$$. The robot can't move outside the grid.The cell $$$(s_x, s_y)$$$ contains a deadly laser. If the robot comes into some cell that has distance less than or equal to $$$d$$$ to the laser, it gets evaporated. The distance between two cells $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ is $$$|x_1 - x_2| + |y_1 - y_2|$$$.Print the smallest number of steps that the robot can take to reach the cell $$$(n, m)$$$ without getting evaporated or moving outside the grid. If it's not possible to reach the cell $$$(n, m)$$$, print -1.The laser is neither in the starting cell, nor in the ending cell. The starting cell always has distance greater than $$$d$$$ to the laser.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The only line of each testcase contains five integers $$$n, m, s_x, s_y, d$$$ ($$$2 \le n, m \le 1000$$$; $$$1 \le s_x \le n$$$; $$$1 \le s_y \le m$$$; $$$0 \le d \le n + m$$$) — the size of the grid, the cell that contains the laser and the evaporating distance of the laser. The laser is neither in the starting cell, nor in the ending cell ($$$(s_x, s_y) \neq (1, 1)$$$ and $$$(s_x, s_y) \neq (n, m)$$$). The starting cell $$$(1, 1)$$$ always has distance greater than $$$d$$$ to the laser ($$$|s_x - 1| + |s_y - 1| > d$$$).

For each testcase, print a single integer. If it's possible to reach the cell $$$(n, m)$$$ from $$$(1, 1)$$$ without getting evaporated or moving outside the grid, then print the smallest amount of steps it can take the robot to reach it. Otherwise, print -1.


You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provide cellular network for all cities, which are located at the distance which is no more than r from this tower.Your task is to find minimal r that each city has been provided by cellular network, i.e. for each city there is at least one cellular tower at the distance which is no more than r.If r = 0 then a tower provides cellular network only for the point where it is located. One tower can provide cellular network for any number of cities, but all these cities must be at the distance which is no more than r from this tower.

The first line contains two positive integers n and m (1 ≤ n, m ≤ 105) — the number of cities and the number of cellular towers. The second line contains a sequence of n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the coordinates of cities. It is allowed that there are any number of cities in the same point. All coordinates ai are given in non-decreasing order. The third line contains a sequence of m integers b1, b2, ..., bm ( - 109 ≤ bj ≤ 109) — the coordinates of cellular towers. It is allowed that there are any number of towers in the same point. All coordinates bj are given in non-decreasing order.

Print minimal r so that each city will be covered by cellular network.


The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts $$$h$$$ hours and each hour lasts $$$m$$$ minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows the number of minutes in decimal; the number of minutes and hours is written with leading zeros if needed to form a two-digit number). Hours are numbered from $$$0$$$ to $$$h-1$$$ and minutes are numbered from $$$0$$$ to $$$m-1$$$.  That's how the digits are displayed on the clock. Please note that digit $$$1$$$ is placed in the middle of its position. A standard mirror is in use on the planet Lapituletti. Inhabitants often look at the reflection of the digital clocks in the mirror and feel happy when what you see on the reflected clocks is a valid time (that means that you see valid digits in the reflection and this time can be seen on the normal clocks at some moment of a day).The image of the clocks in the mirror is reflected against a vertical axis.  The reflection is not a valid time.The reflection is a valid time with $$$h=24$$$, $$$m = 60$$$. However, for example, if $$$h=10$$$, $$$m=60$$$, then the reflection is not a valid time. An inhabitant of the planet Lapituletti begins to look at a mirrored image of the clocks at some time moment $$$s$$$ and wants to know the nearest future time moment (which can possibly happen on the next day), when the reflected clock time is valid.It can be shown that with any $$$h$$$, $$$m$$$, $$$s$$$ such a moment exists. If the reflected time is correct at the moment the inhabitant began to look at the clock, that moment is considered the nearest.You are asked to solve the problem for several test cases.

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. The next $$$2 \cdot T$$$ lines contain the description of test cases. The description of each test case consists of two lines. The first line of a test case contains two integers $$$h$$$, $$$m$$$ ($$$1 \le h, m \le 100$$$). The second line contains the start time $$$s$$$ in the described format HH:MM.

For each test case output in a separate line the nearest moment in format HH:MM when the reflected time is correct.

NoteIn the second test case it is not hard to show that the reflection of 23:59 is incorrect, while the reflection of the moment 00:00 on the next day is correct.

<?php

$times = (int)trim(fgets(STDIN));
for ($idx = 0; $idx < $times; ++$idx) {
    list($hi[], $mi[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    list($hhi[], $mmi[]) = array_map('intval', explode(':', trim(fgets(STDIN))));
}

$mirror = [0, 1, 5, -1, -1, 2, -1, -1, 8, -1];
for ($idx = 0; $idx < $times; ++$idx) {
    $h = &$hi[$idx];
    $m = &$mi[$idx];
    $hh = &$hhi[$idx];
    $mm = &$mmi[$idx];
    for ($i = 0; $i < $h * $m; ++$i) {
        $cur = $hh * $m + $mm + $i;
        $cur1 = sprintf('%02d', floor(($cur % ($h * $m)) / $m));
        $cur2 = sprintf('%02d', $cur % $m);
        $s = strrev($cur1 . $cur2);
        $t = '';
        for ($j = 0; $j < 4; ++$j) {
            if ($mirror[$s[$j]] < 0) {
                continue 2;
            } else {
                $t .= $mirror[$s[$j]];
            }
        }
        if (substr($t, 0, 2) < $h && substr($t, 2, 2) < $m) {
            echo $cur1 . ':' . $cur2 . PHP_EOL;
            continue 2;
        }
    }
}

<?php
	$t = trim(fgets(STDIN));
	function check_reversed_number_if_valid_please($str, $h, $m) {
		$str2 = "";
		$reversable = [0, 1, 2, 5, 8];
		for ($i = 4; $i >= 0; $i--) {
			if (in_array(intval($str[$i]), $reversable) || $str[$i] == ':') {
				$str2 .= (intval($str[$i]) == 2 ? '5' : (intval($str[$i]) == 5 ? '2' : $str[$i]));
			} else {
				return false;
			}
		}
		list($h2, $m2) = explode(":", $str2);
		if (intval($h2) >= $h || intval($m2) >= $m) {
			return false;
		}
		return true;
	}

	function increment_time_minutes_please($str, $h, $m) {
		list($h2, $m2) = explode(":", $str);
		$h2 = intval($h2);
		$m2 = intval($m2);
		if ($m2 + 1 == $m) {
			$h2++;
			$m2 = 0;
		} else {
			$m2++;
		}
		if ($h2 == $h) {
			$h2 = 0;
		}

		return ($h2 >= 10 ? $h2 : "0".$h2).":".($m2 >= 10 ? $m2 : "0".$m2);
	}

	for ($o = 0; $o < $t; $o++) {
		list($h, $m) = explode(" ", trim(fgets(STDIN)));
		$time = trim(fgets(STDIN));
		for ($i = 0; $i < $h*$m; $i++)
			if (check_reversed_number_if_valid_please($time, $h, $m)) {
				print $time."\n";
				break;
			} else {
				$time = increment_time_minutes_please($time, $h, $m);
			}
		}
?>


Theater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.You are to place a spotlight on the stage in some good position. The spotlight will project light in one of the four directions (if you look at the stage from above) — left, right, up or down. Thus, the spotlight's position is a cell it is placed to and a direction it shines.A position is good if two conditions hold:   there is no actor in the cell the spotlight is placed to;  there is at least one actor in the direction the spotlight projects. Count the number of good positions for placing the spotlight. Two positions of spotlight are considered to be different if the location cells or projection direction differ.

The first line contains two positive integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and the number of columns in the plan. The next n lines contain m integers, 0 or 1 each — the description of the plan. Integer 1, means there will be an actor in the corresponding cell, while 0 means the cell will remain empty. It is guaranteed that there is at least one actor in the plan.

Print one integer — the number of good positions for placing the spotlight.

NoteIn the first example the following positions are good:  the (1, 1) cell and right direction;  the (1, 1) cell and down direction;  the (1, 3) cell and left direction;  the (1, 3) cell and down direction;  the (1, 4) cell and left direction;  the (2, 2) cell and left direction;  the (2, 2) cell and up direction;  the (2, 2) and right direction;  the (2, 4) cell and left direction. Therefore, there are 9 good positions in this example.

<?php
fscanf(STDIN, '%d %d', $n, $m);
$st=array();
for($i=0; $i<$n; $i++) $st[$i]=explode(" ", fgets(STDIN));

$count = 0;
$row = 0;
$zeros = 0;
$zeros_temp = 0;

for($i=0; $i<$n; $i++){
  for($j=0; $j<$m; $j++){
    if($st[$i][$j] == 0){
        if($row) $count++;
        $zeros_temp++;
    }
    else{
        $row = 1;
        $zeros += $zeros_temp;
        $zeros_temp = 0;
    }
  }
  $count += $zeros;
  $row = 0;
  $zeros = 0;
  $zeros_temp = 0;
}

for($j=0; $j<$m; $j++){
  for($i=0; $i<$n; $i++){
    if($st[$i][$j] == 0){
        if($row) $count++;
        $zeros_temp++;
    }
    else{
        $row = 1;
        $zeros += $zeros_temp;
        $zeros_temp = 0;
    }
  }
  $count += $zeros;
  $row = 0;
  $zeros = 0;
  $zeros_temp = 0;
}

print $count;
?>

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m, k, i, j, count=0;
    cin>>n>>m;

    int st[n][m];
    for(i = 0; i < n; i++)
		for(j = 0; j < m; j++)
		cin >> st[i][j];

	for(i=0; i<n; i++){
  for(j=0; j<m; j++){
    if(st[i][j] == 0){
      //top
      for(k=0; k<i; k++){
        if(st[k][j] == 1){
          count++;
          break;
        }
      }

      //bottom
      for(k=i+1; k<n; k++){
        if(st[k][j] == 1){
          count++;
          break;
        }
      }

      //left
      for(k=0; k<j; k++){
        if(st[i][k] == 1){
          count++;
          break;
        }
      }

      //right
      for(k=j+1; k<m; k++){
        if(st[i][k] == 1){
          count++;
          break;
        }
      }
    }
  }
}

cout<<count;

    return 0;
}


Dreamoon is a big fan of the Codeforces contests.One day, he claimed that he will collect all the places from $$$1$$$ to $$$54$$$ after two more rated contests. It's amazing!Based on this, you come up with the following problem:There is a person who participated in $$$n$$$ Codeforces rounds. His place in the first round is $$$a_1$$$, his place in the second round is $$$a_2$$$, ..., his place in the $$$n$$$-th round is $$$a_n$$$.You are given a positive non-zero integer $$$x$$$.Please, find the largest $$$v$$$ such that this person can collect all the places from $$$1$$$ to $$$v$$$ after $$$x$$$ more rated contests.In other words, you need to find the largest $$$v$$$, such that it is possible, that after $$$x$$$ more rated contests, for each $$$1 \leq i \leq v$$$, there will exist a contest where this person took the $$$i$$$-th place.For example, if $$$n=6$$$, $$$x=2$$$ and $$$a=[3,1,1,5,7,10]$$$ then answer is $$$v=5$$$, because if on the next two contest he will take places $$$2$$$ and $$$4$$$, then he will collect all places from $$$1$$$ to $$$5$$$, so it is possible to get $$$v=5$$$.

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5$$$) denoting the number of test cases in the input. Each test case contains two lines. The first line contains two integers $$$n, x$$$ ($$$1 \leq n, x \leq 100$$$). The second line contains $$$n$$$ positive non-zero integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 100$$$).

For each test case print one line containing the largest $$$v$$$, such that it is possible that after $$$x$$$ other contests, for each $$$1 \leq i \leq v$$$, there will exist a contest where this person took the $$$i$$$-th place.

NoteThe first test case is described in the statement.In the second test case, the person has one hundred future contests, so he can take place $$$1,2,\ldots,99$$$ and place $$$101$$$ on them in some order, to collect places $$$1,2,\ldots,101$$$.

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     $d = explode(" ", trim(fgets(STDIN)));
     $e = array_unique($d);
     sort($e);
     $f = array_fill(1, 1000, 0);
     for($y = 0; $y < count($e); $y++)
     {
          $f[$e[$y]] = 1;
     }
     for($y = 1; $y <= count($f); $y++)
     {
          if($f[$y] == TRUE)
          {
               continue;
          }
          else
          {
               $c--;
               if($c == 0)
               {
                    for($z = $y + 1; $z <= count($f); $z++)
                    {
                         if($f[$z] == FALSE)
                         {
                              break;
                         }
                    }
                    break;
               }
          }
     }
     print $z - 1 . "\n";
}
?>

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

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

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

        $n = intval($in_str[0]) ;
        $x = intval($in_str[1]) ;

        $in_str = explode(" ", trim(fgets(STDIN))) ;

        $f = array_fill(0, 201, false) ;
        for($i = 0; $i < $n; $i ++)
        {
            $in_str[$i] = intval($in_str[$i]) ;

            $f[$in_str[$i]] = true ;
        }

        $ans = 0 ;
        for($i = 1; $i <= 200; $i ++)
        {
            if($f[$i])
            {
                $ans = $i ;
                continue ;
            }

            if($x > 0) $x -- ;
            else break ;
            $ans = $i;
        }
        echo $ans + $x . "\n" ;
    }
?>

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

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

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

        $n = intval($in_str[0]) ;
        $x = intval($in_str[1]) ;

        $in_str = explode(" ", trim(fgets(STDIN))) ;

        $f = array_fill(0, 201, false) ;
        for($i = 0; $i < $n; $i ++)
        {
            $in_str[$i] = intval($in_str[$i]) ;

            $f[$in_str[$i]] = true ;
        }

        $ans = 0 ;
        for($i = 1; $i <= 200; $i ++)
        {
            if($f[$i]) continue ;

            if($x > 0) $x -- ;
            else
            {
                $ans = $i - 1 ;
                break ;
            }
        }
        echo $ans + $x . "\n" ;
    }
?>

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

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

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

        $n = intval($in_str[0]) ;
        $x = intval($in_str[1]) ;

        $in_str = explode(" ", trim(fgets(STDIN))) ;

        $f = array_fill(0, 201, false) ;
        for($i = 0; $i < $n; $i ++)
        {
            $in_str[$i] = intval($in_str[$i]) ;

            $f[$in_str[$i]] = true ;
        }

        $ans = 0 ;
        for($i = 1; $i <= 200; $i ++)
        {
            if($f[$i]) continue ;

            if($x > 0) $x -- ;
            else break ;
            $ans = $i;
        }
        echo $ans + $x . "\n" ;
    }
?>

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

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

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

        $n = intval($in_str[0]) ;
        $x = intval($in_str[1]) ;

        $in_str = explode(" ", trim(fgets(STDIN))) ;

        $f = array_fill(0, 201, false) ;
        for($i = 0; $i < $n; $i ++)
        {
            $in_str[$i] = intval($in_str[$i]) ;

            $f[$in_str[$i]] = true ;
        }

        $ans = 0 ;
        for($i = 1; $i <= 200; $i ++)
        {
            if($f[$i]) continue ;

            if($x > 0) $x -- ;
            else
            {
                $ans = $i - 1 ;
                break ;
            }
        }
        echo $ans . "\n" ;
    }
?>


Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed k hours for this. He also found that the light in the train changes every hour. The light is measured on a scale from 0 to 100, where 0 is very dark, and 100 is very light.Vasya has a train lighting schedule for all n hours of the trip — n numbers from 0 to 100 each (the light level in the first hour, the second hour and so on). During each of those hours he will either read the whole time, or not read at all. He wants to choose k hours to read a book, not necessarily consecutive, so that the minimum level of light among the selected hours were maximum. Vasya is very excited before the upcoming contest, help him choose reading hours.

The first input line contains two integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ n) — the number of hours on the train and the number of hours to read, correspondingly. The second line contains n space-separated integers ai (0 ≤ ai ≤ 100), ai is the light level at the i-th hour.

In the first output line print the minimum light level Vasya will read at. In the second line print k distinct space-separated integers b1, b2, ..., bk, — the indexes of hours Vasya will read at (1 ≤ bi ≤ n). The hours are indexed starting from 1. If there are multiple optimal solutions, print any of them. Print the numbers bi in an arbitrary order.

NoteIn the first sample Vasya should read at the first hour (light 20), third hour (light 30) and at the fourth hour (light 40). The minimum light Vasya will have to read at is 20.

<?php
$i = 1;

$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', '101 '.fgets($handle));
fclose($handle);

arsort ($hList, SORT_NUMERIC);
$newhList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('output.txt', 'w');
fputs($handle, end($newhList)."\n");
fputs($handle, implode(' ',array_keys($newhList)));
fclose($handle);

<?php
$i = 1;

$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', '101 '.fgets($handle));
fclose($handle);

arsort ($hList);
$newhList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('output.txt', 'w');

if (count($newhList)>3){
fputs($handle, var_export($hList, true)."\n");
fputs($handle, var_export($newhList, true)."\n");
}
fputs($handle, end($newhList)."\n");
fputs($handle, implode(' ',array_keys($newhList)));
fclose($handle);

<?php
$i = 1;

$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', fgets($handle));
fclose($handle);

array_unshift($hList, PHP_INT_MAX);
arsort ($hList);
$newhList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('output.txt', 'w');
fputs($handle, end($newhList)."\n");
fputs($handle, implode(' ',array_keys($newhList)));
fclose($handle);

<?php
$i = 1;

$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', '101 '.fgets($handle));
fclose($handle);

arsort ($hList);
$newhList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('output.txt', 'w');
fputs($handle, var_export($newhList, true)."\n");
fputs($handle, end($newhList)." your checker REALLY SUCKS! \n");
fputs($handle, implode(' ',array_keys($newhList)));
fclose($handle);

<?php
/*
$time_start = microtime(true);
$mem_start = memory_get_usage();
*/
$i = 1;

$handle = @fopen('c:/input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', fgets($handle));
fclose($handle);

array_unshift($hList, PHP_INT_MAX);
arsort ($hList);
$hList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('c:/output.txt', 'w');
fputs($handle, end($hList)."\n");
fputs($handle, implode(' ',array_keys($hList)));
fclose($handle);

/*
$mem_end = memory_get_usage();
$time_end = microtime(true);
echo "Time: ", ($time_end - $time_start)*1000, " MSec\n";
echo "Memory: ", ($mem_end - $mem_start)/1024, " Kb\n";
*/

<?php
/*
$time_start = microtime(true);
$mem_start = memory_get_usage();
*/
$i = 1;

//$handle = @fopen('c:/input.txt', 'r');
$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', fgets($handle));
fclose($handle);

array_unshift($hList, PHP_INT_MAX);
arsort ($hList);
$hList = array_slice($hList, 1, $hRead, true );

//$handle = @fopen('c:/output.txt', 'w');
$handle = @fopen('output.txt', 'w');
fputs($handle, end($hList)."\n");
fputs($handle, implode(' ',array_keys($hList)));
fclose($handle);

/*
$mem_end = memory_get_usage();
$time_end = microtime(true);
echo "Time: ", ($time_end - $time_start)*1000, " MSec\n";
echo "Memory: ", ($mem_end - $mem_start)/1024, " Kb\n";
*/

<?php
$i = 1;

$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', '101 '.fgets($handle));
fclose($handle);

arsort ($hList);
$newhList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('output.txt', 'w');

if (count($newhList)>3){
fputs($handle, var_export($newhList, true)."\n");
}
fputs($handle, end($newhList)."\n");
fputs($handle, implode(' ',array_keys($newhList)));
fclose($handle);

<?php
$i = 1;

$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', '101 '.fgets($handle));
fclose($handle);

arsort ($hList);
$newhList = array_slice($hList, 1, $hRead, true );

$handle = @fopen('output.txt', 'w');
fputs($handle, end($newhList)."\n");
fputs($handle, implode(' ',array_keys($newhList)));
fclose($handle);

<?php
/*
$time_start = microtime(true);
$mem_start = memory_get_usage();
*/
$i = 1;

//$handle = @fopen('c:/input.txt', 'r');
$handle = @fopen('input.txt', 'r');
list($hTotal, $hRead) = explode(' ', trim(fgets($handle)));
$hList = explode(' ', fgets($handle));
fclose($handle);

array_unshift($hList, 101);
arsort ($hList);
$hList = array_slice($hList, 1, $hRead, true );

//$handle = @fopen('c:/output.txt', 'w');
$handle = @fopen('output.txt', 'w');
fputs($handle, end($hList)."\n");
fputs($handle, implode(' ',array_keys($hList)));
fclose($handle);

/*
$mem_end = memory_get_usage();
$time_end = microtime(true);
echo "Time: ", ($time_end - $time_start)*1000, " MSec\n";
echo "Memory: ", ($mem_end - $mem_start)/1024, " Kb\n";
*/


Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.Petya can ask questions like: "Is the unknown number divisible by number y?".The game is played by the following rules: first Petya asks all the questions that interest him (also, he can ask no questions), and then Vasya responds to each question with a 'yes' or a 'no'. After receiving all the answers Petya should determine the number that Vasya thought of.Unfortunately, Petya is not familiar with the number theory. Help him find the minimum number of questions he should ask to make a guaranteed guess of Vasya's number, and the numbers yi, he should ask the questions about.

A single line contains number n (1 ≤ n ≤ 103).

Print the length of the sequence of questions k (0 ≤ k ≤ n), followed by k numbers — the questions yi (1 ≤ yi ≤ n). If there are several correct sequences of questions of the minimum length, you are allowed to print any of them.

NoteThe sequence from the answer to the first sample test is actually correct.If the unknown number is not divisible by one of the sequence numbers, it is equal to 1.If the unknown number is divisible by 4, it is 4.If the unknown number is divisible by 3, then the unknown number is 3.Otherwise, it is equal to 2. Therefore, the sequence of questions allows you to guess the unknown number. It can be shown that there is no correct sequence of questions of length 2 or shorter.

<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
$n = trim(fgets($file));
$pArray = array();
for ($i = 2; $i <= $n; $i++) {

    if (isPrime($i)) {
        $c = 0;
        $t = $n;
        while ($t>=$i) {
            $t /= $i;
            $c++;
        }
        if ($c>0) {
            $pArray[$i] = $c;
            $c = 0;
        }
    }
}
function isPrime($x)
{
    $k = floor(sqrt($x)) + 1;
    $result = true;
    for ($i = 2; $i < $k; $i++) {
        if ($x % $i ==0) {
            $result = false;
            break;
        }
    }
    return $result;
}

$r = array();
foreach ($pArray as $p => $q) {
    for ($i = 1; $i <= $q; $i++) {
        $r[] = pow($p, $i);
    }
}
echo count($r).PHP_EOL;
echo implode(" ", $r);


When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs ai minutes to read the i-th book.Valera decided to choose an arbitrary book with number i and read the books one by one, starting from this book. In other words, he will first read book number i, then book number i + 1, then book number i + 2 and so on. He continues the process until he either runs out of the free time or finishes reading the n-th book. Valera reads each book up to the end, that is, he doesn't start reading the book if he doesn't have enough free time to finish reading it. Print the maximum number of books Valera can read.

The first line contains two integers n and t (1 ≤ n ≤ 105; 1 ≤ t ≤ 109) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of n integers a1, a2, ..., an (1 ≤ ai ≤ 104), where number ai shows the number of minutes that the boy needs to read the i-th book.

Print a single integer — the maximum number of books Valera can read.

<?php
    $arr = explode(' ',  trim(fgets(STDIN)));
    $n = $arr[0];
    $t = $arr[1];
    $arr = explode(' ',  trim(fgets(STDIN)));
    $sum = $arr[0];
    $r = 0;
    $retInt = 0;
    for ($i=0; $i<$n; $i++)
    {
        $left = $i;
        while ($sum<=$t && $r<$n)
        {
            $r++;
            $sum+=$arr[$r];
        }
        $retInt = max($retInt, $r-$left);
        $sum -= $arr[$left];
    }
    echo $retInt;

?>

<?php
// Books

// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

// Solve
// Your code here

function test($n,$arr,$time){
    $max = 0;
    $temp = 0;
    $old = 0;
    $count = 0;
    for($i = 0; $i < $n;$i++) {
        $temp += $arr[$i];
        $count++;
        if ($temp > $time) {
            $max = $max > ($count -1) ? $max : ($count -1);
            $count -= 1;
            $old = $arr[$i - $count];
            $temp -=$old;
        }
        else if($i == $n-1){
            $max = $max > ($count) ? $max : ($count);
        }
    }
    echo $max;
}

test($n,$a,$t);

<?php
// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

$total = 0;
$count = 0;
$iStart = 0;

$cMax = 0;

for($i = $iStart; $i < $n; $i++){
    $tempTotal = $a[$i] + $total;
    if($tempTotal <= $t){
        $total = $tempTotal;
        $count++;
        continue;
    }

    if($cMax < $count){
        $cMax = $count;
    }

    $total-=$a[$iStart];
    $count--;
    $iStart++;
    $i--;
}

echo $cMax > $count ? $cMax : $count;

<?php
// Books

// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

// Solve
$left = 0;
$right = 0;
$sum = 0;
$maxBooks = 0;
while ($right < $n) {
    if ($sum + $a[$right] <= $t) {
        $sum += $a[$right];
        if ($right - $left + 1 > $maxBooks) {
            $maxBooks = $right - $left + 1;
        }
    } else {
        $sum -= $a[$left];
        $left++;
        $right--;
    }
    $right++;
}
echo ($maxBooks);

<?php
$in = 'php://stdin';

$input = fopen($in, "r");

[$n, $t] = explode(" ", trim(fgets($input)));

$a = explode(" ", trim(fgets($input)));

$s = 0;
$start = 0;
$maxLength = 0;

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

    if ($s > $t) {

        $temp = $i - $start;

        if ($temp > $maxLength) {
            $maxLength = $temp;
        }

        $s -= (int) $a[$start];
        $start++;
    }
}

if ($s <= $t) {
    $temp = $n - $start;

    if ($temp > $maxLength) {
        $maxLength = $temp;
    }
}

echo $maxLength < 0 ? 0 : $maxLength;

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$f = array();
for($x = 0; $x < $a; $x++)
{
    $e = 0;
    $d = $b;
    for($y = $x; $y < $a; $y++)
    {
        $d -= $c[$y];
        if($d <= 0)
        {
            break;
        }
        else
        {
            $e++;
        }
    }
    array_push($f, $e);
}
rsort($f);
print $f[0];
?>

<?php
    $arr = explode(' ',  trim(fgets(STDIN)));
    $n = $arr[0];
    $t = $arr[1];
    $arr = explode(' ',  trim(fgets(STDIN)));
    $sum = $arr[0];
    $r = 0;
    $retInt = 0;
    for ($i=0; $i<$n; $i++)
    {
        $left = $i;
        while ($sum<=$t && $r<$n)
        {
            $r++;
            $sum+=$arr[$r];
        }
        $retInt = max($retInt, $r-$left);
        $sum -= $arr[$left];
    }
    $retInt++;
    echo $retInt;

?>

<?php
// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

$total = 0;
$count = 0;
for($i = 0; $i < $n; $i++){
    $count++;
    $temp = $a[$i] + $total;
    if($temp > $t)
        break;
    $total = $temp;
}

echo $count;

<?php
// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

$total = 0;
for($i = 0; $i < $n; $i++){
    $temp = $a[$i] + $total;
    if($temp > $t)
        break;
    $total = $temp;
}

echo $total;

<?php
// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

$total = 0;
$count = 0;
for($i = 0; $i < $n; $i++){
    $count++;
    $temp = $a[$i] + $total;
    if($temp > $t)
        break;
    $total = $temp;
}

echo $total;

<?php
// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));

$total = 0;
for($i = 0; $i < $n; $i++){
    $temp = $a[$i] + $total;
    if($temp > $t)
        break;
}

echo $total;

<?php
// input
$in = 'php://stdin';
$input = fopen($in, "r");
$temp = explode(" ", trim(fgets($input)));
$n = $temp[0];
$t = $temp[1];
$a = explode(" ", trim(fgets($input)));
sort($a);

$total = 0;
$count = 0;
for($i = 0; $i < $n; $i++){
    $temp = $a[$i] + $total;
    if($temp > $t)
        break;
    $total = $temp;
    $count++;
}

echo $count;

<?php
// Books

// input
$in = 'php://stdin';
$input = fopen($in, "r");
$n = fgets($input);
$t = fgets($input);
$a = explode(" ", trim(fgets($input)));

// Solve
$left = 0;
$right = 0;
$sum = 0;
$maxBooks = 0;
while ($right < $n) {
    if ($sum + $a[$right] <= $t) {
        $sum += $a[$right];
        if ($right - $left + 1 > $maxBooks) {
            $maxBooks = $right - $left + 1;
        }
    } else {
        $sum -= $a[$left];
        $left++;
        $right--;
    }
    $right++;
}
echo ($maxBooks);


You are given a non-empty string $$$s=s_1s_2\dots s_n$$$, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string $$$s$$$ if there is an integer $$$j$$$ ($$$1 \le j \le n-2$$$), that $$$s_{j}s_{j+1}s_{j+2}=$$$"one" or $$$s_{j}s_{j+1}s_{j+2}=$$$"two".For example:  Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"),  Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time.For example, if the string looks like $$$s=$$$"onetwone", then if Polycarp selects two indices $$$3$$$ and $$$6$$$, then "onetwone" will be selected and the result is "ontwne".What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be?

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string $$$s$$$. Its length does not exceed $$$1.5\cdot10^5$$$. The string $$$s$$$ consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed $$$1.5\cdot10^6$$$.

Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain $$$r$$$ ($$$0 \le r \le |s|$$$) — the required minimum number of positions to be removed, where $$$|s|$$$ is the length of the given line. The second line of each answer should contain $$$r$$$ different integers — the indices themselves for removal in any order. Indices are numbered from left to right from $$$1$$$ to the length of the string. If $$$r=0$$$, then the second line can be skipped (or you can print empty). If there are several answers, print any of them.

10
onetwonetwooneooonetwooo
two
one
twooooo
ttttwo
ttwwoo
ooone
onnne
oneeeee
oneeeeeeetwooooo

NoteIn the first example, answers are:  "onetwone",  "testme" — Polycarp likes it, there is nothing to remove,  "oneoneone",  "twotwo". In the second example, answers are:   "onetwonetwooneooonetwooo",  "two",  "one",  "twooooo",  "ttttwo",  "ttwwoo" — Polycarp likes it, there is nothing to remove,  "ooone",  "onnne" — Polycarp likes it, there is nothing to remove,  "oneeeee",  "oneeeeeeetwooooo".


There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monster being eaten, and they stand in the queue next to each other. Monsters eat each other instantly. There are no monsters which are being eaten at the same moment. After the monster A eats the monster B, the weight of the monster A increases by the weight of the eaten monster B. In result of such eating the length of the queue decreases by one, all monsters after the eaten one step forward so that there is no empty places in the queue again. A monster can eat several monsters one after another. Initially there were n monsters in the queue, the i-th of which had weight ai.For example, if weights are [1, 2, 2, 2, 1, 2] (in order of queue, monsters are numbered from 1 to 6 from left to right) then some of the options are:  the first monster can't eat the second monster because a1 = 1 is not greater than a2 = 2;  the second monster can't eat the third monster because a2 = 2 is not greater than a3 = 2;  the second monster can't eat the fifth monster because they are not neighbors;  the second monster can eat the first monster, the queue will be transformed to [3, 2, 2, 1, 2]. After some time, someone said a good joke and all monsters recovered. At that moment there were k (k ≤ n) monsters in the queue, the j-th of which had weight bj. Both sequences (a and b) contain the weights of the monsters in the order from the first to the last.You are required to provide one of the possible orders of eating monsters which led to the current queue, or to determine that this could not happen. Assume that the doctor didn't make any appointments while monsters were eating each other.

The first line contains single integer n (1 ≤ n ≤ 500) — the number of monsters in the initial queue. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the initial weights of the monsters. The third line contains single integer k (1 ≤ k ≤ n) — the number of monsters in the queue after the joke.  The fourth line contains k integers b1, b2, ..., bk (1 ≤ bj ≤ 5·108) — the weights of the monsters after the joke.  Monsters are listed in the order from the beginning of the queue to the end.

In case if no actions could lead to the final queue, print "NO" (without quotes) in the only line.  Otherwise print "YES" (without quotes) in the first line. In the next n - k lines print actions in the chronological order. In each line print x — the index number of the monster in the current queue which eats and, separated by space, the symbol 'L' if the monster which stays the x-th in the queue eats the monster in front of him, or 'R' if the monster which stays the x-th in the queue eats the monster behind him. After each eating the queue is enumerated again.  When one monster eats another the queue decreases. If there are several answers, print any of them.

NoteIn the first example, initially there were n = 6 monsters, their weights are [1, 2, 2, 2, 1, 2] (in order of queue from the first monster to the last monster). The final queue should be [5, 5]. The following sequence of eatings leads to the final queue:  the second monster eats the monster to the left (i.e. the first monster), queue becomes [3, 2, 2, 1, 2];  the first monster (note, it was the second on the previous step) eats the monster to the right (i.e. the second monster), queue becomes [5, 2, 1, 2];  the fourth monster eats the mosnter to the left (i.e. the third monster), queue becomes [5, 2, 3];  the finally, the third monster eats the monster to the left (i.e. the second monster), queue becomes [5, 5]. Note that for each step the output contains numbers of the monsters in their current order in the queue.

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = explode(" ", trim(fgets(STDIN)));
if($a == $c)
{
     if($b == $d)
     {
          print "YES";
     }
     else
     {
          print "NO";
     }
}
else
{
     $e = array_sum($b);
     $f = array_sum($d);
     if($e != $f)
     {
          print "NO";
     }
     else
     {
          $g = array();
          for($x = 0; $x < $c; $x++)
          {
               $h = $d[$x];
               $i = array();
               for($y = 0; $y < count($b); $y++)
               {
                    array_push($i, $b[$y]);
                    $j = array_sum($i);
                    if($j == $h)
                    {
                         array_push($g, $i);
                         $b = array_slice($b, count($i));
                         break;
                    }
               }
          }
          if(count($g) != $c)
          {
               print "NO";
          }
          else
          {
               $k = 0;
               for($x = 0; $x < count($g); $x++)
               {
                    $l = array_unique($g[$x]);
                    if((count($l) == 1) && (count($g[$x]) != 1))
                    {
                         $k = 1;
                         break;
                    }
               }
               if($k == 1)
               {
                    print "NO";
               }
               else
               {
                    print "YES\n";
                    for($x = 0; $x < count($g); $x++)
                    {
                         $m = $g[$x];
                         if(count($m) == 1)
                         {
                              continue;
                         }
                         else
                         {
                              $n = max($m);
                              for($y = 0; $y < count($m); $y++)
                              {
                                   if(($m[$y - 1] < $n) && ($m[$y] == $n) && (($y - 1) >= 0))
                                   {
                                        while(TRUE)
                                        {
                                             if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))
                                             {
                                                  break;
                                             }
                                             elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " L\n";
                                                  $m[$y - 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                                  $y--;
                                             }
                                             elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " R\n";
                                                  $m[$y + 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                             }
                                        }
                                        break;
                                   }
                                   elseif(($m[$y] == $n) && ($m[$y + 1] < $n))
                                   {
                                        while(TRUE)
                                        {
                                             if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))
                                             {
                                                  break;
                                             }
                                             elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " L\n";
                                                  $m[$y - 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                                  $y--;
                                             }
                                             elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " R\n";
                                                  $m[$y + 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                             }
                                        }
                                        break;
                                   }
                              }

                         }
                    }
               }
          }
     }
}
?>

<?php

$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = explode(" ", trim(fgets(STDIN)));

if($a == $c)
{
  if($b == $d) print "YES";
  else print "NO";
}
elseif(array_sum($b) != array_sum($d))
{
  print "NO";
}
else
{
  $who = array();
  $k = 0;
  while(count($d) > 0){
    if($b[0] == $d[0]){
        $b = array_slice($b, 1);
        $d = array_slice($d, 1);
        $k++;
        continue;
    }
    for($i = 0; $i < count($b); $i++){
      if($i > 0 && $b[$i] > $b[$i-1]){
        if($i+1 < count($b) && $b[$i]+$b[$i-1] == $b[$i+1]) continue;
        $b[$i] += $b[$i-1];
        $who[] = ($i+1+$k).' L';
        unset($b[$i-1]);
        $b = array_values($b);
        break;
      }
      if($i+1 < count($b) && $b[$i] > $b[$i+1]){
        if($i+2 < count($b) && $b[$i]+$b[$i+1] == $b[$i+2]) continue;
        $b[$i] += $b[$i+1];
        $who[] = ($i+1+$k).' R';
        unset($b[$i+1]);
        $b = array_values($b);
        break;
      }
      if($i == count($b)-1) {
        break(2);
      }
    }
  }

  if($b == $d){
    print "YES\n";
    foreach($who as $w){
      print $w."\n";
    }
  }
  else print "NO";

}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = explode(" ", trim(fgets(STDIN)));
if($a == $c)
{
     if($b == $d)
     {
          print "YES";
     }
     else
     {
          print "NO";
     }
}
else
{
     $e = array_sum($b);
     $f = array_sum($d);
     if($e != $f)
     {
          print "NO";
     }
     else
     {
          $g = array();
          for($x = 0; $x < $c; $x++)
          {
               $h = $d[$x];
               $i = array();
               for($y = 0; $y < count($b); $y++)
               {
                    array_push($i, $b[$y]);
                    $j = array_sum($i);
                    if($j == $h)
                    {
                         array_push($g, $i);
                         $b = array_slice($b, count($i));
                         break;
                    }
               }
          }
          if(count($g) != $c)
          {
               print "NO";
          }
          else
          {
               $k = 0;
               for($x = 0; $x < count($g); $x++)
               {
                    $l = array_unique($g[$x]);
                    if(count($l) == 1)
                    {
                         $k = 1;
                         break;
                    }
               }
               if($k == 1)
               {
                    print "NO";
               }
               else
               {
                    print "YES\n";
                    for($x = 0; $x < count($g); $x++)
                    {
                         $m = $g[$x];
                         if(count($m) == 1)
                         {
                              continue;
                         }
                         else
                         {
                              $n = max($m);
                              for($y = 0; $y < count($m); $y++)
                              {
                                   if(($m[$y - 1] < $n) && ($m[$y] == $n) && (($y - 1) >= 0))
                                   {
                                        while(TRUE)
                                        {
                                             if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))
                                             {
                                                  break;
                                             }
                                             elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " L\n";
                                                  $m[$y - 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                                  $y--;
                                             }
                                             elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " R\n";
                                                  $m[$y + 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                             }
                                        }
                                        break;
                                   }
                                   elseif(($m[$y] == $n) && ($m[$y + 1] < $n))
                                   {
                                        while(TRUE)
                                        {
                                             if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))
                                             {
                                                  break;
                                             }
                                             elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " L\n";
                                                  $m[$y - 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                                  $y--;
                                             }
                                             elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))
                                             {
                                                  print ($y + $x + 1) . " R\n";
                                                  $m[$y + 1] += $m[$y];
                                                  $o = array_slice($m, 0, $y);
                                                  $p = array_slice($m, $y + 1);
                                                  $m = array_merge($o, $p);
                                             }
                                        }
                                        break;
                                   }
                              }

                         }
                    }
               }
          }
     }
}
?>

<?php

$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = explode(" ", trim(fgets(STDIN)));

if($a == $c)
{
  if($b == $d) print "YES";
  else print "NO";
}
elseif(array_sum($b) != array_sum($d))
{
  print "NO";
}
else
{
  $who = array();
  $k = 0;
  while(count($d) > 0){
    if($b[0] == $d[0]){
        $b = array_slice($b, 1);
        $d = array_slice($d, 1);
        $k++;
        continue;
    }
    for($i = 0; $i < count($b); $i++){
      if($i > 0 && $b[$i] > $b[$i-1]){
        $b[$i] += $b[$i-1];
        $who[] = ($i+1+$k).' L';
        //$b = array_slice($b, $i);
        unset($b[$i-1]);
        $b = array_values($b);
        break;
      }
      if($i+1 < count($b) && $b[$i] > $b[$i+1]){
        $b[$i] += $b[$i+1];
        $who[] = ($i+1+$k).' R';
        //$b = array_slice($b, $i+1);
        unset($b[$i+1]);
        $b = array_values($b);
        break;
      }
      if($i == count($b)-1) {
        foreach($b as $bv) print $bv." ";
        print "\n";
        foreach($d as $dv) print $dv." ";
        print "\n------\n";
        break(2);
      }
    }
    foreach($b as $bv) print $bv." ";
    print "\n";
    foreach($d as $dv) print $dv." ";
    print "\n------\n";
  }

  if($b == $d){
    print "YES\n";
    foreach($who as $w){
      print $w."\n";
    }
  }
  else print "NO";

}
?>

<?php

$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = explode(" ", trim(fgets(STDIN)));

if($a == $c)
{
  if($b == $d) print "YES";
  else print "NO";
}
elseif(array_sum($b) != array_sum($d))
{
  print "NO";
}
else
{
  $who = array();
  $k = 0;
  while(count($d) > 0){
    if($b[0] == $d[0]){
        $b = array_slice($b, 1);
        $d = array_slice($d, 1);
        $k++;
        continue;
    }
    for($i = 0; $i < count($b); $i++){
      if($i > 0 && $b[$i] > $b[$i-1]){
        $b[$i] += $b[$i-1];
        $who[] = ($i+1+$k).' L';
        //$b = array_slice($b, $i);
        unset($b[$i-1]);
        $b = array_values($b);
        break;
      }
      if($i+1 < count($b) && $b[$i] > $b[$i+1]){
        $b[$i] += $b[$i+1];
        $who[] = ($i+1+$k).' R';
        //$b = array_slice($b, $i+1);
        unset($b[$i+1]);
        $b = array_values($b);
        break;
      }
      if($i == count($b)-1) {
        break(2);
      }
    }
  }

  if($b == $d){
    print "YES\n";
    foreach($who as $w){
      print $w."\n";
    }
  }
  else print "NO";

}
?>

<?php

$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
$d = explode(" ", trim(fgets(STDIN)));

if($a == $c)
{
  if($b == $d) print "YES";
  else print "NO";
}
elseif(array_sum($b) != array_sum($d))
{
  print "NO";
}
else
{
  $who = array();
  $k = 0;
  while(count($d) > 0){
    if($b[0] == $d[0]){
        $b = array_slice($b, 1);
        $d = array_slice($d, 1);
        $k++;
    }
    for($i = 0; $i < count($b); $i++){
      if($i > 0 && $b[$i] > $b[$i-1]){
        $b[$i] += $b[$i-1];
        $who[] = ($i+1+$k).' L';
        //$b = array_slice($b, $i);
        unset($b[$i-1]);
        $b = array_values($b);
        break;
      }
      if($i+1 < count($b) && $b[$i] > $b[$i+1]){
        $b[$i] += $b[$i+1];
        $who[] = ($i+1+$k).' R';
        //$b = array_slice($b, $i+1);
        unset($b[$i+1]);
        $b = array_values($b);
        break;
      }
      if($i == count($b)-1) break(2);
    }
  }

  if(count($who) && $b == $d){
    print "YES\n";
    foreach($who as $w){
      print $w."\n";
    }
  }
  else print "NO";

}
?>


Polycarp has $$$n$$$ coins, the value of the $$$i$$$-th coin is $$$a_i$$$. It is guaranteed that all the values are integer powers of $$$2$$$ (i.e. $$$a_i = 2^d$$$ for some non-negative integer number $$$d$$$).Polycarp wants to know answers on $$$q$$$ queries. The $$$j$$$-th query is described as integer number $$$b_j$$$. The answer to the query is the minimum number of coins that is necessary to obtain the value $$$b_j$$$ using some subset of coins (Polycarp can use only coins he has). If Polycarp can't obtain the value $$$b_j$$$, the answer to the $$$j$$$-th query is -1.The queries are independent (the answer on the query doesn't affect Polycarp's coins).

The first line of the input contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n, q \le 2 \cdot 10^5$$$) — the number of coins and the number of queries. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ — values of coins ($$$1 \le a_i \le 2 \cdot 10^9$$$). It is guaranteed that all $$$a_i$$$ are integer powers of $$$2$$$ (i.e. $$$a_i = 2^d$$$ for some non-negative integer number $$$d$$$). The next $$$q$$$ lines contain one integer each. The $$$j$$$-th line contains one integer $$$b_j$$$ — the value of the $$$j$$$-th query ($$$1 \le b_j \le 10^9$$$).

Print $$$q$$$ integers $$$ans_j$$$. The $$$j$$$-th integer must be equal to the answer on the $$$j$$$-th query. If Polycarp can't obtain the value $$$b_j$$$ the answer to the $$$j$$$-th query is -1.


Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,...,   10" will be corrected to "1, 2, 3, ..., 10".In this task you are given a string s, which is composed by a concatination of terms, each of which may be:   a positive integer of an arbitrary length (leading zeroes are not allowed),  a "comma" symbol (","),  a "space" symbol (" "),  "three dots" ("...", that is, exactly three points written one after another, also known as suspension points). Polycarp wants to add and remove spaces in the string s to ensure the following:   each comma is followed by exactly one space (if the comma is the last character in the string, this rule does not apply to it),  each "three dots" term is preceded by exactly one space (if the dots are at the beginning of the string, this rule does not apply to the term),  if two consecutive numbers were separated by spaces only (one or more), then exactly one of them should be left,  there should not be other spaces. Automate Polycarp's work and write a program that will process the given string s.

The input data contains a single string s. Its length is from 1 to 255 characters. The string s does not begin and end with a space. Its content matches the description given above.

Print the string s after it is processed. Your program's output should be exactly the same as the expected answer. It is permissible to end output line with a line-break character, and without it.

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$string = file_get_contents("php://stdin");

$patterns = array(
    "/(\s+),/",
    "/,/",
    "/(\.\.\.)(\s+)/",
    "/(\.\.\.)/",
    "/(\s+)/"
);

$replacements = array (
    ",",
    ", ",
    "...",
    " ...",
    " "
);

echo trim(preg_replace($patterns, $replacements, $string));
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
$input = file_get_contents("php://stdin");

$len = strlen ($input);
$result = '';
$prew = '';
for($i = 0; $i < $len; $i++){
    if($input[$i] == '.'){
        if($prew){
            $result .= $prew . '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        $prew = '';
    } else if($input[$i] == ','){
        if($prew == ', '){
            $result .= $prew;
        }
        $prew = ', ';
    } else if($input[$i] == ' '){
        if(!$prew){
            $prew = ' ';
        }
    } else {
       if($prew == ', ' || $result[strlen ($result) - 1] != '.'){
           $result .= $prew;
       }
       $result .= $input[$i];
       $prew = '';
    }
}
echo trim($result);
?>

<?php

	$string = trim(file_get_contents('php://stdin'));

	$string = preg_replace("/\s*,\s*/", ', ', $string);
	$string = preg_replace("/\s*\.\.\.\s*/", ' ...', $string);
	$string = preg_replace("/\s+/", ' ', $string);

	echo trim($string, ' ');

<?php
$rx = array(
    '/\\.\\.\\./s' => ' ...',
    '/(\\s*,\\s*)/s' => ', ',
    '/\\s\\s/s' => ' ',
);
$str = fgets(STDIN);
$str = preg_replace(array_keys($rx), array_values($rx), $str);
fwrite(STDOUT, trim($str));

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$input = file_get_contents("php://stdin");
$input = str_replace(" ", "", $input);

$len = strlen ($input);
$result = '';
for($i = 0; $i < $len; $i++){
    //echo $input[$i];
    if($input[$i] == '.'){
        //echo ' ���������';
        if($input[$i - 1] == ','){
            $result .= '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    } else if($input[$i] == ','){
        $result .= ', ';
    } else {
        $result .= $input[$i];
        //echo ' �����';
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    }

    //echo "\n";
}

echo $result;
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
$input = file_get_contents("php://stdin");

$len = strlen ($input);
$result = '';
$prew = '';
for($i = 0; $i < $len; $i++){
    if($input[$i] == '.'){
        if($prew){
            $result .= $prew . '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        $prew = '';
    } else if($input[$i] == ','){
        if($prew == ', '){
            $result .= $prew;
        }
        $prew = ', ';
    } else if($input[$i] == ' '){
        if(!$prew){
            $prew = ' ';
        }
    } else {
       if($prew && $result[strlen ($result) - 1] != '.'){
           $result .= $prew;
       }
       $result .= $input[$i];
       $prew = '';
    }
}
echo trim($result);
?>

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$input = file_get_contents("php://stdin");
$input = str_replace(" ", "", $input);

$len = strlen ($input);
$result = '';
for($i = 0; $i < $len; $i++){
    //echo $input[$i];
    if($input[$i] == '.'){
        //echo ' ���������';
        if($i < 1 || $input[$i - 1] == ','){
            $result .= '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    } else if($input[$i] == ','){
        $result .= ', ';
    } else {
        $result .= $input[$i];
        //echo ' �����';
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    }

    //echo "\n";
}

echo $result;
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$input = file_get_contents("php://stdin");
$input = str_replace(" ", "", $input);

$len = strlen ($input);
$result = '';
for($i = 0; $i < $len; $i++){
    //echo $input[$i];
    if($input[$i] == '.'){
        //echo ' ���������';
        if($i < 1 || $input[$i - 1] == ','){
            $result .= '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    } else if($input[$i] == ','){
        if(isset($input[$i + 1])){
			$result .= ', ';
		} else {
			$result .= ',';
		}
    } else {
        $result .= $input[$i];
        if($input[$i + 1] == ','){
            $i++;
            $result .= ', ';
        }
    }

    //echo "\n";
}

echo trim($result);
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$input = file_get_contents("php://stdin");
$input = str_replace(" ", "", $input);

$len = strlen ($input);
$result = '';
for($i = 0; $i < $len; $i++){
    //echo $input[$i];
    if($input[$i] == '.'){
        //echo ' ���������';
        if($i > 1 && $input[$i - 1] == ','){
            $result .= '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    } else if($input[$i] == ','){
        $result .= ', ';
    } else {
        $result .= $input[$i];
        //echo ' �����';
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    }

    //echo "\n";
}

echo $result;
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
$input = file_get_contents("php://stdin");

$len = strlen ($input);
$result = '';
$prew = '';
for($i = 0; $i < $len; $i++){
    if($input[$i] == '.'){
        if($prew){
            $result .= $prew . '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        $prew = '';
    } else if($input[$i] == ','){
        if($prew == ', '){
            $result .= $prew;
        }
        $prew = ', ';
    } else if($input[$i] == ' '){
        if(!$prew){
            $prew = ' ';
        }
    } else {
       $result .= $prew . $input[$i];
       $prew = '';
    }
}
echo trim($result);
?>

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$input = file_get_contents("php://stdin");
$input = str_replace(" ", "", $input);

$len = strlen ($input);
$result = '';
for($i = 0; $i < $len; $i++){
    //echo $input[$i];
    if($input[$i] == '.'){
        //echo ' ���������';
        if($input[$i - 1] == ','){
            $result .= '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        if($i > 1 && $input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    } else if($input[$i] == ','){
        $result .= ', ';
    } else {
        $result .= $input[$i];
        //echo ' �����';
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    }

    //echo "\n";
}

echo $result;
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$string = file_get_contents("php://stdin");

$patterns[0] = "/(\s+),/";
$patterns[1] = "/,/";
$patterns[2] = "/(\.\.\.)/";
$patterns[3] = "/(\s+)/";

$replacements[3] = ",";
$replacements[2] = ", ";
$replacements[1] = " ...";
$replacements[0] = " ";

echo trim(preg_replace($patterns, $replacements, $string));
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>

<?
/*
$start_time = microtime();
$start_array = explode(" ",$start_time);
$time['start'] = $start_array[1] + $start_array[0];*/

$input = file_get_contents("php://stdin");
$input = str_replace(" ", "", $input);

$len = strlen ($input);
$result = '';
for($i = 0; $i < $len; $i++){
    //echo $input[$i];
    if($input[$i] == '.'){
        //echo ' ���������';
        if($i < 1 || $input[$i - 1] == ','){
            $result .= '...';
        } else {
            $result .= ' ...';
        }
        $i += 2;
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    } else if($input[$i] == ','){
        if(isset($input[$i + 1])){
			$result .= ', ';
		} else {
			$result .= ',';
		}
    } else {
        $result .= $input[$i];
        //echo ' �����';
        if($input[$i + 1] == ','){
            //echo ' ���';
            $i++;
            $result .= ', ';
        }
    }

    //echo "\n";
}

echo $result;
/*
$end_time = microtime();
$end_array = explode(" ",$end_time);
$time['gener_class'] = $end_array[1] + $end_array[0];
echo $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/
?>


Polycarp loves not only to take pictures, but also to show his photos to friends. On his personal website he has recently installed a widget that can display n photos with the scroll option. At each moment of time the widget displays exactly one photograph with the option showing the previous/next one. From the first photo, you can switch to the second one or to the n-th one, from the second photo you can switch to the third one or to the first one, etc. Thus, navigation is performed in a cycle.Polycarp's collection consists of m photo albums, the i-th album contains ai photos. Polycarp wants to choose n photos and put them on a new widget. To make watching the photos interesting to the visitors, he is going to post pictures so that no two photos from one album were neighboring (each photo will have exactly two neighbors, the first photo's neighbors are the second and the n-th one).Help Polycarp compile a photo gallery. Select n photos from his collection and put them in such order that no two photos from one album went one after the other.

The first line contains two integers n and m (3 ≤ n ≤ 1000, 1 ≤ m ≤ 40), where n is the number of photos on the widget, and m is the number of albums. The second line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000), where ai is the number of photos in the i-th album.

Print the single number -1 if there is no solution. Otherwise, print n numbers t1, t2, ..., tn, where ti represents the number of the album of the i-th picture in the widget. The albums are numbered from 1 in the order of their appearance in the input. If there are several solutions, print any of them.


The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a parallelepiped k × n × m, that is, it has k layers (the first layer is the upper one), each of which is a rectangle n × m with empty squares ('.') and obstacles ('#'). The water can only be present in the empty squares. The tap is positioned above the square (x, y) of the first layer, it is guaranteed that this square is empty. Every minute a cubical unit of water falls into the plate. Find out in how many minutes the Serial Guy should unglue himself from the soap opera and turn the water off for it not to overfill the plate. That is, you should find the moment of time when the plate is absolutely full and is going to be overfilled in the next moment.Note: the water fills all the area within reach (see sample 4). Water flows in each of the 6 directions, through faces of 1 × 1 × 1 cubes.

The first line contains three numbers k, n, m (1 ≤ k, n, m ≤ 10) which are the sizes of the plate. Then follow k rectangles consisting of n lines each containing m characters '.' or '#', which represents the "layers" of the plate in the order from the top to the bottom. The rectangles are separated by empty lines (see the samples). The last line contains x and y (1 ≤ x ≤ n, 1 ≤ y ≤ m) which are the tap's coordinates. x is the number of the line and y is the number of the column. Lines of each layer are numbered from left to right by the integers from 1 to n, columns of each layer are numbered from top to bottom by the integers from 1 to m.

The answer should contain a single number, showing in how many minutes the plate will be filled.


You are given a permutation $$$p=[p_1, p_2, \ldots, p_n]$$$ of integers from $$$1$$$ to $$$n$$$. Let's call the number $$$m$$$ ($$$1 \le m \le n$$$) beautiful, if there exists two indices $$$l, r$$$ ($$$1 \le l \le r \le n$$$), such that the numbers $$$[p_l, p_{l+1}, \ldots, p_r]$$$ is a permutation of numbers $$$1, 2, \ldots, m$$$.For example, let $$$p = [4, 5, 1, 3, 2, 6]$$$. In this case, the numbers $$$1, 3, 5, 6$$$ are beautiful and $$$2, 4$$$ are not. It is because:  if $$$l = 3$$$ and $$$r = 3$$$ we will have a permutation $$$[1]$$$ for $$$m = 1$$$;  if $$$l = 3$$$ and $$$r = 5$$$ we will have a permutation $$$[1, 3, 2]$$$ for $$$m = 3$$$;  if $$$l = 1$$$ and $$$r = 5$$$ we will have a permutation $$$[4, 5, 1, 3, 2]$$$ for $$$m = 5$$$;  if $$$l = 1$$$ and $$$r = 6$$$ we will have a permutation $$$[4, 5, 1, 3, 2, 6]$$$ for $$$m = 6$$$;  it is impossible to take some $$$l$$$ and $$$r$$$, such that $$$[p_l, p_{l+1}, \ldots, p_r]$$$ is a permutation of numbers $$$1, 2, \ldots, m$$$ for $$$m = 2$$$ and for $$$m = 4$$$. You are given a permutation $$$p=[p_1, p_2, \ldots, p_n]$$$. For all $$$m$$$ ($$$1 \le m \le n$$$) determine if it is a beautiful number or not.

The first line contains the only integer $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases in the input. The next lines contain the description of test cases. The first line of a test case contains a number $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the given permutation $$$p$$$. The next line contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are different) — the given permutation $$$p$$$. It is guaranteed, that the sum of $$$n$$$ from all test cases in the input doesn't exceed $$$2 \cdot 10^5$$$.

Print $$$t$$$ lines — the answers to test cases in the order they are given in the input.  The answer to a test case is the string of length $$$n$$$, there the $$$i$$$-th character is equal to $$$1$$$ if $$$i$$$ is a beautiful number and is equal to $$$0$$$ if $$$i$$$ is not a beautiful number.

NoteThe first test case is described in the problem statement.In the second test case all numbers from $$$1$$$ to $$$5$$$ are beautiful:  if $$$l = 3$$$ and $$$r = 3$$$ we will have a permutation $$$[1]$$$ for $$$m = 1$$$;  if $$$l = 3$$$ and $$$r = 4$$$ we will have a permutation $$$[1, 2]$$$ for $$$m = 2$$$;  if $$$l = 2$$$ and $$$r = 4$$$ we will have a permutation $$$[3, 1, 2]$$$ for $$$m = 3$$$;  if $$$l = 2$$$ and $$$r = 5$$$ we will have a permutation $$$[3, 1, 2, 4]$$$ for $$$m = 4$$$;  if $$$l = 1$$$ and $$$r = 5$$$ we will have a permutation $$$[5, 3, 1, 2, 4]$$$ for $$$m = 5$$$.