<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$g = 0;
$h = array();
for($x = 1; $x <= $a; $x++)
{
    $c = trim(fgets(STDIN));
    $d = str_split($c);
    array_unshift($d, " ");
    unset($d[0]);
    $e = array_search("G", $d);
    $f = array_search("S", $d);
    array_push($h, $f - $e);
    if($e > $f)
    {
        $g = 1;
        break;
    }
}
if($g == 1)
{
    print "-1";
}
else
{
    $i = array_unique($h);
    print count($i);
}
?>

<?php

list($lines, $chars) = explode(" ", trim(fgets(STDIN)));

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

	$row = array_flip($row);
	if($row['G'] < $row['S'])
		$ms[] = $row['G'] - $row['S'];
	else {
		echo "-1" . PHP_EOL;
		exit;
	}
}

$ms = array_unique($ms);
echo sizeof($ms) . PHP_EOL;

<?php

list($lines, $chars) = explode(" ", trim(fgets(STDIN)));

$m = $chars + 1;
for($i = 0; $i < $lines; $i++)
{
	$row = str_split(trim(fgets(STDIN)));

	$gPos = -1;
	$cPos = -1;
	for($j = 0; $j < ($chars / 2); $j++)
	{
		$gPos = ($row[$j] == 'G') ? $j : $gPos;
		$cPos = ($row[($chars - $j - 1)] == 'S') ? $chars - $j - 1 : $cPos;
	}

	$m = ($gPos < $cPos) ? min($m, $cPos - $gPos) : $m;
}

$m = ($m > $chars) ? -1 : $m;

echo $m . PHP_EOL;


<?php
function calc($size, $repo) {
    $i = 0; $j = count($repo) - 1;
    $bucket = 0;
    while ($i < $j) {
        if ($repo[$j] + $repo[$i] <= $size) {
            $i ++;
        }
        $bucket ++;
        $j --;
    }
    if ($i == $j) $bucket ++;
    return $bucket;
}

fscanf(STDIN, "%d %d", $n, $k);
$temp = fgets(STDIN);
$repo = explode(" ", $temp);
$len = count($repo);
$left = $repo[$len - 1];
$right = 2 * $left;
while($left < $right) {
    $mid = intval(($left + $right) / 2);
    if (calc($mid, $repo) <= $k) {
        $right = $mid;
    } else {
        $left = $mid + 1;
    }
}
echo intval($left), "\n";
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = array_sum($c) / $b;
if($d < max($c))
{
    print max($c);
}
else
{
    print ceil($d);
}
?>


<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
$n = trim(fgets($file));
$aArray = explode(" ", trim(fgets($file)));
$vArray = array();
$t = 0;
$result = 0;
while ($t<$n) {
    for ($i = 0; $i < $n; $i++) {
        if ($aArray[$i]>$t || isset($vArray[$i])) {
            continue;
        }
        $vArray[$i] = 1;
        $t++;
    }
    $result++;
    if ($t == $n) {
        break;
    }
    for ($i = $n-1; $i >= 0; $i--) {
        if ($aArray[$i]>$t || isset($vArray[$i])) {
            continue;
        }
        $vArray[$i] = 1;
        $t++;
    }
    $result++;
}
echo $result-1 . PHP_EOL;


<?php

for(;;){
  $input = fgets(STDIN,4096);
  if($input === false) break;

  list($n, $x, $y) = explode(" ",$input);
  $y = trim($y);

  if( bccomp($n,$y) === 1 ){
    echo "-1\n";
    continue;
  }

  $mul = bcadd(bcadd($y, "-$n", 0), "1", 0);
  $sum = bcadd($n, "-1", 0);
  $sum = bcadd($sum, bcmul($mul, $mul, 0), 0);

  if( bccomp($sum,$x) === -1){
    echo "-1\n";
    continue;
  }

  echo $mul."\n";
  for($i=1;bccomp("$i",$n,0)===-1;$i++) echo "1\n";
}

?>


<?php
list($n, $m) = explode(" ", fgets(STDIN));
$arr = explode(" ", fgets(STDIN));
$marr = array();
foreach($arr as $k){
    $marr[(int)$k] = isset($marr[(int)$k]) ? $marr[(int)$k] + 1 : 1;
}
$marr = array_values($marr);
$sum = 0;
foreach($marr as $mid => $mc){
    $sum+= array_sum(array_values(array_slice($marr, $mid + 1))) * $mc;
}
fprintf(STDOUT, '%d', $sum);
?>

<?php
list($n, $m) = explode(" ", fgets(STDIN));
$arr = explode(" ", fgets(STDIN));
$marr = array();
foreach($arr as $k){
    $marr[(int)$k] = isset($marr[(int)$k]) ? $marr[(int)$k] + 1 : 1;
}
$sum = 0;
foreach($marr as $mid => $mc){
    $sum+= ($n - $mc);
}
fprintf(STDOUT, '%d', $sum);
?>


    <?php
    $str=trim(fgets(STDIN));
    $word="heidi";
    $cnt=0;
    for ($i=0; $i <strlen($str) ; $i++)
       {
       	   if($str[$i]==$word[$cnt])
               $cnt++;

       }
       echo $cnt==5?"YES":"NO";

<?php
$str=trim(fgets(STDIN));
$word="heidi";
$cnt=0;
for ($i=0; $i <strlen($str) ; $i++)
   {
   	    echo "cnt=$cnt\n";
   	   if($str[$i]==$word[$cnt])
   	   {

           $cnt++;
        }

   }
   echo $cnt==5?"YES":"NO";

