<?php
function solve($n,$arr,$brr) {
    $ult = [] ;
    for($i=0;$i<$n;$i++) {
        if($brr[$i] !== 0) {
            $ult[] = $arr[$i] - $brr[$i] ;
        }
    }
    $test = array_unique($ult) ;
    if(count($test) === 0) {
        return "YES" ;
    }
    else if(count($test) === 1) {
        if($test[0] > -1) {
            for($i=0;$i<$n;$i++) {
                if (!($arr[$i] - $test[0] <= $brr[$i])) {
                    return "NO" ;
                }
            }
            return  "YES" ;
        }
        return "NO" ;
    }
    return "NO";
}

$t = (int) fgets(STDIN);
$ans = [] ;
while($t--) {
    $n = (int) fgets(STDIN);
    $arr = array_map("intval", explode(" ",fgets(STDIN)));
    $brr = array_map("intval", explode(" ",fgets(STDIN)));

    $ans[] = solve($n,$arr,$brr);
}
print_r(implode("\n",$ans)) ;

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

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

 function solve()
 {
     $n = IO::getInt();
     $a = IO::getArray();
     $b = IO::getArray();
     $ans = 'YES';
     $temp = 0;
     $tt = false ;
     $zeroMax = 0;
     for($i=0; $i<$n; $i++) {
          if($b[$i] > $a[$i]) {
               $ans = 'NO';
               break;
          }
          if($b[$i] == 0) {
               $zeroMax = IO::getMaxValue($zeroMax, $a[$i]);
          } else {
             if(!$tt) {
                 $temp =  $a[$i] - $b[$i];
                 $tt = true;
             } else {
               if(($a[$i] - $b[$i]) != $temp) {
                    $ans = 'NO';
                    break;
               }
             }
          }
     }
     $ans = $tt && $temp < $zeroMax ? 'NO' : $ans;
      IO::pr($ans);

 }

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

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

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

        return $d == $n;
    }

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

         return $a[$n];
     }

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

}

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

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

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

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

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

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

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

        return $aResult;

    }
}

class SolveArchive
{

}

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

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

 function solve()
 {
     $n = IO::getInt();
     $a = IO::getArray();
     $b = IO::getArray();
     $ans = 'YES';
     $temp = $a[0] - $b[0];
     $tt = $b[0] ;
     for($i=0; $i<$n; $i++) {
          if($b[$i] > $a[$i]) {
               $ans = 'NO';
               break;
          }
          if($b[$i] > 0 && $tt > 0 && ($a[$i] - $b[$i]) != $temp) {
               $ans = 'NO';
               break;
          } else {
               if($b[$i] > 0) {
                   $tt = 1;
                   $temp = $a[$i] - $b[$i];
               }

          }
          if($b[$i] == 0 && ($tt > 0 && ($a[$i] - $b[$i]) > $temp)) {
               $ans = 'NO';
               break;
          }
     }
      IO::pr($ans);

 }

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

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

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

        return $d == $n;
    }

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

         return $a[$n];
     }

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

}

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

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

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

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

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

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

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

        return $aResult;

    }
}

class SolveArchive
{

}

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

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

 function solve()
 {
     $n = IO::getInt();
     $a = IO::getArray();
     $b = IO::getArray();
     $ans = 'YES';
     $temp = $a[0] - $b[0];
     $tt = $b[0] ;
     for($i=0; $i<$n; $i++) {
          if($b[$i] > $a[$i]) {
               $ans = 'NO';
               break;
          }
          if($b[$i] > 0 && $tt > 0 && ($a[$i] - $b[$i]) != $temp) {
               $ans = 'NO';
               break;
          } else {
               if($i > 0) {
                   $tt = 1;
                   $temp = $a[$i] - $b[$i];
               }

          }
          if($b[$i] == 0 && (($a[$i] - $b[$i]) > $temp)) {
               $ans = 'NO';
               break;
          }
     }
      IO::pr($ans);

 }

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

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

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

        return $d == $n;
    }

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

         return $a[$n];
     }

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

}

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

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

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

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

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

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

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

        return $aResult;

    }
}

class SolveArchive
{

}

<?php
function solve($n,$arr,$brr) {
    $ult = [] ;
    for($i=0;$i<$n;$i++) {
        if($brr[$i] !== 0) {
            $ult[] = $arr[$i] - $brr[$i] ;
        }
    }
    $test = array_unique($ult) ;
    if(count($test) === 0) {
        return "YES" ;
    }
    else if(count($test) === 1) {
        if($test[0] > -1) {
            return  "YES" ;
        }
        return "NO" ;
    }
    return "NO";
}

$t = (int) fgets(STDIN);
$ans = [] ;
while($t--) {
    $n = (int) fgets(STDIN);
    $arr = array_map("intval", explode(" ",fgets(STDIN)));
    $brr = array_map("intval", explode(" ",fgets(STDIN)));

    $ans[] = solve($n,$arr,$brr);
}
print_r(implode("\n",$ans)) ;


<?php
#1190b
$start = microtime(1);
$n = trim(fgets(STDIN));
$n_ = $n - 1;
$arr = explode(' ', trim(fgets(STDIN)));
sort($arr);
$amount = 0;
$pairs = 0;
for ($i = 0; $i < $n; $i++) {
    if ($i < $n_ && $arr[$i] == $arr[$i + 1]) {
        $pairs++;
        if ($i && $arr[$i - 1] == ($arr[$i] - 1)) {
            $pairs++;
        }
        if ($arr[$i] == 0) {
            $pairs = 2;
        }
    }
    $amount += $arr[$i] - $i;
}
if ($pairs > 1 || !($amount & 1))  {
    echo 'cslnb';
} else {
    echo 'sjfnb';
}

<?php
#1190b
$start = microtime(1);
$n = trim(fgets(STDIN));
$n_ = $n - 1;
$arr = explode(' ', trim(fgets(STDIN)));
sort($arr);
$amount = 0;
$pairs = 0;
for ($i = 0; $i < $n; $i++) {
    if ($i < $n_ && $arr[$i] === $arr[$i + 1]) {
        $pairs++;
        if ($i && (int)$arr[$i - 1] === ($arr[$i] - 1)) {
            $pairs++;
        }
        if ($arr[$i] === '0') {
            $pairs = 2;
        }
    }
    $amount += $arr[$i] - $i;
}
if ($pairs > 1 || !($amount & 1))  {
    echo 'cslnb';
} else {
    echo 'sjfnb';
}

<?php
#1190b
$start = microtime(1);
$n = trim(fgets(STDIN)) - 1;
$arr = explode(' ', trim(fgets(STDIN)));
sort($arr);
$amount = 0;
$pairs = 0;
for ($i = 0; $i < $n; $i++) {
    if ($arr[$i] == $arr[$i + 1]) {
        $pairs++;
        if ($i && $arr[$i - 1] == ($arr[$i] - 1)) {
            $pairs++;
        }
        if ($arr[$i] == 0) {
            $pairs = 2;
        }
    }
    $amount += $arr[$i] - $i;
}
if ($pairs > 1 || !($amount & 1))  {
    echo 'cslnb';
} else {
    echo 'sjfnb';
}


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

   $t = IO::getInt();