<?php
$str=trim(fgets(STDIN));
$word="heidi";
for ($i=0; $i <strlen($word) ; $i++)
{
	 for ($j=0; $j <strlen($str) ; $j++)
	 {
	 	if($i==4)
	 	{
			 	if($word[$i]==$str[$j])
			 	{
			 		$store[$i]=$j;
			 		//break;
			 	}
	    }
		else
	    {
	    	if($word[$i]==$str[$j])
		     {
					$store[$i]=$j;
					break;
		     }
	    }

	 }
}
$flag=0;
for ($i=0; $i <count($store)-1 ; $i++)
{
	if($store[$i]>$store[$i+1])
	    {
	     $flag=1;
	     echo "NO";
	    }
}
if($flag==0)
echo "YES";


<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$diff = 0;
$res = array();
$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$diff += $q_same*$q1;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		$resx = array();
		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			if ($resx[$x1.' '.$x2]) {
				$res[] = $x2.' '.$x1;
				$resx[$x2.' '.$x1] = 1;
			} else {
				$res[] = $x1.' '.$x2;
				$resx[$x1.' '.$x2] = 1;
			}

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

//--------------------
echo implode(L,$res);

<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$diff = 0;
$res = array();
$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		$resx = array();
		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			if ($resx[$x1.' '.$x2] > $resx[$x2.' '.$x1]) {
				$res[] = $x2.' '.$x1;
				$resx[$x2.' '.$x1]++;
			} else {
				$res[] = $x1.' '.$x2;
				$resx[$x1.' '.$x2]++;
			}

			$diff++;

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) && $q1 > $q2 ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

echo implode(L,$res);

<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$diff = 0;
$res = array();
$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$diff += $q_same*$q1;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			$res[] = $x1.' '.$x2;

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

//--------------------
echo implode(L,$res);

<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$diff = 0;
$res = array();
$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		$resx = array();
		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			if ($resx[$x1.' '.$x2]) {
				$res[] = $x2.' '.$x1;
				$resx[$x2.' '.$x1] = 1;
			} else {
				$res[] = $x1.' '.$x2;
				$resx[$x1.' '.$x2] = 1;
			}

			$diff++;

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) && $q1 > $q2 ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

//--------------------
echo implode(L,$res);

<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$diff = 0;
$res = array();
$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		$resx = array();
		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			if ($resx[$x1.' '.$x2] > $resx[$x2.' '.$x1]) {
				$res[] = $x2.' '.$x1;
				$resx[$x2.' '.$x1]++;
			} else {
				$res[] = $x1.' '.$x2;
				$resx[$x1.' '.$x2]++;
			}

			$diff++;

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) && $q1 > $q2 ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

echo implode(L,$result);

<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$res = array();

$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$diff += $q_same*$q1;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			$res[] = $x1.' '.$x2;

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

//--------------------
echo implode(L,$res);

<? $f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

list($kids,$colors) = explode(' ',$f[0]);

if ($kids == 1) {
	echo '0'.L.'1 1';
	exit;
}

$data = explode(' ', $f[1]);

$distr = array();

for($i=1;$i<=$colors;$i++) {
	$distr[$i] = sizeof(array_keys($data,$i));
}

arsort($distr);

$res = array();

$is = true;

while (($q1 = reset($distr)) && $is) {
	$is = false;

	$c1 = key($distr);

	$same = array_keys($distr,$q1);

	$q_same = sizeof($same);

	if ($q_same > 1) {
		$is = true;

		$diff += $q_same*$q1;

		$xame = array();

		foreach ($same as $u) {
			$xame[$u] = $q1 * 2;
			unset($distr[$u]);
		}

		while($qx1 = reset($xame)) {
			$x1 = key($xame);
			$qx2 = next($xame);
			$x2 = key($xame);

			$res[] = $x1.' '.$x2;

			if ($qx1==1) {
				unset($xame[$x1]);
			} else {
				$xame[$x1]--;
			}

			if ($qx2==1) {
				unset($xame[$x2]);
			} else {
				$xame[$x2]--;
			}

			if ($xame) {
				arsort($xame);
			}
		}

	} else {
		while ( $q1 && ($q2 = next($distr)) ) {
			$is = true;
			$c2 = key($distr);

			$max = $q2;
			$q1 -= $q2;
			$q2 = 0;

			for ($z=0;$z<$max;$z++) {
				$res[] = $c1.' '.$c2;
				$res[] = $c2.' '.$c1;
				$diff += 2;
			}

			if ($q2)
				$distr[$c2] = $q2;
			else
				unset($distr[$c2]);
		}

		if ($q1)
			$distr[$c1] = $q1;
		else
			unset($distr[$c1]);

	}

	arsort($distr);
}

for ($z=0;$z<$q1;$z++) {
	$res[] = $c1.' '.$c1;
	$res[] = $c1.' '.$c1;
}

array_unshift($res, $diff);

//--------------------
echo implode(L,$res);


<?php

$t = intval(readline());

$i = 0;

$final_result = [];

while($i++ < $t) {

    $wheelCount = intval(readline());

    $currentState = explode(' ', readline());

    foreach($currentState as $key => $value) {
        $opCountAndOps = explode(' ', readline());
        $opCount = $opCountAndOps[0];
        $ops = $opCountAndOps[1];

        foreach(str_split($ops) as $op) {
            if($op === "D") {
                $currentState[$key] = (intval($currentState[$key]) + 1) % 10;
            } else {
                $currentState[$key] = (intval($currentState[$key]) - 1) % 10;

                if($currentState[$key] < 0) {
                    $currentState[$key] = 9;
                }
            }

        }
    }

    array_push($final_result, $currentState);
}

foreach($final_result as $result) {
    foreach($result as $value) {
        echo $value . ' ';
    }

    echo PHP_EOL;
}

<?php

$cnt = readline();
$res = array();
$k = 0;
while ($cnt--) {
    $s = readline();
    $ar = explode(' ', readline());

    foreach ($ar as $t) {
        list($x, $moves) = explode(' ', readline());
        $moves = str_split($moves);

        $i = 0;
        foreach ($moves as $move) {
            if ($move == 'U') {
                $i--;
            } else {
                $i++;
            }
        }

        $res[$k][] = $t + $i;
    }
    $k++;
}

//var_dump($res);
//exit();
foreach ($res as $ss) {
    foreach ($ss as $s) {
        echo parse($s) . " ";
    }
    echo "\n";
}

function parse($i)
{
    if ($i > 9) {
        $i = $i - 10;
    } elseif ($i < 0) {
        $i = $i + 10;
    }

    return $i;
}

<?php

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

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

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

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

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

function printLine($arg) {

	print_r($arg) ;
	print_r("\n") ;

}

function sol($st) {
	$sum = 0 ;
	$arr = str_split($st) ;
	foreach($arr as $e) {
		if($e === "D") $sum += 1 ;
		else $sum -= 1 ;
	}
	return $sum ;
}

$t = readInt() ;

while($t--) {
	$n = readInt() ;
	$fin = readIntArray() ;
	$oprs = [] ;
	$ans = [] ;
	for($i=0;$i<$n;$i++) {
		[$r, $z] = explode(" ",read()) ;
		$oprs[] = sol($z) ;
	}
	// printLine($oprs);
	for($i=0;$i<$n;$i++) {
		$temp = ($oprs[$i] + $fin[$i]) % 10 ;
		if($temp < 0) {
			$temp = 10 + $temp ;
		}
		$ans[] = $temp ;
	}
	printLine(implode(" ", $ans));

}

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

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
//3
//3
//9 3 1
//3 DDD
//4 UDUU
//2 DU
function solve()
{
    $n = IO::get();
    $a = IO::getArray();

    $ans = [];
    for($i=0; $i<$n; $i++) {
        list($t, $s) = IO::getArray();
        $temp = (int)$a[$i];
        for($j=0; $j<$t; $j++) {
           if($s[$j] == 'U') {
               if($temp == 0) {
                   $temp = 9;
               } else {
                   $temp--;
               }
           } else {
               if($temp == 9) {
                   $temp = 0;
               } else {
                   $temp++;
               }
           }
        }

        $ans[] =  $temp;
    }
    IO::prArray($ans);

}

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

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


<?php
function mod_math($k, $m) { return ($k - $m * floor($k/$m)); }
function convertSymbol($str,&$last) {
    if($last != 0) {
        $nlast = array('0','0','0','0','0','0','0','0');
        $lbin = decbin($last);
        $n=0;
        for($i=(strlen($lbin)-1);$i>=0;$i--) {
            $nlast[$n++] = $lbin[$i];
        }
        $last = bindec(implode('', $nlast));
    }
    $dec = ord($str);
    $bin = decbin($dec);
    $nbin = array('0','0','0','0','0','0','0','0');
    $n = 0;
    for($i=(strlen($bin)-1);$i>=0;$i--) {
        $nbin[$n++] = $bin[$i];
    }
    $nbin = implode('', $nbin);
    $ndec = bindec($nbin);
    $s = $last-$ndec;
    $res = mod_math($s,256);
    $last = $dec;
    echo( $res ."\n" );
}

$in = trim(fgets(STDIN));
$last = 0;
for($i=0;$i<strlen($in);$i++) {
    convertSymbol($in[$i],$last);
}

<?
$str=trim(fgets(STDIN));

function reverses(&$str){
    $ss="";
    $size=strlen($str);
    for($i=$size-1; $i>=0; $i--){
        $ss.=$str[$i];
    }
    for($i=$size+1; $i<=8; $i++)
        $ss.="0";
    return $ss;
}
$tmp=0;
for($i=0, $s=strlen($str); $i<$s; $i++){
    $char=ord($str[$i]);
    $bin=decbin($char);
    $rev_bin = reverses($bin);
    $dec=bindec($rev_bin);
    echo (($tmp-$dec)%256+256)%256,"\n";
    $tmp=$dec;
}
?>


<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = trim(fgets(STDIN), "\n\r");
		$l = substr($s, 0, 5);
		$r = substr($s, -5);
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}

<?php

fscanf(STDIN, "%d", $n);
for ($i = 0; $i < $n; $i++)
{
	$str = trim(fgets(STDIN), "\r\n");
	$f = endsWith($str, 'lala.');
	$r = startsWith($str, 'miao.');

	if ($f xor $r)
	{
		if ($f)
			echo "Freda's" . PHP_EOL;
		elseif ($r)
			echo "Rainbow's" . PHP_EOL;
	} else
		echo "OMG>.< I don't know!" . PHP_EOL;
}

function startsWith($haystack, $needle)
{
	return !strncmp($haystack, $needle, strlen($needle));
}

function endsWith($haystack, $needle)
{
	$length = strlen($needle);
	if ($length == 0)
	{
		return true;
	}

	return (substr($haystack, -$length) === $needle);
}