//   $point = ord('a') + ord('b') ;

   for($q=0; $q <$t; $q++) {
       $ans = 0;
       list($a, $b, $c) = IO::getArray();
       $z = $c;
       $y = bcadd($z, $b);
       $x = bcadd($y, $a);

       IO::pr([$x, $y, $z]);
//      xmody=a = 1, x = yt1+a  17%15 = 2
// ymodz=b = 3,   y = zt2 + b   15%8 = 7
// zmodx=c => x = z = xt3 + c.
   }

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

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
         if(is_array($s)) {
             echo implode( ' ', $s), PHP_EOL;
         } else {
             echo $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($n = 1; $n <= $t; $n++) {
        list($a,$b, $c) = explode(' ', trim(fgets(STDIN)));

        $z = $c;
        $y = bcadd(bcmul(bcsub($b, 1), $z), $b);
        $x = bcadd($a , $y);

        echo "$x $y $z" . PHP_EOL;
    }
?>

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

   $t = IO::getInt();
//   $point = ord('a') + ord('b') ;

   for($q=0; $q <$t; $q++) {
       $ans = 0;
       list($a, $b, $c) = IO::getArray();
       $x = $a;
       $z = bcadd($x, $c);
       $y = bcadd($z, $b);

       IO::pr([$x, $y, $z]);
//      xmody=a,
// ymodz=b,
// zmodx=c.
   }

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

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
         if(is_array($s)) {
             echo implode( ' ', $s), PHP_EOL;
         } else {
             echo $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
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";
define("INTMAXVALUE",     2147483646);

   $t = IO::getInt();
//   $point = ord('a') + ord('b') ;

   for($q=0; $q <$t; $q++) {
       $ans = 0;
       list($a, $b, $c) = IO::getArray();
       $x = $a;
       $z = bcadd($x + $c);
       $y = bcadd($z + $b);

       IO::pr([$x, $y, $z]);
//      xmody=a,
// ymodz=b,
// zmodx=c.
   }

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

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
         if(is_array($s)) {
             echo implode( ' ', $s), PHP_EOL;
         } else {
             echo $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
/*  $input = "4 1
1 3";*/
    $input = trim(file_get_contents("php://stdin"));
    $split_text = explode("\n",$input);
    $n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
    $number_of_not_match = $n_m[1]-'0';
    array_splice($split_text, 0, 1);
    $list_of_unmatch=array();
    $array_length = sizeof($split_text);
    for($c=0; $c<$array_length; $c++){
        $unmatch = explode(" ",$split_text[$c]);
        array_push($list_of_unmatch, trim($unmatch[0]), trim($unmatch[1]));
    }

    $list_of_unmatch = array_unique($list_of_unmatch);
    $list_of_unmatch = array_values($list_of_unmatch);
    $initial=1;
    $unmatch_length = sizeof($list_of_unmatch);
    $n = $n_m[0]-'0';

    for($a=0; $a<$n;$a++){
        if(in_array("$initial", $list_of_unmatch))
            $initial++;
    }

    $path = "";

    $fix=$initial;
    for($i=1; $i<=$n; $i++){
        $initial=$fix;
        while($initial==$i)
            $initial++;
        $temp=$i.' '.$initial;
        if(in_array($temp,$path)){
 			continue;
        }

        $temp=$initial.' '.$i;
        $path[]=$temp;
    }
    echo $n-1;
    for($j=0; $j<$n-1; $j++){
        // echo "<br>".$path[$j];
        echo PHP_EOL.$path[$j];
    }

<?php
/*	$input = "4 1
1 3";*/
	$input = trim(file_get_contents("php://stdin"));
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$array_length = $split_text.length;

	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$split_text)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	// $input = trim(file_get_contents("php://stdin"));
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$array_length = sizeof($split_text);
	for($c=0; $c<$array_length; $c++){
		$list_of_unmatch[] = explode(" ",$split_text[$c]);
	}

	$initial=1;
	$unmatch_length = sizeof($list_of_unmatch);

	$n = $n_m[0]-'0';
	for($a=0; $a<$n;$a++){
		if(in_array("$initial", $list_of_unmatch))
			$initial++;
	}
	$path = "";
	for($i=1; $i<$n; $i++){
		$temp=(string)($initial.' '.($i+1));
		while($initial==$i)
			$initial++;
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

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

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$split_text)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		echo "<br>".$path[$j];
		// echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text[$c+1]);
	}
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=$initial.' '.($i+1);
		$temp1=($i+1).' '.$initial;
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo $path[$j].PHP_EOL;
	}

<?php
/*  $input = "4 1
1 3";*/
    $input = trim(file_get_contents("php://stdin"));
    $split_text = explode("\n",$input);
    $n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
    $number_of_not_match = $n_m[1]-'0';
    array_splice($split_text, 0, 1);
    $list_of_unmatch=array();
    $array_length = sizeof($split_text);
    for($c=0; $c<$array_length; $c++){
        $unmatch = explode(" ",$split_text[$c]);
        array_push($list_of_unmatch, trim($unmatch[0]), trim($unmatch[1]));
    }

    var_dump($list_of_unmatch);

    $list_of_unmatch = array_unique($list_of_unmatch);
    $list_of_unmatch = array_values($list_of_unmatch);
    $initial=1;
    $unmatch_length = sizeof($list_of_unmatch);
    $n = $n_m[0]-'0';

    for($a=0; $a<$n;$a++){
        if(in_array("$initial", $list_of_unmatch))
            $initial++;
    }

    $path = "";

    $fix=$initial;
    for($i=1; $i<=$n; $i++){
        $initial=$fix;
        while($initial==$i)
            $initial++;
        $temp=$i.' '.$initial;
        if(in_array($temp,$path)){
 			continue;
        }

        $temp=$initial.' '.$i;
        $path[]=$temp;
    }
    echo $n-1;
    for($j=0; $j<$n-1; $j++){
        // echo "<br>".$path[$j];
        echo PHP_EOL.$path[$j];
    }

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);
	$split_text = implode("\n",$split_text);
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text);
	}
	$forever_nt_couple = array_map('strval',$forever_nt_couple);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(var_dump(in_array($temp,$forever_nt_couple))){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = trim(file_get_contents("php://stdin"));
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$array_length = sizeof($split_text);
	for($c=0; $c<$array_length; $c++){
		$list_of_unmatch[] = explode(" ",$split_text[$c]);
	}

	$initial=1;
	$unmatch_length = sizeof($list_of_unmatch);

	$n = $n_m[0]-'0';
	for($a=0; $a<$n;$a++){
		if(in_array("$initial", $list_of_unmatch))
			$initial++;
	}
	$path = "";
	$fix=$initial;
	for($i=1; $i<$n; $i++){
		$initial=$fix;
		$temp=(string)($initial.' '.($i+1));
		while($initial==$i)
			$initial++;
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*  $input = "4 1
1 3";*/
    $input = trim(file_get_contents("php://stdin"));
    $split_text = explode("\n",$input);
    $n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
    $number_of_not_match = $n_m[1]-'0';
    array_splice($split_text, 0, 1);

    $array_length = sizeof($split_text);
    for($c=0; $c<$array_length; $c++){
    	$split_text[$c] = trim($split_text[$c]);
        $list_of_unmatch = explode(" ",$split_text[$c]);
    }

    $initial=1;
    $unmatch_length = sizeof($list_of_unmatch);
    $n = $n_m[0]-'0';

    for($a=0; $a<$n;$a++){
        if(in_array("$initial", $list_of_unmatch))
            $initial++;
    }

    $path = "";

    $fix=$initial;
    for($i=1; $i<=$n; $i++){
        $initial=$fix;
        while($initial==$i)
            $initial++;
        $temp=$i.' '.$initial;
        $temp1=$initial.' '.$i;
        if(in_array($temp,$path)){
 			continue;
        }

        if(in_array($temp,$split_text) || in_array($temp1,$split_text)){
        	$initial++;
        	while($initial==$i)
            	$initial++;
        }

        $temp=$initial.' '.$i;
        $path[]=$temp;
    }
    echo $n-1;
    for($j=0; $j<$n-1; $j++){
        // echo "<br>".$path[$j];
        echo PHP_EOL.$path[$j];
    }

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);
	$split_text = implode("\n",$split_text);
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text);
	}
	$forever_nt_couple = array_map('strval',$forever_nt_couple);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array(var_dump($temp),var_dump($forever_nt_couple))){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*  $input = "4 1
1 3";*/
    $input = trim(file_get_contents("php://stdin"));
    $split_text = explode("\n",$input);
    $n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
    $number_of_not_match = $n_m[1]-'0';
    array_splice($split_text, 0, 1);

    $array_length = sizeof($split_text);
    for($c=0; $c<$array_length; $c++){
    	$split_text[$c] = trim($split_text[$c]);
        $list_of_unmatch = explode(" ",$split_text[$c]);
    }

    $initial=1;
    $unmatch_length = sizeof($list_of_unmatch);
    $n = $n_m[0]-'0';

    for($a=0; $a<$n;$a++){
        if(in_array("$initial", $list_of_unmatch))
            $initial++;
    }

    $path = "";

    $fix=$initial;
    for($i=1; $i<=$n; $i++){
        $initial=$fix;
        while($initial==$i)
            $initial++;
        $temp=$i.' '.$initial;
        $temp=$initial.' '.$i;
        if(in_array($temp,$path) || in_array($temp,$split_text) || in_array($temp1,$split_text)){
        	$initial++;
        	while($initial==$i)
            	$initial++;
        }

        $temp=$initial.' '.$i;
        $path[]=$temp;
    }
    echo $n-1;
    for($j=0; $j<$n-1; $j++){
        // echo "<br>".$path[$j];
        echo PHP_EOL.$path[$j];
    }

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text[$c+1]);
	}
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=$initial.' '.($i+1);
		if(in_array($temp,"$forever_nt_couple")){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text[$c+1]);
	}
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=$initial.' '.($i+1);
		$temp1=($i+1).' '.$initial;
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);
	$split_text = implode("\n",$split_text);
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text);
	}
	$forever_nt_couple = array_map('strval',$forever_nt_couple);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text[$c+1]);
	}
	$forever_nt_couple = array_map('strval',$forever_nt_couple);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=$initial.' '.($i+1);
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = trim(file_get_contents("php://stdin"));
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$array_length = sizeof($split_text);
	for($c=0; $c<$array_length; $c++){
		$list_of_unmatch[] = explode(" ",$split_text[$c]);
	}

	$initial=1;
	$unmatch_length = sizeof($list_of_unmatch);

	$n = $n_m[0]-'0';
	for($a=0; $a<$n;$a++){
		if(in_array("$initial", $list_of_unmatch))
			$initial++;
	}
	$path = "";
	for($i=1; $i<$n; $i++){
		$temp=(string)($initial.' '.($i+1));
		while($initial==$i)
			$initial++;
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");
	var_dump($input);
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);
	var_dump($split_text);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$split_text)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(array_search($temp,$split_text)!==false){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text);
	}
	$forever_nt_couple = array_map('strval',$forever_nt_couple);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text[$c+1]);
		echo $forever_nt_couple;
	}
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=$initial.' '.($i+1);
		$temp1=($i+1).' '.$initial;
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*  $input = "4 1
1 3";*/
    $input = trim(file_get_contents("php://stdin"));
    $split_text = explode("\n",$input);
    $n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
    $number_of_not_match = $n_m[1]-'0';
    array_splice($split_text, 0, 1);

    $array_length = sizeof($split_text);
    for($c=0; $c<$array_length; $c++){
    	$split_text[$c] = trim($split_text[$c]);
        $list_of_unmatch = explode(" ",$split_text[$c]);
    }

    $initial=1;
    $unmatch_length = sizeof($list_of_unmatch);
    $n = $n_m[0]-'0';

    for($a=0; $a<$n;$a++){
        if(in_array("$initial", $list_of_unmatch))
            $initial++;
    }

    $path = "";

    $fix=$initial;
    for($i=1; $i<=$n; $i++){
        $initial=$fix;
        while($initial==$i)
            $initial++;
        $temp=trim($i.' '.$initial);
        if(in_array($temp,$path)){
        	continue;
        }
        $temp=$initial.' '.$i;
        $path[]=$temp;
    }
    echo $n-1;
    for($j=0; $j<$n-1; $j++){
        // echo "<br>".$path[$j];
        echo PHP_EOL.$path[$j];
    }

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$split_text)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");

	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	for($c=0; $c<$number_of_not_match; $c++){
		$forever_nt_couple = explode("\n",$split_text[$c+1]);
		echo $forever_nt_couple[0];
	}
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=$initial.' '.($i+1);
		$temp1=($i+1).' '.$initial;
		if(in_array($temp,$forever_nt_couple)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");
	var_dump($input);
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);
	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array(var_dump($temp),var_dump($split_text))){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

<?php
/*	$input = "4 1
1 3";*/
	$input = file_get_contents("php://stdin");
	var_dump($input);
	$split_text = explode("\n",$input);
	$n_m = explode(" ",$split_text[0]); //index 0 store n, index 1 store m
	$number_of_not_match = $n_m[1]-'0';
	array_splice($split_text, 0, 1);

	$array_length = $split_text.length;
	for($a=0; $a<$array_length;$a++)
		$split_text[$a]=trim($split_text[$a]);

	$n = $n_m[0]-'0';
	$path = "";
	for($i=1; $i<$n; $i++){
		$initial=1;
		$temp=(string)($initial.' '.($i+1));
		if(in_array($temp,$split_text)){
			$initial++;
			while($initial==$i)
				$initial++;
			$temp=$initial.' '.$i;
		}
		$path[]=$temp;
	}
	echo $n-1;
	for($j=0; $j<$n-1; $j++){
		// echo "<br>".$path[$j];
		echo PHP_EOL.$path[$j];
	}

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

$nm = explode(' ',$f[0]);

for ($i=1;$i<=$nm[0];$i++) {
	$all[$i] = 1;
}

$left = $right = array();

if ($f[1]) {
	for ($i=1;$i<=$nm[1];$i++) {
		$deny = explode(' ',$f[$i]);

		if (!$left || $left[$deny[0]] || $left[$deny[1]]) {
			$left[$deny[0]] = 1;
			$left[$deny[1]] = 1;
		} else {
			$right[$deny[0]] = 1;
			$right[$deny[1]] = 1;
		}

		unset($all[$deny[0]],$all[$deny[1]]);
	}

	$qa = sizeof($all);

	if (!$right) {
		$move = key($all);
		$right[$move] = 1;
		unset($all[$move]);
		$left += $all;
	} elseif (sizeof($left) > sizeof($right)) {
		$left += $all;
	} else {
		$right += $all;
	}

} else {
	$left = array(1=>1);
	unset($all[1]);
	$right = $all;
}

$ql = sizeof($left);
$qr = sizeof($right);

if ($a = $ql * $qr) {
	echo $a;
	foreach ($left as $l=>$null) {
		foreach ($right as $r=>$null) {
			echo PHP_EOL.$l.' '.$r;
		}
	}
} else {
	echo 0;
}

<?
$f = file('php://stdin'); $f2 = fopen('php://stdout','w+');

$nm = explode(' ',$f[0]);

for ($i=1;$i<=$nm[0];$i++) {
	$all[$i] = 1;
}

$left = $right = array();

if ($f[1]) {
	for ($i=1;$i<=$nm[1];$i++) {
		$deny = explode(' ',$f[$i]);

		if (!$left || $left[$deny[0]] || $left[$deny[1]]) {
			$left[$deny[0]] = 1;
			$left[$deny[1]] = 1;
		} else {
			$right[$deny[0]] = 1;
			$right[$deny[1]] = 1;
		}

		unset($all[$deny[0]],$all[$deny[1]]);
	}

	$qa = sizeof($all);

	if ($right && sizeof($left) > sizeof($right)) {
		$left += $all;
		$ql += $qa;
	} else {
		$right += $all;
		$qr += $qa;
	}

} else {
	$left = array(1=>1);
	unset($all[1]);
	$right = $all;
}

$ql = sizeof($left);
$qr = sizeof($right);

if ($a = $ql * $qr) {
	fwrite($f2, $a);
	foreach ($left as $l=>$null) {
		foreach ($right as $r=>$null) {
			fwrite($f2, $l.' '.$r);
		}
	}
} else {
	fwrite($f2, 0);
}

fclose($f2);

<?
$f = file('php://stdin');

$nm = explode(' ',$f[0]);

for ($i=1;$i<=$nm[0];$i++) {
	$all[$i] = 1;
}

$left = $right = array();

if ($f[1]) {
	for ($i=1;$i<=$nm[1];$i++) {
		$deny = explode(' ',$f[$i]);

		if (!$left || $left[$deny[0]] || $left[$deny[1]]) {
			$left[$deny[0]] = 1;
			$left[$deny[1]] = 1;
		} else {
			$right[$deny[0]] = 1;
			$right[$deny[1]] = 1;
		}

		unset($all[$deny[0]],$all[$deny[1]]);
	}

	$qa = sizeof($all);

	if (!$right) {
		$move = key($all);
		$right[$move] = 1;
		unset($all[$move]);
		$left += $all;
	} elseif (sizeof($left) > sizeof($right)) {
		$left += $all;
	} else {
		$right += $all;
	}

} else {
	$left = array(1=>1);
	unset($all[1]);
	$right = $all;
}

$ql = sizeof($left);
$qr = sizeof($right);

if ($a = $ql * $qr) {
	echo $a;
	foreach ($left as $l=>$null) {
		foreach ($right as $r=>$null) {
			echo PHP_EOL.$l.' '.$r;
		}
	}
} else {
	echo 0;
}

<?
$f = file('php://stdin'); $f2 = fopen('php://stdout','w+');

$nm = explode(' ',$f[0]);

for ($i=1;$i<=$nm[0];$i++) {
	$all[$i] = 1;
}

$left = $right = array();

if ($f[1]) {
	for ($i=1;$i<=$nm[1];$i++) {
		$deny = explode(' ',$f[$i]);

		if (!$left || $left[$deny[0]] || $left[$deny[1]]) {
			$left[$deny[0]] = 1;
			$left[$deny[1]] = 1;
		} else {
			$right[$deny[0]] = 1;
			$right[$deny[1]] = 1;
		}

		unset($all[$deny[0]],$all[$deny[1]]);
	}

	$qa = sizeof($all);

	if (!$right) {
		$move = key($all);
		$right[$move] = 1;
		unset($all[$move]);
		$left += $all;
	} elseif (sizeof($left) > sizeof($right)) {
		$left += $all;
	} else {
		$right += $all;
	}

} else {
	$left = array(1=>1);
	unset($all[1]);
	$right = $all;
}

$ql = sizeof($left);
$qr = sizeof($right);

if ($a = $ql * $qr) {
	fwrite($f2, $a.PHP_EOL);
	foreach ($left as $l=>$null) {
		foreach ($right as $r=>$null) {
			fwrite($f2, $l.' '.$r.PHP_EOL);
		}
	}
} else {
	fwrite($f2, 0);
}

fclose($f2);


<?php
    //phpinfo();
    // 输入
    function solve($n)
    {
        for($i = 1; $i <= $n; $i ++) echo $i * 2 . " " ;
        for($i = 1; $i < $n; $i ++) echo $i * 2 - 1 . " " ;
        echo $n * 3 - 1 . "\n" ;
    }

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

        $half = $n / 2 ;
        if($half & 1)
        {
            echo "NO" . "\n" ;
            continue ;
        }
        else
        {
            echo "YES" . "\n" ;
            solve($half) ;
        }
    }