<?php
$a = trim(fgets(STDIN));
$b = array();
for($x = 0; $x < $a; $x++)
{
     $c = fgets(STDIN);
     for($y = 0; $y < strlen($c); $y++)
     {
          if($c[$y] == " ")
          {
               $c[$y] = "!";
          }
     }
     $b[$x] = trim($c);
}
for($x = 0; $x < $a; $x++)
{
     $d = $b[$x];
     $e = substr($d, 0, 5);
     $f = substr($d, strlen($d) - 5);
     if(($e == "miao.") && ($f == "lala."))
     {
          print "OMG>.< I don't know!\n";
     }
     elseif($e == "miao.")
     {
          print "Rainbow's\n";
     }
     elseif($f == "lala.")
     {
          print "Freda's\n";
     }
     else
     {
          print "OMG>.< I don't know!\n";
     }
}
?>

<?php
$t = trim(fgets(STDIN));
while($t--){
	$s = trim(fgets(STDIN), "\n\r");
	$l = substr($s, 0, 5);
	$r = substr($s, -5);
	if($l == 'miao.' && $r == 'lala.')
		echo 'OMG>.< I don\'t know!';
	elseif($l == 'miao.')
		echo 'Rainbow\'s';
	elseif($r == 'lala.')
		echo 'Freda\'s';
	else
		echo 'OMG>.< I don\'t know!';
	echo "\n";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = "  " . trim(fgets(STDIN));
    $c = strpos($b, "miao.");
    $d = strpos($b, "lala.", strlen($b) - 5);
    if(($c == 2) && ($d != (strlen($b) - 5)))
    {
        print "Rainbow's\n";
    }
    elseif(($c != 2) && ($d == (strlen($b) - 5)))
    {
        print "Freda's\n";
    }
    else
    {
        print "OMG>.< I don't know!\n";
    }
}
$b = "  " . trim(fgets(STDIN));
$c = strpos($b, "miao.");
$d = strpos($b, "lala.", strlen($b) - 5);
if(($c == 2) && ($d != (strlen($b) - 5)))
{
    print "Rainbow's";
}
elseif(($c != 2) && ($d == (strlen($b) - 5)))
{
    print "Freda's";
}
else
{
    print "OMG>.< I don't know!";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = "  " . trim(fgets(STDIN));
    $c = strpos($b, "miao.");
    $d = strpos($b, "lala.", strlen($b) - 5);
    if($b == "  miaolala.")
    {
        print "OMG>.< I don't know!\n";
    }
    elseif(($c == 2) && ($d != (strlen($b) - 5)))
    {
        print "Rainbow's\n";
    }
    elseif(($c != 2) && ($d == (strlen($b) - 5)))
    {
        print "Freda's\n";
    }
    else
    {
        print "OMG>.< I don't know!\n";
    }
}
$b = "  " . trim(fgets(STDIN));
$c = strpos($b, "miao.");
$d = strpos($b, "lala.", strlen($b) - 5);
if(($c == 2) && ($d != (strlen($b) - 5)))
{
    print "Rainbow's";
}
elseif(($c != 2) && ($d == (strlen($b) - 5)))
{
    print "Freda's";
}
else
{
    print "OMG>.< I don't know!";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if(($c == "lala.") && ($d == "miao"))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if($b == "miaolala.")
    {
        print "Rainbow's" . "\n";
    }
    elseif(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if($b == "miaolala.")
{
    print "Rainbow's";
}
elseif(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, 0, 5);
    $d = substr($b, -5);
    if(($c == "miao.") && ($d == "lala."))
    {
        print "OMG>.< I don't know!\n";
    }
    elseif(($c == "miao.") && ($d != "lala."))
    {
        print "Rainbow's\n";
    }
    elseif(($c != "miao.") && ($d == "lala."))
    {
        print "Freda's\n";
    }
    elseif($b == "miaolala.")
    {
        print "OMG>.< I don't know!\n";
    }
    else
    {
        print "OMG>.< I don't know!\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, 0, 5);
$d = substr($b, -5);
if(($c == "miao.") && ($d == "lala."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "miao.") && ($d != "lala."))
{
    print "Rainbow's";
}
elseif(($c != "miao.") && ($d == "lala."))
{
    print "Freda's";
}
elseif($b == "miaolala.")
{
    print "OMG>.< I don't know!";
}
else
{
    print "OMG>.< I don't know!";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if($b == "miaolala.")
    {
        print "Rainbow's" . "\n";
    }
    elseif(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b == trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if($b = "miaolala.")
{
    print "Rainbow's";
}
elseif(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = fgets(STDIN);
    $c = substr($b, 0, 5);
    $d = substr($b, -5);
    if(($c == "miao.") && ($d == "lala."))
    {
        print "OMG>.< I don't know!\n";
    }
    elseif(($c == "miao.") && ($d != "lala."))
    {
        print "Rainbow's\n";
    }
    elseif(($c != "miao.") && ($d == "lala."))
    {
        print "Freda's\n";
    }
    else
    {
        print "OMG>.< I don't know!\n";
    }
}
$b = fgets(STDIN);
$c = substr($b, 0, 5);
$d = substr($b, -5);
if(($c == "miao.") && ($d == "lala."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "miao.") && ($d != "lala."))
{
    print "Rainbow's";
}
elseif(($c != "miao.") && ($d == "lala."))
{
    print "Freda's";
}
else
{
    print "OMG>.< I don't know!";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if($b = "miaolala.")
    {
        print "Rainbow's" . "\n";
    }
    elseif(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if($b = "miaolala.")
{
    print "Rainbow's" . "\n";
}
elseif(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!" . "\n";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!" . "\n";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's" . "\n";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's" . "\n";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, 0, 5);
    $d = substr($b, -5);
    if(($c == "miao.") && ($d == "lala."))
    {
        print "OMG>.< I don't know!\n";
    }
    elseif(($c == "miao.") && ($d != "lala."))
    {
        print "Rainbow's\n";
    }
    elseif(($c != "miao.") && ($d == "lala."))
    {
        print "Freda's\n";
    }
    else
    {
        print "OMG>.< I don't know!\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, 0, 5);
$d = substr($b, -5);
if(($c == "miao.") && ($d == "lala."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "miao.") && ($d != "lala."))
{
    print "Rainbow's";
}
elseif(($c != "miao.") && ($d == "lala."))
{
    print "Freda's";
}
else
{
    print "OMG>.< I don't know!";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if($b == "miaolala.")
    {
        print "Rainbow's" . "\n";
    }
    elseif(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b == trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if($b = "miaolala.")
{
    print "Rainbow's" . "\n";
}
elseif(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!" . "\n";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!" . "\n";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's" . "\n";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's" . "\n";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = fgets(STDIN);
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b = fgets(STDIN);
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = substr($b, strlen($b) - 5);
    $d = substr($b, 0, 5);
    if($b == "miaolala.")
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d == "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c != "lala.") && ($d != "miao."))
    {
        print "OMG>.< I don't know!" . "\n";
    }
    elseif(($c == "lala.") && ($d != "miao."))
    {
        print "Freda's" . "\n";
    }
    elseif(($c != "lala.") && ($d == "miao."))
    {
        print "Rainbow's" . "\n";
    }
}
$b = trim(fgets(STDIN));
$c = substr($b, strlen($b) - 5);
$d = substr($b, 0, 5);
if($b == "miaolala.")
{
    print "OMG>.< I don't know!" . "\n";
}
elseif(($c == "lala.") && ($d == "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c != "lala.") && ($d != "miao."))
{
    print "OMG>.< I don't know!";
}
elseif(($c == "lala.") && ($d != "miao."))
{
    print "Freda's";
}
elseif(($c != "lala.") && ($d == "miao."))
{
    print "Rainbow's";
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x < $a; $x++)
{
    $b = "  " . fgets(STDIN);
    $c = strpos($b, "miao.");
    $d = strpos($b, "lala.", strlen($b) - 5);
    if(($c == 2) && ($d != (strlen($b) - 5)))
    {
        print "Rainbow's\n";
    }
    elseif(($c != 2) && ($d == (strlen($b) - 5)))
    {
        print "Freda's\n";
    }
    else
    {
        print "OMG>.< I don't know!\n";
    }
}
$b = "  " . fgets(STDIN);
$c = strpos($b, "miao.");
$d = strpos($b, "lala.", strlen($b) - 5);
if(($c == 2) && ($d != (strlen($b) - 5)))
{
    print "Rainbow's";
}
elseif(($c != 2) && ($d == (strlen($b) - 5)))
{
    print "Freda's";
}
else
{
    print "OMG>.< I don't know!";
}
?>

<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = trim(fgets(STDIN), "\n");
		$l = substr($s, 0, 5);
		$r = substr($s, -5);
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}

<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = fgets(STDIN);
		$l = substr($s, 0, 5);
		$r = substr($s, -5);
		echo $r;
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}

<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = trim(fgets(STDIN), "\n", "\0");
		$l = substr($s, 0, 5);
		$r = substr($s, -5);
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}

<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = trim(fgets(STDIN));
		$l = substr($s, 0, 5);
		$r = substr($s, -5);
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}

<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = (fgets(STDIN));
		$l = substr($s, 0, 5);
		$r = substr($s, -7);
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}

<?php
	$n = fgets(STDIN);

	for($i = 0; $i < $n; ++$i)
	{
		$s = trim(fgets(STDIN), "\n\n");
		$l = substr($s, 0, 5);
		$r = substr($s, -5);
		if($l == 'miao.' && $r == 'lala.')
			echo 'OMG>.< I don\'t know!';
		elseif($l == 'miao.')
			echo 'Rainbow\'s';
		elseif($r == 'lala.')
			echo 'Freda\'s';
		else
			echo 'OMG>.< I don\'t know!';
		echo "\n";
	}


<?php
# 1175A
$stdin = STDIN;
$t = (int)trim(fgets($stdin));
while ($t > 0) {
    [$n, $k] = explode(' ', trim(fgets($stdin)));
    $i = '0';
    while ($n !== '0') {
        $mod = bcmod($n, $k);
        if ($k > 1 && ($mod === '0')) {
            $n = bcdiv($n, $k);
            $i = bcadd($i, '1');
        } else {
            $n = bcadd($n, '-' . $mod);
            $i = bcadd($i, $mod);
        }
    }
    echo $i . PHP_EOL;
    $t--;
}

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     $d = 0;
     while(TRUE)
     {
          if(bcmod($b, $c) == 0)
          {
               $b = bcdiv($b, $c);
               $d = bcadd($d, 1);
          }
          else
          {
               $d = bcadd($d, bcmod($b, $c));
               $b = bcsub($b, bcmod($b, $c));
          }
          if($b == 0)
          {
               print $d . "\n";
               break;
          }
     }
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     $d = 0;
     while(TRUE)
     {
          if(bcmod($b, $c) == 0)
          {
               $b = bcdiv($b, $c);
               $d++;
          }
          else
          {
               $d += bcmod($b, $c);
               $b = bcsub($b, bcmod($b, $c));
          }
          if($b == 0)
          {
               printf("%.0f", $d);
               print "\n";
               break;
          }
     }
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     $d = 0;
     while(TRUE)
     {
          if(bcmod($b, $c) == 0)
          {
               $b = bcdiv($b, $c);
               $d = bcadd($d, 1);
          }
          else
          {
               $d = bcadd($d, bcmod($b, $c));
               $b = bcsub($b, bcmod($b, $c));
          }
          if($b == 0)
          {
               printf("%.0f", $d);
               print "\n";
               break;
          }
     }
}
?>

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


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

while($t > 0)
{
    $n = fgets($stdin);

    if ($n % 4 == 0)
        echo("YES\n");
    else
        echo("NO\n");

    $t -= 1;
}

fclose($stdin);
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = trim(fgets(STDIN));
     if($b % 4 == 0)
     {
          print "YES\n";
     }
     else
     {
          print "NO\n";
     }
}
?>

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

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

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

        echo $n&3 ? "NO\n" : "YES\n" ;
    }
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = trim(fgets(STDIN));
     if($b % 2 == 0)
     {
          print "YES\n";
     }
     else
     {
          print "NO\n";
     }
}
?>


<?php
$num = fgets(STDIN);
$string_array = fgets(STDIN);
$loc_extr = 0;
$array = explode(' ', $string_array);
for ($i=1; $i < ($num-1); $i++) {
	if (intval($array[$i-1])>intval($array[$i]) ) {
	    if (intval($array[$i+1])>intval($array[$i]))
	        $loc_extr++;
	}
	else if (intval($array[$i-1])<intval($array[$i])) {
	    if (intval($array[$i+1])<intval($array[$i]))
	        $loc_extr++;
	}
}
echo $loc_extr;
?>

<?php
$num = fgets(STDIN);
$string_array = fgets(STDIN);
$loc_extr = 0;
$array = explode(' ', $string_array);
for ($i=1; $i < ($num-1); $i++) {
	if (($array[$i-1]>=$array[$i] && $array[$i+1]>$array[$i])||($array[$i-1]>$array[$i] && $array[$i+1]>=$array[$i])) {
	    $loc_extr++;
	}
	else if (($array[$i-1]<=$array[$i] && $array[$i+1]<$array[$i])||($array[$i-1]<$array[$i] && $array[$i+1]<=$array[$i])) {
	    $loc_extr++;
	}
}
echo $loc_extr;
?>

<?php
$num = fgets(STDIN);
$string_array = fgets(STDIN);
$loc_extr = 0;
$array = explode(' ', $string_array);
for ($i=1; $i < ($num-1); $i++) {
	if ($array[$i-1]>$array[$i] ) {
	    if ($array[$i+1]>$array[$i])
	        $loc_extr++;
	}
	else if ($array[$i-1]<$array[$i]) {
	    if ($array[$i+1]<$array[$i])
	        $loc_extr++;
	}
}
echo $loc_extr;
?>

<?php
$num = fgets(STDIN);
$string_array = fgets(STDIN);
$loc_extr = 0;
$array = explode(' ', $string_array);
for ($i=1; $i < ($num-1); $i++) {
	if ($array[$i-1]>$array[$i]) {
	    if ($array[$i+1]>$array[i])
	        $loc_extr++;
	}
	else if ($array[$i-1]<$array[$i]) {
	    if ($array[$i+1]<$array[$i])
	        $loc_extr++;
	}
}
echo $loc_extr;
?>

<?php
$num = fgets(STDIN);
$string_array = fgets(STDIN);
$loc_extr = 0;
$array = explode(' ', $string_array);
for ($i=1; $i < $num; $i++) {
	if ($array[$i-1]>$array[$i]) {
	    if ($array[$i+1]>$array[i])
	        $loc_extr++;
	}
	else if ($array[$i-1]<$array[$i]) {
	    if ($array[$i+1]<$array[$i])
	        $loc_extr++;
	}
}
echo $loc_extr;
?>

<?php
$num = fgets(STDIN);
$string_array = fgets(STDIN);
$loc_extr = 0;
$array = explode(' ', $string_array);
for ($i=1; $i < ($num-1); $i++) {
	if (($array[$i-1]>=$array[$i] && $array[$i+1]>$array[i])||($array[$i-1]>$array[$i] && $array[$i+1]>=$array[i])) {
	    $loc_extr++;
	}
	else if (($array[$i-1]>=$array[$i] && $array[$i+1]>$array[i])||($array[$i-1]>$array[$i] && $array[$i+1]>=$array[i])) {
	    $loc_extr++;
	}
}
echo $loc_extr;
?>


<?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 133 - Problem C
function func($in) {
	$n = $in[0];
	$m = $in[1];
	$k = $in[2];

	$ans = "";
	if ($k == 1) {
		if (($n == 2) && ($m == 2)) {
			return "4\n1 2 3 4";
		}
		if ($n >= $m + 2) {
			return "2\n1 " . $n;
		} else {
			return "3\n1 " . $n . " " . (2 * $n - 1);
		}
	}
	if ($n >= $m + 1) {
		$ans = (2 * $k) . "\n" . str_repeat("1 ", $k) . $n . str_repeat(" " . ($n + 1), $k - 1);
	} else {
		$ans = (2 * $k + 1) . "\n" . str_repeat("1 ", $k) . $n . str_repeat(" " . ($n + 1), $k - 1) . " " . (2 * $n);
	}
	return $ans;
}

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

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

<?php
list($n, $m, $k) = explode(' ', fgets(STDIN));
$a = array();
$size = $n + $m + 1;

if ($k == 1){
  for($i=1;$i<$size;$i+=$n-1)
    $a[] = $i;
  echo count($a), PHP_EOL;
  foreach($a as $i)
    echo $i, ' ';
}else{
  $prev = 1;
  while($prev < $size-1){
    if ($prev == 1){
      for($i=0;$i<$k;$i++) $a[] = $prev;
    }else{
      $a[] = $prev;
      $prev++;
      for($i=0;$i<$k-1;$i++) $a[] = $prev;
    }
    $prev+=$n-1;
  }

  if ($prev < $size) $a[] = $size-1;
  echo count($a), PHP_EOL;
  foreach($a as $i)
    echo $i, ' ';
}
echo PHP_EOL;

<?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 133 - Problem C
function func($in) {
	$n = $in[0];
	$m = $in[1];
	$k = $in[2];

	$ans = "";
	if ($k == 1) {
		if ($n >= $m + 2) {
			return "2\n1 " . $n;
		} else {
			return "3\n1 " . $n . " " . (2 * $n - 1);
		}
	}
	if ($n >= $m + 1) {
		$ans = (2 * $k) . "\n" . str_repeat("1 ", $k) . $n . str_repeat(" " . ($n + 1), $k - 1);
	} else {
		$ans = (2 * $k + 1) . "\n" . str_repeat("1 ", $k) . $n . str_repeat(" " . ($n + 1), $k - 1) . " " . (2 * $n);
	}
	return $ans;
}

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


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

list($n,$k) = explode(" ",trim(fgets($f)));
$s = str_split(trim(fgets($f)));

$a = array();
foreach($s as $x){
    $a[$x]+=1;
}
arsort($a);

$a = array_values($a);

$i = 0;
$sum = 0;
while($k>0){
    $m = $a[$i];

    if ($m<=$k){
        $sum = $sum + ($m*$m);
        $k = $k-$m;
    } else {
        $sum = $sum + ($k*$k);
        $k = 0;
    }
    $i++;
}

echo ($sum);

<?php

function FindCards($n,$k,$cards){

    $repeatChar = count_chars($cards,1);
    rsort($repeatChar);
    $count      = 0;
    $total      = 0;
    //print_r($repeatChar);
    foreach ($repeatChar as $key => $value) {
        $check = 0;
        if($count>$k)
            break;
        $check = $count + $value;

        if($check <= $k){
            $count += $value;
            $total +=$value*$value;

        }
        else{
            $left   = $k-$count;
            $count += $left;
            $total += $left*$left;
        }
    }

    echo $total;
}

$nk       = trim(fgets(STDIN));
$cards    = trim(fgets(STDIN));
$nk       = explode(" ", $nk);
$n        = $nk[0];
$k        = $nk[1];
FindCards($n,$k,$cards);

<?php

function FindCards($n,$k,$cards){

    $repeatChar = count_chars($cards,1);
    $count      = 0;
    $total      = 0;

    foreach ($repeatChar as $key => $value) {
        $check = 0;
        if($count>$k)
            break;
        $check = $count + $value;

        if($check <= $k){
            $count += $value;
            $total +=$value*$value;

        }

    }
    if($count<$k){
        $total += $k-$count;
    }
    echo $total;
}

$nk       = trim(fgets(STDIN));
$cards    = trim(fgets(STDIN));
$nk       = explode(" ", $nk);
$n        = $nk[0];
$k        = $nk[1];
FindCards($n,$k,$cards);

<?php

function FindCards($n,$k,$cards){

    $repeatChar = count_chars($cards,1);
    $count      = 0;
    $total      = 0;

    foreach ($repeatChar as $key => $value) {
        $check = 0;
        if($count>$k)
            break;
        $check = $count + $value;

        if($check <= $k){
            $count += $value;
            $total +=$value*$value;

        }
        else{
            $left   = $k-$count;
            $count += $left;
            $total += $left*$left;
        }
    }

    echo $total;
}

$nk       = trim(fgets(STDIN));
$cards    = trim(fgets(STDIN));
$nk       = explode(" ", $nk);
$n        = $nk[0];
$k        = $nk[1];
FindCards($n,$k,$cards);


<?php

define('DEBUG', false);

$stdIn = STDIN;
$stdOut = STDOUT;

if (DEBUG === true) {
    $stdIn = fopen('1391B.txt', 'r');
}

fscanf($stdIn, "%d\n", $nTestCase);

for ($testcase = 0; $testcase < $nTestCase; $testcase++) {
    fscanf($stdIn, "%d %d\n", $nRows, $nColumn);
    $str = [];
    $total = 0;

    for($row = 0; $row < $nRows; $row++) {
        $str[$row] = fgets($stdIn);
        $total += $str[$row][$nColumn-1] == 'D' || $str[$row][$nColumn-1] ==  'C' ? 0 : 1;

        if ($row == $nRows-1) {
            for ($col=0; $col < $nColumn; $col++) {
                $total += $str[$row][$col] == 'R' || $str[$row][$col] ==  'C' ? 0 : 1;
            }
        }
    }

    fprintf($stdOut, "%d\n", $total);
}
if (DEBUG === true) {
    $stdIn = fclose($stdIn);
}

<?php

define('DEBUG', false);

$stdIn = STDIN;
$stdOut = STDOUT;

if (DEBUG === true) {
    $stdIn = fopen('1391B.txt', 'r');
}

fscanf($stdIn, "%d\n", $nTestCase);

for ($testcase = 0; $testcase < $nTestCase; $testcase++) {
    fscanf($stdIn, "%d %d\n", $nRows, $nColumn);
    $str = [];
    $total = 0;

    for($row = 0; $row < $nRows; $row++) {
        $str[$row] = fgets($stdIn);
        $total += $str[$row][$nColumn-1] == 'D' || $str[$row][$nColumn-1] ==  'C' ? 0 : 1;

        if ($row == $nRows-1) {
            $perfectLastRow = array_fill(0, $nColumn-1, 'R');
            $perfectLastRow[$nColumn-1] = 'C';
            $perfectLastRow[$nColumn] = "\n";
            $total += count(array_diff(array_filter(str_split($str[$row])), $perfectLastRow));
        }
    }

    fprintf($stdOut, "%d\n", $total);
}
if (DEBUG === true) {
    $stdIn = fclose($stdIn);
}


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

 $loop = true;
 $t = $loop ? IO::getInt() : 1;

 while($t--) {
      solve();
 }

 function solve()
 {
      $ans = 'NO';
      $n = IO::getInt();
      $a = IO::getArray();

      $sum = array_sum($a);
      for($i=0; $i < $n; $i++) {
           if($a[$i] == ($sum - $a[$i]) / ($n-1)) {
                $ans = 'YES';
                break;
           }
      }
      IO::pr($ans);
 }

//   $ans = 0;
//        list($n, $x) = IO::getArray();

//        $len = strlen($x);
//        if($len > $n) {
//           $ans = -1;
//        } elseif($len < $n) {
//           $maxV = maxVal($x);
//           if($maxV == '1') {
//              $ans = -1;
//           } else {
//                $ind = [0, 1];

//                foreach(str_split($x) as $ch) {
//                     IO::pr($ch);
//                }

//           }

//        }

//        IO::pr($ans);

//  function temp($x, $$aTemp, $ans) {
//       while($n > strlen($x)) {
//         IO::pr($ans . " " . strlen($x) . " " . $x . " " . $maxV);
//         if($maxV < 9 && in_array('3', str_split($x))) {
//              $maxV = 3;
//         }
//           $x = bcmul($x, $maxV);
//           $ans++;
//           $maxV = IO::getMaxValue(maxVal($x) , $maxV);
//      }
//      return $ans;
//  }
function maxVal($x) {
     $max = $x[0];
          for($i=1; $i<strlen($x); $i++) {
              $max = IO::getMaxValue($max, $x[$i]);
              if($max == 9) {
                   break;
              }
          }
          return $max;
}

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

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

 class Algor {
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

     public static function fabicon($n, $a) {
         if($n <= 1) {
             return $a[$n];
         }
         for($i=2; $i<=$n; $i++) {
             $a[$i] = $a[$i-1] + $a[$i-2];
         }

         return $a[$n];
     }

     function getRotate($a, $s, $e, $ind) {
         $ar = [];
         for ($i= $s; $i<=$e; $i++) {
             $ar[$i] = $a[$i];
             $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
             // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
             $a[$i] = $j < $i ? $ar[$j] : $a[$j];
         }
         return $a;
     }

}

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

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

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

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

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

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

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

        return $aResult;

    }
}

class SolveArchive
{

}

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

for ($test = 0; $test < $t; $test++) {
    $n = trim(fgets(STDIN));
    $a = explode(' ', trim(fgets(STDIN)));
    $s = 0;

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

    $res = false;

    for ($i = 0; $i < $n; $i++) {
        if ($s - $a[$i] == $a[$i] * ($n - 1)) {
            $res = true;
            break;
        }
    }

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

<?php
    $t = trim(fgets(STDIN));
    for ($t1=1; $t1<=$t; $t1++) {
        $n = trim(fgets(STDIN));
        $a = explode(' ', trim(fgets(STDIN)));

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

        $b = false;
        for ($i=0; $i<$n; $i++) {
            $iS = bcsub($iSum, $a[$i]);
            if (bcmod($iS, $n-1) == 0) {
                $iSred = bcdiv($iS, $n-1);
                if ($iSred == $a[$i]) {
                    $b = true;
                    echo 'YES' . PHP_EOL;
                    break;
                }
            }
        }
        if (!$b) {
            echo 'NO' . PHP_EOL;
        }
    }

<?php
$t = trim(fgets(STDIN));
$ans = [];
for($i=0; $i<$t; $i++) {
    $n = trim(fgets(STDIN));
    $input = explode(' ', trim(fgets(STDIN)));

    $su = 0;
    $found = false;
    for($k=0; $k<$n; $k++) {
        $sum = 0;
        for($j=0; $j<$n; $j++) {
            if($su !== $j) {
                $sum += $input[$j];
            }
        }
        if(($sum / ($n - 1)) == $input[$su]) {
            $ans[]= 'yes';
            $found = true;
            $su++;
            break;
        }
        $su++;
    }
    if($found === false) {
        $ans[] = 'no';
    }
}

foreach ($ans as $v) {
    echo "$v\n";
}

<?php
$t = trim(fgets(STDIN));
$res = [];
for ($test = 0; $test < $t; $test++) {
    $n = trim(fgets(STDIN));
    $a = explode(' ', trim(fgets(STDIN)));
    $s = 0;

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

    $ok = false;

    for ($i = 0; $i < $n; $i++) {
        if ($s - $a[$i] == $a[$i] * ($n - 1)) {
            $ok = true;
            break;
        }
    }

    if ($ok) $res[] = 'Yes';
    else $res[] = 'No';
}

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