?>

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

$solve = function($n){

	if($n % 4 !== 0){
		return false;
	}
	$a = array_fill(0, $n, 0);
	$n2 = $n / 2;
	for($i = 0; $i < $n2; $i++){
		$i2 = 2*$i + 1;
		$a[$i + $n2] = $i2;
		$a[$i] = $i2 + 1;
	}
	$a[$n-1] += $n2;
	return $a;
};

$t = intval(fgets(STDIN));
for(; $t > 0; $t--){

	$n = intval(fgets(STDIN));

	if(($a = $solve($n)) === false){
		echo "NO";
	} else {
		echo "YES\n";
		echo implode(' ', $a);
	}
	echo "\n";
}

<?php
error_reporting(0);

main();

function main() {
	list($cases) = explode(" ", trim(fgets(STDIN)));

	for ($i = 0; $i < $cases; $i++) {
		$n = trim(fgets(STDIN));
		$res = run($n);
		if ($res[0] == "NO") {
			print "NO\n";
		} else {
			print "YES\n";
			print join(" ", $res[1]) . "\n";
		}
	}
}

function run($n) {
	if ( ($n / 2) % 2 == 1) {
		return ["NO", []];
	}

	$start = 4;

	$res = [];

	$total1 = 0;

	for ($i = 0; $i < $n/2; $i++) {
		array_push($res, $start);
		$total1 += $start;
		$start += 2;
	}

	$start = 3;

	$total2 = 0;

	for ($i = 0; $i < $n/2; $i++) {
		array_push($res, $start);
		$total2 += $start;
		$start += 2;
	}

	#print $total1 . ":" . $total2 . "\n";

	$res[count($res)-1] += ($total1 - $total2);

	return ["YES", $res];
}

?>

<?php

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --){
    //print pow(2, intval(fgets(STDIN)) - 1)."\n";
    $n = intval(trim(fgets(STDIN)));
    if(($n / 2) % 2 == 1) {
        print "NO\n";
        continue;
    }
    print "YES\n";

    for($i = 0; $i < $n / 2; $i++){
        print (($i + 1) * 2)." ";
    }

    for($i = 1; $i < $n - 1; $i += 2){
        print ($i)." ";
    }

    print $n + $n / 2 - 1;
    print "\n";

}

<?php

$t = (int)fgets(STDIN);
for ($i = 0; $i < $t; $i++) {
    $n = (int)fgets(STDIN);
    if ($n === 2) {
        echo "NO\n";
        continue;
    }

    if (($n % 4) !== 0) {
        echo "NO\n";
        continue;
    }

    $sum = 0;
    $diff = 0;
    echo "YES\n";
    $k = $n / 2;
    for ($j = 0; $j < $k; $j++) {
        $diff += 2;
        echo $diff.' ';
        $sum += $diff;
    }
    $k = $n / 2;
    $diff = 1;
    while ($k > 1) {
        echo $diff." ";
        $sum -= $diff;
        $diff += 2;
        $k--;
    }
    echo $sum."\n";
}

<?php
    //phpinfo();
    // 输入
    function solve($n)
    {
        for($i = 1; $i <= $n; $i ++) echo $i * 2 . " " ;
        for($i = 1; $i < $n; $i ++) echo $i * 2 - 1 . " " ;
        echo $n * 3 - 1 . "\n" ;
    }

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

        $half = $n / 2 ;
        if($half & 1)
        {
            echo "NO" . "\n" ;
            continue ;
        }
        else
        {
            echo "YES" . "\n" ;
            solve($half) ;
        }
    }
?>

<?php
    //phpinfo();
    // 输入
    function solve($n)
    {
        $Balanced = array() ;

        for($i = 1; $i <= $n; $i ++) $Balanced[] = 2 * $i ;
        for($i = 1; $i < $n; $i ++) $Balanced[] = $i * 2 - 1 ;
        $Balanced[] = $i * 3 - 1 ;

        echo implode(" ", $Balanced) . "\n" ;
    }

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

        $half = $n / 2 ;
        if($half & 1)
        {
            echo "NO" . "\n" ;
            continue ;
        }
        else
        {
            echo "YES" . "\n" ;
            solve($half) ;
        }
    }
?>

<?php
error_reporting(0);

main();

function main() {
	list($cases) = explode(" ", trim(fgets(STDIN)));

	for ($i = 0; $i < $cases; $i++) {
		$n = trim(fgets(STDIN));
		$res = run($n);
		if ($res[0] == "NO") {
			print "NO\n";
		} else {
			print "YES\n";
			print join(" ", $res[1]) . "\n";
		}
	}
}

function run($n) {
	if ( ($n / 2) % 2 == 1) {
		return ["NO", []];
	}

	$start = 4;

	$res = [];

	$total1 = 0;

	for ($i = 0; $i < $n/2; $i++) {
		array_push($res, $start);
		$total1 += $start;
		$start += 2;
	}

	$start = 3;

	$total2 = 0;

	for ($i = 0; $i < $n/2; $i++) {
		array_push($res, $start);
		$total2 += $start;
		$start += 2;
	}

	print $total1 . ":" . $total2 . "\n";

	$res[count($res)-1] += ($total1 - $total2);

	return ["YES", $res];
}

?>


<?php

$data1 = (int) trim(fgets(STDIN));
// $data2 = str_split(trim(fgets(STDIN)), 1);
// $data3 = str_split(trim(fgets(STDIN)), 1);
for($i=0;$i<$data1;$i++)
{
    $data2 = (int) trim(fgets(STDIN));
    $data3 = preg_split("/ /", trim(fgets(STDIN)));

    $main = new MainClass;

    echo $main->solution($data1, $data2 , $data3) . "\r\n";
}

class MainClass {

	public function solution($n , $m , $data)
	{
	    if($m == 1)
    	    return 0;

    	$sum = array_sum($data);
    	if($sum % $m != 0)
    	    return -1;

    	$avg=$sum/count($data);
    	$max= 0;
    	$min= 0;
    	foreach($data as $value)
    	{
    	    if($value > $avg)
    	    {
    	        $max++;
    	    }
    	    elseif($value <= $avg)
    	    {
    	        $min++;
    	    }
    	}

	    return $max;
	}
}

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

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

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

  $sum = array_sum($a);
  if ($sum % $n != 0) { echo '-1'.PHP_EOL; }
  else {
    $d = $sum / $n;
    for ($j = 0; $j < $n; $j++) {
      if ($a[$j] > $d) { $ans++; }
    }
    echo $ans.PHP_EOL;
  }
}

?>

<?php

$data1 = (int) trim(fgets(STDIN));
// $data2 = str_split(trim(fgets(STDIN)), 1);
// $data3 = str_split(trim(fgets(STDIN)), 1);
for($i=0;$i<$data1;$i++)
{
    $data2 = (int) trim(fgets(STDIN));
    $data3 = preg_split("/ /", trim(fgets(STDIN)));

    $main = new MainClass;

    echo $main->solution($data1, $data2 , $data3) . "\r\n";
}

class MainClass {

	public function solution($n , $m , $array)
	{
	    if($m == 1)
    	    return 0;

	    $sum = $max_c = $max = 0;
	    foreach($array as $index)
	    {
	        $sum += $index;
	        if($max < $index)
	        {
	            $max = $index;
	        }
	    }

	    if($sum % $m != 0)
            return -1;

	    foreach($array as $index)
	    {
	        if($max == $index)
            {
                $max_c++;
            }
	    }

	    return $m - $max_c;
	}
}

<?php

$data1 = (int) trim(fgets(STDIN));
// $data2 = str_split(trim(fgets(STDIN)), 1);
// $data3 = str_split(trim(fgets(STDIN)), 1);
for($i=0;$i<$data1;$i++)
{
    $data2 = (int) trim(fgets(STDIN));
    $data3 = preg_split("/ /", trim(fgets(STDIN)));

    $main = new MainClass;

    echo $main->solution($data1, $data2 , $data3) . "\r\n";
}

// End of interface

class MainClass {
	// 978В.File name
	//public $problemLink = 'https://codeforces.com/problemset/problem/978/B';
	//public $submissionLink = '';

	public function solution($n , $m , $array)
	{
	    if($m == 1)
    	    return 0;

	    $sum = $max_c = $max = 0;
	    foreach($array as $index)
	    {
	        $sum += $index;
	        if($max < $index)
	        {
	            $max = $index;
	        }
	    }

	    if($sum % $m != 0)
            return -1;

	    foreach($array as $index)
	    {
	        if($max == $index)
            {
                $max_c++;
            }
	    }

	    return $max - $max_c;
	}
}


<?php
/**
 * Created by PhpStorm.
 * User: jianzjzhang
 * Date: 2018/5/10
 * Time: 10:36
 */

function mapping($arr, $k)
{
    $map = array();
    $map = array_pad($map, 256, -1);
    $dp = array();
    $dp = array_pad($dp, 256, -1);
    $result = array();

    foreach ($arr as $x){
        if($map[$x] != -1){
            $result[] = $map[$x];
        }
        else{
            $start = $x - $k + 1;
            if($start < 0){
                $start = 0;
            }
            if($map[$start] != -1 && $start != 0 && $map[$start-1] == $map[$start]){
                $start = $dp[$start] + 1;
            }
            $result[] = $start;
            for($i=$start; $i<=$x; $i++){
                $map[$i] = $start;
                $dp[$i] = $x;
            }
        }
    }
    return $result;
}

function main()
{
    list($n, $k) = explode(" ", fgets(STDIN));
    $arr = array();
    for($i=0; $i<$n-1; $i++){
        $arr[] = intval(stream_get_line(STDIN, 4, " "));
    }
    $arr[] = intval(stream_get_line(STDIN, 4, "\n"));

    echo implode(" ", mapping($arr, intval($k)));
}

main();

<?php
/**
 * Created by PhpStorm.
 * User: jianzjzhang
 * Date: 2018/5/10
 * Time: 10:36
 */

function mapping($arr, $k)
{
    $map = array();
    $map = array_pad($map, 256, -1);
    $result = array();

    foreach ($arr as $x){
        if($map[$x] != -1){
            $result[] = $map[$x];
        }
        else{
            $start = $x;
            for(; $start+$k>$x && $start>=0 && $map[$start]==-1; $start--);
            $result[] = ++$start;
            for($i=0; $i<$k; $i++){
                $map[$start+$i] = $start;
            }
        }
    }
    return $result;
}

function main()
{
    list($n, $k) = explode(" ", fgets(STDIN));
    $arr = array();
    for($i=0; $i<$n; $i++){
        $arr[] = intval(stream_get_line(STDIN, 4, " "));
    }

    echo implode(" ", mapping($arr, intval($k)));
}

main();


<?php
    $dir                        = fopen("php://stdin", 'r');
    $contents                   = stream_get_contents($dir);
    $inputs                     = explode("\n",$contents);
    $entrancesCount             = (int) $inputs[0];
    $fansCountPerEntrance       = array_map('intval', explode(' ', $inputs[1]));
    $possibilitiesForEntrance   = [];
    $fanEntrance                = getEntrance($entrancesCount, $fansCountPerEntrance);
    echo $fanEntrance;

    function getEntrance($entrancesCount, $fansCountPerEntrance)
    {
        for($entranceCounter = 0; $entranceCounter < $entrancesCount; $entranceCounter ++)
        {
           /* if($fansCountPerEntrance[0] == 1)
            {
                return $entranceCounter + 1;
            } */
            $possibilitiesForEntrance[$entranceCounter] = max(0, ceil(($fansCountPerEntrance[$entranceCounter] - $entranceCounter) / $entrancesCount));
        }
        $entranceNumber = array_keys($possibilitiesForEntrance, min($possibilitiesForEntrance))[0]+1;
        return $entranceNumber;
    }
?>

<?php
    $dir                        = fopen("php://stdin", 'r');
    $contents                   = stream_get_contents($dir);
    $inputs                     = explode("\n",$contents);
    $entrancesCount             = (int) $inputs[0];
    $fansCountPerEntrance       = array_map('intval', explode(' ', $inputs[1]));
    $possibilitiesForEntrance   = [];
    $fanEntrance                = getEntrance($entrancesCount, $fansCountPerEntrance);
    echo $fanEntrance;

    function getEntrance($entrancesCount, $fansCountPerEntrance)
    {
        for($entranceCounter = 0; $entranceCounter < $entrancesCount; $entranceCounter ++)
        {
            if($fansCountPerEntrance[0] == 1)
            {
                return $entranceCounter + 1;
            }
            $possibilitiesForEntrance[$entranceCounter] = max(0, ceil(($fansCountPerEntrance[$entranceCounter] - $entranceCounter) / $entrancesCount));
        }
        $entranceNumber = array_keys($possibilitiesForEntrance, min($possibilitiesForEntrance))[0]+1;
        return $entranceNumber;
    }
?>


<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readString() {$d = trim(fgets($this->_fh));return $d;}
	public function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}
	public function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
	public function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}
}

class Utils {
	/* Perform action N times. Can return values in array */
	static public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}
	/* Integral. Keys preserved. By reference. */
	static public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}
	/* Difference. Keys preserved. By reference. */
	static public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}
	static public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}
}

class PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = [];
	static public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}
	static public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}
}

/*****************************************/

$ir = new InputReader();

/* TASK */
$t = $ir->readInt();

for($i=1; $i<=$t; $i++) {
	list($l, $r) = $ir->readArrayOfInt(2);
	echo $l.' '.(2*$l)."\n";
	flush();
}

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     $d = $b * 2;
     print $b . " " . $d . "\n";
}
?>

<?php
$numberOfRooms = (int)trim(fgets(STDIN));

$count = 0;
for ($i = 0; $i < $numberOfRooms; $i++) {
    $numbers = explode(' ', trim(fgets(STDIN)));
    $first = (int) $numbers[0];
    $last = (int) $numbers[1];
    echo $first. " ". ($first*2) . "\n";
}

<?php
$number = trim(fgets(STDIN));
for ($i=$number; $i > 0 ; $i--) {
    list($x, $y) = explode(' ', trim(fgets(STDIN)));
    echo $x ." ".($x*2)."\n";
    $number--;
}

<?php
function returnDivisible($start, $end)
{
    for ($i = $start; $i <= floor($end/2)  ; $i++) {
        if ($i * 2 <= $end) {
            return [$i, $i * 2];
        }
    }

    return [null, null];
}

$p = fopen('php://stdin', 'r');
$t = intval(fgets($p));
$lines = [];
for ($i = 0; $i < $t; $i++) {
    $lines[] = explode(' ', fgets($p));
}

foreach ($lines as $line) {
    echo returnDivisible($line[0], $line[1])[0] . ' ' . returnDivisible($line[0], $line[1])[1] . PHP_EOL;
}

<?php
$number = trim(fgets(STDIN));
$res[] = 0;
for ($i=$number; $i > 0 ; $i--) {
    list($x, $y) = explode(' ', trim(fgets(STDIN)));
    for ($j=$x; $j < $y ; $j++) {
        if ($y%$j == 0) {
            echo $j ." ".$y."\n";
            break;
        }
    }
    $number--;
}

<?php
$number = trim(fgets(STDIN));
$res[] = 0;
for ($i=$number; $i > 0 ; $i--) {
    list($x, $y) = explode(' ', trim(fgets(STDIN)));
    for ($j=$x; $j <= $y ; $j++) {
        if ($y%$j == 0 && $j != $y) {
            echo $j ." ".$y."\n";
            break;
        }
    }
    $number--;
}


<?php
$k = intval(fgets(STDIN));
for($i = 0; $i < $k; $i++)
{
    $n = intval(fgets(STDIN));
    $repeats = array();
    $s1 = fgets(STDIN);
    $s2 = fgets(STDIN);
    $arS1 = str_split($s1);
    $arS2 = str_split($s2);
    $diff1 = array_diff_assoc($arS1, $arS2);
    $diff2 = array_diff_assoc($arS2, $arS1);
    $succ = false;
    if(count($diff1) == 2) {
        $first = reset($diff1);
        $second = array_pop($diff1);
        $third = reset($diff2);
        $fourth = array_pop($diff2);
        if($first == $second && $third == $fourth)
            $succ = true;
    }

    $res = ($succ) ? "YES\n" : "NO\n";
    echo $res;

}?>

<?php
    $dir = fopen("php://stdin", 'r');
    $input = stream_get_contents($dir);

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray)-2; $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    $response = array();
    foreach ($casesArray as $case) {
        if (countDifferencesAndValidate($case['length'], $case['word_1'], $case['word_2'])) {
            array_push($response, "YES");
        } else {
            array_push($response, "NO");
        }
    }

    echo implode(PHP_EOL, $response);

    function countDifferencesAndValidate($length, $word_1, $word_2)
    {
        $charactersOfWord_1 = str_split($word_1);
        $charactersOfWord_2 = str_split($word_2);

        $counter = 0;
        $differencesArray = array();
        for ($i = 0; $i < $length; $i++) {
            if ($charactersOfWord_1[$i] != $charactersOfWord_2[$i]) {
                $counter++;
                $differencesArray[$i] = array('word_1' => $charactersOfWord_1[$i], 'word_2' => $charactersOfWord_2[$i]);
            }

            if ($counter > 2) {
                return false;
            }
        }

        if ($counter == 2) {
            $status = validateDifferences($differencesArray);

            return $status;
        } else {
            return false;
        }
    }

    function validateDifferences($inputArray)
    {
        $keys = array_keys($inputArray);
        if ($inputArray[$keys[0]]['word_1'] == $inputArray[$keys[1]]['word_1'] &&
            $inputArray[$keys[0]]['word_2'] == $inputArray[$keys[1]]['word_2']) {
            return true;
        }

        return false;
    }

<?php
    $dir = fopen("php://stdin", 'r');
    $input = stream_get_contents($dir);
//    $input = '4
//5

//bca';

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray)-2; $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    $response = array();
    foreach ($casesArray as $case) {
        if (countDifferencesAndValidate($case['length'], $case['word_1'], $case['word_2'])) {
            array_push($response, "YES");
        } else {
            array_push($response, "NO");
        }
    }

    echo implode(PHP_EOL, $response);

    function countDifferencesAndValidate($length, $word_1, $word_2)
    {
        $charactersOfWord_1 = str_split($word_1);
        $charactersOfWord_2 = str_split($word_2);

        $counter = 0;
        $differencesArray = array();
        for ($i = 0; $i < $length; $i++) {
            if ($charactersOfWord_1[$i] != $charactersOfWord_2[$i]) {
                $counter++;
                $differencesArray[$i] = array('word_1' => $charactersOfWord_1[$i], 'word_2' => $charactersOfWord_2[$i]);
            }

            if ($counter > 2) {
                return false;
            }
        }

        if ($counter == 2) {
            $status = validateDifferences($differencesArray);

            return $status;
        } else {
            return false;
        }
    }

    function validateDifferences($inputArray)
    {
        $keys = array_keys($inputArray);
        if ($inputArray[$keys[0]]['word_1'] == $inputArray[$keys[1]]['word_1'] &&
            $inputArray[$keys[0]]['word_2'] == $inputArray[$keys[1]]['word_2']) {
            return true;
        }

        return false;
    }

<?php
    $dir = fopen("php://stdin", 'r');
    $input = stream_get_contents($dir);
//    $input = '4
//5
//souse
//houhe
//3
//cat
//dog
//2
//aa
//az
//3
//abc
//bca';

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray)-2; $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    $response = array();
    foreach ($casesArray as $case) {
        if (countDifferencesAndValidate($case['length'], $case['word_1'], $case['word_2'])) {
            array_push($response, "YES");
        } else {
            array_push($response, "NO");
        }
    }

    echo implode(PHP_EOL, $response);

    function countDifferencesAndValidate($length, $word_1, $word_2)
    {
        $charactersOfWord_1 = str_split($word_1);
        $charactersOfWord_2 = str_split($word_2);

        $counter = 0;
        $differencesArray = array();
        for ($i = 0; $i < $length; $i++) {
            if ($charactersOfWord_1[$i] != $charactersOfWord_2[$i]) {
                $counter++;
                $differencesArray[$i] = array('word_1' => $charactersOfWord_1[$i], 'word_2' => $charactersOfWord_2[$i]);
            }

            if ($counter > 2) {
                return false;
            }
        }

        if ($counter == 2) {
            $status = validateDifferences($differencesArray);

            return $status;
        } else {
            return false;
        }
    }

    function validateDifferences($inputArray)
    {
        $keys = array_keys($inputArray);
        if ($inputArray[$keys[0]]['word_1'] == $inputArray[$keys[1]]['word_1'] &&
            $inputArray[$keys[0]]['word_2'] == $inputArray[$keys[1]]['word_2']) {
            return true;
        }

        return false;
    }

<?php

$n = trim(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $x = trim(fgets(STDIN));
    $a = str_split(trim(fgets(STDIN)));
    $b = str_split(trim(fgets(STDIN)));
    $aR = $bR = array();
    $bool = "Yes";
    for($j = 0; $j < $x; $j++){
        if($a[$j] != $b[$j]){
            $aR[] = $a[$j];
            $bR[] = $b[$j];
        }
        if(count($aR) > 2 || count($bR) > 2){
            $bool = "No";
            break;
        }
    }

    if(count($aR) == 1){
            $bool = "No";
        }

    if($bool == "Yes"){
        $r1 = array_unique($aR);
        $r2 = array_unique($bR);
        if(count($r1) > 1 || count($r2) > 1){
            $bool = "No";
        }
    }
    echo $bool."\n";

}

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    list($k) = explode(' ', trim(fgets(STDIN)));
    list($s1) = explode(' ', trim(fgets(STDIN)));
    list($s2) = explode(' ', trim(fgets(STDIN)));
    $iCountTrue = 0;
    $iCountFalse = 0;
    $aTest1 = [];
    $aTest2 = [];
    $bFlag = true;
    for ($j = 0; $j < $k; $j++){
        if($s1[$j] != $s2[$j] && $iCountFalse <= 2){
            $aTest1[] = [
                'key' => $j,
                'word' => $s1[$j]
            ];
            $aTest2[] = [
                'key' => $j,
                'word' => $s2[$j]
            ];
            $iCountFalse++;
        }
    }
    if($iCountFalse == 2 && ($aTest1[0]['word'] == $aTest1[1]['word'] && $aTest2[0]['word'] == $aTest2[1]['word'])){
        echo "YES"."\n";
    } else {
        echo "NO"."\n";
    }
}

<?php

$q = + trim(fgets(STDIN));

for ($i = 0; $i < $q; $i++){
	$n = + trim(fgets(STDIN));
	$str1 = trim(fgets(STDIN));
	$str2 = trim(fgets(STDIN));

	echo calc($n, $str1, $str2) ? 'YES':'NO';
	echo "\n";

}

function calc($n, $str1, $str2){

	$arr1 = [];$arr2 = [];
	for ($i = 0; $i < $n; $i++){
		if($str1[$i] != $str2[$i]){
			$arr1[] = $str1[$i];
			$arr2[] = $str2[$i];
		}
	}
	$str1 = implode('', $arr1);
	$str2 = implode('', $arr2);

	if(strlen($str1) == 2 && $str1[0] == $str1[1] && $str2[0] == $str2[1]){
		return true;
	}
	return false;

}

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";$d=0;$t=0;
    $t = trim(fgets($handle));
    for($i=0;$i<$t;$i++)
    {
        $arr=array();
        $d = trim(fgets($handle));

        $str1 = trim(fgets($handle));
        $str2 = trim(fgets($handle));

        $arr=array();
        $ans=1;
        for ($h=0;$h<$d;$h++) {
            if($str1[$h]!=$str2[$h])
            {
                $arr[]=$str1[$h].$str2[$h];
            }
        }

            if(sizeof($arr)==2 && $arr[0]==$arr[1])
             printf("%s\n","Yes");
         else
             printf("%s\n","No");

    }

}

solve();
?>

<?php
fscanf(STDIN,"%d\n",$tc);
while ($tc--)
{
	fscanf(STDIN,"%d\n",$lengthOfStr);
	$str1=trim(fgets(STDIN));
	$str2=trim(fgets(STDIN));
    $cnt=0;
    $j=0;
    $a=array();
    $b=array();
	for ($i=0; $i <$lengthOfStr ; $i++)
	{
		if($str1[$i]!=$str2[$i])
		{
			$cnt++;
			$a[$j]=$str1[$i];
			$b[$j]=$str2[$i];
			$j++;
			if($cnt>2)
			break;
		}

	}
	if($cnt==2&&$a[0]==$a[1]&&$b[0]==$b[1])
		echo "Yes\n";
	else
		echo "No\n";
}

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    list($k) = explode(' ', trim(fgets(STDIN)));
    list($s1) = explode(' ', trim(fgets(STDIN)));
    list($s2) = explode(' ', trim(fgets(STDIN)));
    $iCountTrue = 0;
    $iCountFalse = 0;
    $bFlag = true;
    for ($j = 0; $j < $k; $j++){
        if($s1[$j] != $s2[$j]){
            $iCountFalse++;
        } else {
            $iCountTrue++;
        }
    }
    if($iCountFalse == 2 && $k != $iCountFalse){
        echo "YES"."\n";
    } else {
        echo "NO"."\n";
    }
}

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    list($k) = explode(' ', trim(fgets(STDIN)));
    list($s1) = explode(' ', trim(fgets(STDIN)));
    list($s2) = explode(' ', trim(fgets(STDIN)));
    $iCountTrue = 0;
    $iCountFalse = 0;
    $aTest1 = [];
    $aTest2 = [];
    $bFlag = true;
    for ($j = 0; $j < $k; $j++){
        if($s1[$j] != $s2[$j]){
            $aTest1[] = $s1[$j];
            $aTest2[] = $s2[$j];
            $iCountFalse++;
        } else {
            $iCountTrue++;
        }
    }
    if($iCountFalse == 2 && $k != $iCountFalse && ($aTest1[0] == $aTest1[1] && $aTest2[1] == $aTest2[0])){
        echo "YES"."\n";
    } else {
        echo "NO"."\n";
    }
}

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    list($k) = explode(' ', trim(fgets(STDIN)));
    list($s1) = explode(' ', trim(fgets(STDIN)));
    list($s2) = explode(' ', trim(fgets(STDIN)));
    $iCountTrue = 0;
    $iCountFalse = 0;
    $aTest1 = [];
    $aTest2 = [];
    $bFlag = true;
    for ($j = 0; $j < $k; $j++){
        if($s1[$j] != $s2[$j] && $iCountFalse <= 2){
            $aTest1[] = [
                'key' => $j,
                'word' => $s1[$j]
            ];
            $aTest2[] = [
                'key' => $j,
                'word' => $s2[$j]
            ];
            $iCountFalse++;
        }
    }
    if($iCountFalse == 2 && $k != $iCountFalse && ($aTest1[0]['word'] == $aTest1[1]['word'] && $aTest2[1]['word'] == $aTest2[0]['word'])){
        $s1[$aTest1[0]['key']] = $aTest2[0]['word'];
        $s2[$aTest2[1]['key']] = $aTest1[1]['word'];
        if($s1 == $s2){
            echo "YES"."\n";
        } else {
            echo "NO"."\n";
        }
    } else {
        echo "NO"."\n";
    }
}

<?php
$k = intval(fgets(STDIN));
for($i = 0; $i < $k; $i++)
{
    $n = intval(fgets(STDIN));
    $repeats = array();
    $s1 = fgets(STDIN);
    $s2 = fgets(STDIN);
    $arS1 = str_split($s1);
    $arS2 = str_split($s2);
    $diff1 = array_diff_assoc($arS1, $arS2);
    $diff2 = array_diff_assoc($arS2, $arS1);
    print_r($diff1);
    $succ = false;
    if(count($diff1) == 2) {
        $first = reset($diff1);
        $second = array_pop($diff1);
        $third = reset($diff2);
        $fourth = array_pop($diff2);
        if($first == $second && $third == $fourth)
            $succ = true;
    }

    $res = ($succ) ? "YES\n" : "NO\n";
    echo $res;

}?>

<?php
fscanf(STDIN,"%d\n",$tc);
while ($tc--)
{
	fscanf(STDIN,"%d\n",$lengthOfStr);
	$str1=trim(fgets(STDIN));
	$str2=trim(fgets(STDIN));
    $cnt=0;
    $j=0;
    $a=array();
    $b=array();
	for ($i=0; $i <$lengthOfStr ; $i++)
	{
		if($str1[$i]!=$str2[$i])
		{
			$cnt++;
			$a[$j]=$str1[$i];
			$b[$j]=$str2[$i];
			$j++;
		}
		if($cnt==2)
			break;
	}
	if($cnt==2&&$a[0]==$a[1]&&$b[0]==$b[1])
		echo "Yes\n";
	else
		echo "No\n";
}

<?php
    $dir = fopen("php://stdin", 'r');
    $input = stream_get_contents($dir);
    //    $input = '4
    //5
    //souse
    //houhe
    //3
    //cat
    //dog
    //2
    //aa
    //az
    //3
    //abc
    //bca';

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray); $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    $response = array();
    foreach ($casesArray as $case) {
        if (countDifferencesAndValidate($case['length'], $case['word_1'], $case['word_2'])) {
            array_push($response, "YES");
        } else {
            array_push($response, "NO");
        }
    }

    echo implode(PHP_EOL, $response);

    function countDifferencesAndValidate($length, $word_1, $word_2)
    {
        $charactersOfWord_1 = str_split($word_1);
        $charactersOfWord_2 = str_split($word_2);

        $counter = 0;
        $differencesArray = array();
        for ($i = 0; $i < $length; $i++) {
            if ($charactersOfWord_1[$i] != $charactersOfWord_2[$i]) {
                $counter++;
                $differencesArray[$i] = array('word_1' => $charactersOfWord_1[$i], 'word_2' => $charactersOfWord_2[$i]);
            }

            if ($counter > 2) {
                return false;
            }
        }

        if ($counter == 2) {
            $status = validateDifferences($differencesArray);

            return $status;
        } else {
            return false;
        }
    }

    function validateDifferences($inputArray)
    {
        $keys = array_keys($inputArray);
        if ($inputArray[$keys[0]]['word_1'] == $inputArray[$keys[1]]['word_1'] &&
            $inputArray[$keys[0]]['word_2'] == $inputArray[$keys[1]]['word_2']) {
            return true;
        }

        return false;
    }

<?php
        $dir = fopen("php://stdin", 'r');
        $input = stream_get_contents($dir);
//    $input = '4
//5
//souse
//houhe
//3
//cat
//dog
//2
//aa
//az
//3
//abc
//bca';

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray); $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    $response = array();
    foreach ($casesArray as $case) {
//        if (countDifferencesAndValidate($case['length'], $case['word_1'], $case['word_2'])) {
//            $response[] = "YES";
//        } else {
//            $response[] = "NO";
//        }
    }

    echo 1; exit();

<?php
        $dir = fopen("php://stdin", 'r');
        $input = stream_get_contents($dir);
        var_dump($input);

<?php
    $dir = fopen("php://stdin", 'r');
    $input = stream_get_contents($dir);
    //    $input = '4
    //5
    //souse
    //houhe
    //3
    //cat
    //dog
    //2
    //aa
    //az
    //3
    //abc
    //bca';

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray); $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    $response = array();
    foreach ($casesArray as $case) {
        if (countDifferencesAndValidate($case['length'], $case['word_1'], $case['word_2'])) {
            array_push($response, "YES");
        } else {
            array_push($response, "NO");
        }
    }

    echo implode(' ', $response);

    function countDifferencesAndValidate($length, $word_1, $word_2)
    {
        $charactersOfWord_1 = str_split($word_1);
        $charactersOfWord_2 = str_split($word_2);

        $counter = 0;
        $differencesArray = array();
        for ($i = 0; $i < $length; $i++) {
            if ($charactersOfWord_1[$i] != $charactersOfWord_2[$i]) {
                $counter++;
                $differencesArray[$i] = array('word_1' => $charactersOfWord_1[$i], 'word_2' => $charactersOfWord_2[$i]);
            }

            if ($counter > 2) {
                return false;
            }
        }

        if ($counter == 2) {
            $status = validateDifferences($differencesArray);

            return $status;
        } else {
            return false;
        }
    }

    function validateDifferences($inputArray)
    {
        $keys = array_keys($inputArray);
        if ($inputArray[$keys[0]]['word_1'] == $inputArray[$keys[1]]['word_1'] &&
            $inputArray[$keys[0]]['word_2'] == $inputArray[$keys[1]]['word_2']) {
            return true;
        }

        return false;
    }

<?php
        $dir = fopen("php://stdin", 'r');
        $input = stream_get_contents($dir);
//    $input = '4
//5
//souse
//houhe
//3
//cat
//dog
//2
//aa
//az
//3
//abc
//bca';

    $inputArray = explode(PHP_EOL, $input);

    $casesArray = array();
    $nrCases = (int)array_shift($inputArray);
    for ($i = 0, $count = 1; $i < count($inputArray); $i += 3) {
        $casesArray[$count++] = array(
            'length' => (int)$inputArray[$i],
            'word_1' => $inputArray[$i + 1],
            'word_2' => $inputArray[$i + 2]
        );
    }

    var_dump($casesArray);exit();

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";$d=0;$t=0;
    $t = trim(fgets($handle));
    for($i=0;$i<$t;$i++)
    {
        $arr=array();
        $d = trim(fgets($handle));

        $str1 = trim(fgets($handle));
        $str2 = trim(fgets($handle));
        $str1map=array();
        $str2map=array();
        for ($h=0;$h<$d;$h++)
        {
            if(isset($str1map[$str1[$h]])) {
                $str1map[$str1[$h]] = $str1map[$str1[$h]] + 1;
            }else
            {
                $str1map[$str1[$h]]=0;
            }
            if(isset($str2map[$str2[$h]])) {
                $str2map[$str2[$h]] = $str2map[$str2[$h]] + 1;
            }else
            {
                $str2map[$str2[$h]]=0;
            }

        }
        $arr=array();
        $ans=0;
        for ($h=0;$h<$d;$h++) {

            if ($str1[$h] != $str2[$h] && $str1map[$str1[$h]] == $str2map[$str2[$h]] && $str1map[$str1[$h]] == 1)
                $ans = 1;
        }
            if($ans==1)
             printf("%s\n","Yes");
         else
             printf("%s\n","No");

    }

}

solve();
?>

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";$d=0;$t=0;
    $t = trim(fgets($handle));
    for($i=0;$i<$t;$i++)
    {
        $arr=array();
        $d = trim(fgets($handle));

        $str1 = trim(fgets($handle));
        $str2 = trim(fgets($handle));
        $str1map=array();
        $str2map=array();
        for ($h=0;$h<$d;$h++)
        {
            if(isset($str1map[$str1[$h]])) {
                $str1map[$str1[$h]] = $str1map[$str1[$h]] + 1;
            }else
            {
                $str1map[$str1[$h]]=0;
            }
            if(isset($str2map[$str2[$h]])) {
                $str2map[$str2[$h]] = $str2map[$str2[$h]] + 1;
            }else
            {
                $str2map[$str2[$h]]=0;
            }

        }
        $arr=array();
        $ans=1;
        for ($h=0;$h<$d;$h++) {
            if ($str1[$h] != $str2[$h] && $str1map[$str1[$h]] == $str2map[$str2[$h]] && $str1map[$str1[$h]] >0)
                $ans = 1;
            else if($str1[$h]==$str2[$h]){
                $ans=1;
            }else
            {
                $ans=0;
            }
        }
            if($ans==1)
             printf("%s\n","Yes");
         else
             printf("%s\n","No");

    }

}

solve();
?>

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($local, "r");
    $s="";$d=0;$t=0;
    $t = trim(fgets($handle));
    for($i=0;$i<$t;$i++)
    {
        $arr=array();
        $d = trim(fgets($handle));

        $str1 = trim(fgets($handle));
        $str2 = trim(fgets($handle));

        $arr=array();
        $ans=1;
        for ($h=0;$h<$d;$h++) {
            if($str1[$h]!=$str2[$h])
            {
                $arr[]=$str1[$h].$str2[$h];
            }
        }

            if(sizeof($arr)==2 && $arr[0]==$arr[1])
             printf("%s\n","Yes");
         else
             printf("%s\n","No");

    }

}

solve();
?>


<?php

$t=trim(fgets(STDIN));
while($t--)
{
     list($n,$k)=explode(' ',trim(fgets(STDIN)));
     $a=explode(' ',trim(fgets(STDIN)));
     $ans=0;
     for($i=0;$i<$k;$i++)
     {
          $s=0;
          for($j=$i;$j<$n;$j+=$k)
               $s=max($s,$a[$j]);
          $ans+=$s;
     }
     echo $ans."\n";
}
?>

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

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

   list($n, $k) = IO::getArray();
   $a = IO::getArray();
     if($n > $k) {
        for ($i=0; $i<$k; $i++) {
           for ($j=$k+$i; $j<$n; $j +=$k) {
               if($a[$i] < $a[$j]) {
                    $a[$i] = $a[$j];
               }
           }
        }
     }

     $ans = 0;
     for ($i=0; $i<$k; $i++) {
        $ans = bcadd($ans, $a[$i]);
     }
     IO::pr($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;
    }
}