object B extends App {

  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val (ak, ar)    = scala.io.StdIn.readLine().split(" ").map(_.toInt).sorted.splitAt(k)
    val bk          = scala.io.StdIn.readLine().split(" ").map(_.toInt).sorted(Ordering.Int.reverse).take(k)

    val ans = ar.sum + (bk ++ ak).sorted(Ordering.Int.reverse).take(k).sum

    println(ans)
  }
}

//package codeforces.contests._1353

object TwoArraysAndSwaps {
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(n, k) = io.StdIn.readLine.split(" ").map(_.toInt)

      val a, b = io.StdIn.readLine.split(" ").map(_.toInt).sorted
      println {
        a.slice(k, n).sum + (a.slice(0, k) ++ b.slice(n - k, n)).sorted(Ordering.Int.reverse).take(k).sum
      }
    }
  }
}

import scala.io.StdIn.readLine

object B {

  def solution(n: Int, k: Int, a0: Seq[Int], b0: Seq[Int]): Int = {
    val a = a0.sorted.toArray
    val b = b0.sorted.reverse.toArray
    var i = 0
    while (i < k && a(i) < b(i)) {
      a(i) = b(i)
      i += 1
    }
    a.sum
  }

  def main(args: Array[String]): Unit = {
    for {_ <- 0 until readLine.toInt} {
      val Seq(n, k) = readLine.split(" ").toSeq.map(_.toInt)
      val a = readLine.split(" ").toSeq.map(_.toInt)
      val b = readLine.split(" ").toSeq.map(_.toInt)
      println(solution(n, k, a, b))
    }
  }
}

import java.io._
import java.util.StringTokenizer

import scala.math.max
import scala.math.min
import scala.reflect.ClassTag
import scala.collection.immutable._

object Main {
	def main(args: Array[String]): Unit = {
		try {
			val (in, out) =
				if (isOnlineJudge) {
					(
						new FastScanner(new InputStreamReader(System.in)),
						new PrintWriter(System.out)
					)
				} else {
					(
						new FastScanner(new FileReader(new File("problem.in"))),
						new PrintWriter(new File("problem.out"))
					)
				}
			new CF644(in, out).solve()
			out.flush()
			out.close()
		} catch {
			case e: IOException => e.printStackTrace()
		}
	}

	private[this] val isOnlineJudge = true

	class FastScanner(val streamReader: InputStreamReader) {
		private[this] val reader = new BufferedReader(streamReader, 32768)
		private[this] var tokenizer: StringTokenizer = _

		@inline private[this] final def next(): String = {
			while (tokenizer == null || !tokenizer.hasMoreTokens)
				tokenizer = new StringTokenizer(reader.readLine)
			tokenizer.nextToken
		}

		def nextInt(): Int = Integer.parseInt(next())

		def nextLong(): Long = java.lang.Long.parseLong(next())

		def nextChar(): Char = next().charAt(0)

		def ni(): Int = nextInt()

		def nl(): Long = nextLong()

		def nc(): Char = nextChar()

		def ns(): String = next()

		def ns(n: Int): Array[Char] = ns().toCharArray

		def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

		def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
			val A1, A2 = Array.ofDim[Int](n)
			REP(n) { i =>
				A1(i) = ni() + offset
				A2(i) = ni() + offset
			}
			(A1, A2)
		}

		def nm(n: Int, m: Int): Array[Array[Int]] = {
			val A = Array.ofDim[Int](n, m)
			REP(n) { i =>
				REP(m) { j =>
					A(i)(j) = ni()
				}
			}
			A
		}

		def nal(n: Int): Array[Long] = map(n)(_ => nl())

		def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
	}

	def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
		var i = offset
		val N = n + offset
		while (i < N) {
			f(i);
			i += 1
		}
	}

	def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
		var i = n - 1 + offset
		while (i >= offset) {
			f(i);
			i -= 1
		}
	}

	def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
		REP(to - from + 1, from)(f)
	}

	def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
		val res = Array.ofDim[A](n)
		REP(n)(i => res(i) = f(i + offset))
		res
	}

	def sumL(as: Array[Int]): Long = {
		var s = 0L
		REP(as.length)(i => s += as(i))
		s
	}

	def cumSum(as: Array[Int]): Array[Long] = {
		val cum = Array.ofDim[Long](as.length + 1)
		REP(as.length) { i =>
			cum(i + 1) = cum(i) + as(i)
		}
		cum
	}
}

class CF644 (fScanner: Main.FastScanner, out: java.io.PrintWriter) {

	import Main._
	import fScanner._

	// def solve(): Unit = {
	// 	val T = ni()
	// 	for(i <- 0 until T){
	// 	var ans : Int = 1000
	// 		val n = ni()
	// 		var list: List[Int] = List()
	// 		for(j <- 0 until n){
	// 			val cu:Int = ni()
	// 			for( x <- list)
	// 				ans = ans.min( ( cu - x ).max(x - cu) )
	// 			list = cu::	list
	// 		}
	// 		out.println(ans)
	// 	}
	// }

	def solve(): Unit ={
		val T = ni()
		for(i <- 0 until T){
			val n = ni()
			val k = ni()
			var A : Vector[Int] = Vector()
			var B : Vector[Int] = Vector()

			for(j <- 0 until n){
				val a = ni()
				A = A :+ a
			}
			for(j <- 0 until n){
				val b = ni()
				B = B :+ b
			}
			A = A.sortWith(_ < _)
			B = B.sortWith(_ > _)

			var j:Int = 0
			var ans:Int = 0
			// println(A, B)
			for( (p, q) <- (A zip B) ){
				// println(p, q)
				if(j < k){
					ans = ans + max(p, q)
				}
				else ans = ans + p

				j = j+1
 			}

 			out.println(ans)
		}
	}
}

import java.util

object ProblemB extends App {

  import java.io.{BufferedReader, InputStreamReader, PrintWriter}
  import java.util.StringTokenizer
  import scala.collection.mutable

  val in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)))
  val out = new PrintWriter(System.out)

  class FastScanner(val in: BufferedReader) {
    var st: StringTokenizer = _;

    def nextToken(): String = {
      while (st == null || !st.hasMoreTokens) {
        st = new StringTokenizer(in.readLine);
      }
      return st.nextToken();
    }

    def nextInt(): Integer = {
      Integer.parseInt(nextToken());
    }

    def nextLong(): Long = {
      nextToken().toLong;
    }

    def nextDouble(): Double = {
      nextToken().toDouble;
    }
  }

  val t = in.nextInt()

  for (_ <- 1 to t) {
    val m = in.nextInt()
    var k = in.nextInt()
    val a1 = new Array[Int](m)
    val a2 = new Array[Int](m)
    for (i <- 0 until m) {
      a1(i) = in.nextInt()
    }
    for (i <- 0 until m) {
      a2(i) = in.nextInt()
    }

    util.Arrays.sort(a1)
    util.Arrays.sort(a2)

    var i = 0

    while (i < m && k > 0 && a1(i) < a2(m - i - 1)) {
      a1(i) = a2(m - i - 1)
      i = i + 1
      k = k - 1
    }

    println(a1.sum)

  }

}

import java.io._
import java.util.StringTokenizer

import scala.math.max
import scala.math.min
import scala.reflect.ClassTag
import scala.collection.immutable._

object Main {
	def main(args: Array[String]): Unit = {
		try {
			val (in, out) =
				if (isOnlineJudge) {
					(
						new FastScanner(new InputStreamReader(System.in)),
						new PrintWriter(System.out)
					)
				} else {
					(
						new FastScanner(new FileReader(new File("problem.in"))),
						new PrintWriter(new File("problem.out"))
					)
				}
			new CF644(in, out).solve()
			out.flush()
			out.close()
		} catch {
			case e: IOException => e.printStackTrace()
		}
	}

	private[this] val isOnlineJudge = false

	class FastScanner(val streamReader: InputStreamReader) {
		private[this] val reader = new BufferedReader(streamReader, 32768)
		private[this] var tokenizer: StringTokenizer = _

		@inline private[this] final def next(): String = {
			while (tokenizer == null || !tokenizer.hasMoreTokens)
				tokenizer = new StringTokenizer(reader.readLine)
			tokenizer.nextToken
		}

		def nextInt(): Int = Integer.parseInt(next())

		def nextLong(): Long = java.lang.Long.parseLong(next())

		def nextChar(): Char = next().charAt(0)

		def ni(): Int = nextInt()

		def nl(): Long = nextLong()

		def nc(): Char = nextChar()

		def ns(): String = next()

		def ns(n: Int): Array[Char] = ns().toCharArray

		def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

		def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
			val A1, A2 = Array.ofDim[Int](n)
			REP(n) { i =>
				A1(i) = ni() + offset
				A2(i) = ni() + offset
			}
			(A1, A2)
		}

		def nm(n: Int, m: Int): Array[Array[Int]] = {
			val A = Array.ofDim[Int](n, m)
			REP(n) { i =>
				REP(m) { j =>
					A(i)(j) = ni()
				}
			}
			A
		}

		def nal(n: Int): Array[Long] = map(n)(_ => nl())

		def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
	}

	def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
		var i = offset
		val N = n + offset
		while (i < N) {
			f(i);
			i += 1
		}
	}

	def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
		var i = n - 1 + offset
		while (i >= offset) {
			f(i);
			i -= 1
		}
	}

	def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
		REP(to - from + 1, from)(f)
	}

	def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
		val res = Array.ofDim[A](n)
		REP(n)(i => res(i) = f(i + offset))
		res
	}

	def sumL(as: Array[Int]): Long = {
		var s = 0L
		REP(as.length)(i => s += as(i))
		s
	}

	def cumSum(as: Array[Int]): Array[Long] = {
		val cum = Array.ofDim[Long](as.length + 1)
		REP(as.length) { i =>
			cum(i + 1) = cum(i) + as(i)
		}
		cum
	}
}

class CF644 (fScanner: Main.FastScanner, out: java.io.PrintWriter) {

	import Main._
	import fScanner._

	// def solve(): Unit = {
	// 	val T = ni()
	// 	for(i <- 0 until T){
	// 	var ans : Int = 1000
	// 		val n = ni()
	// 		var list: List[Int] = List()
	// 		for(j <- 0 until n){
	// 			val cu:Int = ni()
	// 			for( x <- list)
	// 				ans = ans.min( ( cu - x ).max(x - cu) )
	// 			list = cu::	list
	// 		}
	// 		out.println(ans)
	// 	}
	// }

	def solve(): Unit ={
		val T = ni()
		for(i <- 0 until T){
			val n = ni()
			val k = ni()
			var A : Vector[Int] = Vector()
			var B : Vector[Int] = Vector()

			for(j <- 0 until n){
				val a = ni()
				A = A :+ a
			}
			for(j <- 0 until n){
				val b = ni()
				B = B :+ b
			}
			A = A.sortWith(_ < _)
			B = B.sortWith(_ > _)

			var j:Int = 0
			var ans:Int = 0
			// println(A, B)
			for( (p, q) <- (A zip B) ){
				// println(p, q)
				if(j < k){
					ans = ans + max(p, q)
				}
				else ans = ans + p

				j = j+1
 			}

 			out.println(ans)
		}
	}
}

object B extends App {

  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val (ak, ar)    = scala.io.StdIn.readLine().split(" ").map(_.toInt).sorted.splitAt(k)
    val bk          = scala.io.StdIn.readLine().split(" ").map(_.toInt).sorted(Ordering.Int.reverse).take(k)

    val bt  = bk.takeWhile(_ > ak.head)
    val at  = ak.drop(bt.length)
    val ans = ar.sum + bt.sum + at.sum

    println(ans)
  }
}


import io.StdIn._
import scala.collection.mutable._

object Solution extends App {
  var a = readLine()
  var b = readLine()

  var alen = a.length()
  var blen = b.length()

  if ( alen < blen ) {

    val temp = "0" * ( blen - alen )
    a = temp + a

  }
  if ( alen > blen ) {

    val temp = "0" * ( alen - blen )
    b = temp + b

  }

  if ( a > b ) {
    println ( ">" )
  }
  if ( a == b ) {
    println ( "=" )
  }
  if ( a < b ) {
    println ( "<" )
  }

}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val a = in.next().dropWhile(_ == '0')
  val b = in.next().dropWhile(_ == '0')
  if (a.length > b.length)
    println('>')
  else if (a.length < b.length)
    println('<')
  else {
    val f = a.zip(b).find(i => i._1 != i._2)
    if (f.isEmpty)
      println('=')
    else if (f.get._1 < f.get._2)
      println('<')
    else
      println('>')
  }
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val a = in.next().dropWhile(_ == '0')
  val b = in.next().dropWhile(_ == '0')
  if (a.length < b.length)
    println('>')
  else if (a.length < b.length)
    println('<')
  else {
    val f = a.zip(b).find(i => i._1 != i._2)
    if (f.isEmpty)
      println('=')
    else if (f.get._1 < f.get._1)
      println('<')
    else
      println('>')
  }
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val a = in.next().dropWhile(_ == '0')
  val b = in.next().dropWhile(_ == '0')
  if (a.length > b.length)
    println('>')
  else if (a.length < b.length)
    println('<')
  else {
    val f = a.zip(b).find(i => i._1 != i._2)
    if (f.isEmpty)
      println('=')
    else if (f.get._1 < f.get._1)
      println('<')
    else
      println('>')
  }
}


import java.io.FileOutputStream
import java.io.FileInputStream
import java.io.PrintStream

/**
  * Created by octavian on 16/01/2016.
  */
object GCode {

  def main (args: Array[String]) {
    //System.setIn(new FileInputStream("src/gcode.in"))
    //System.setOut(new PrintStream(new FileOutputStream("src/gcode.out")))
    val n = readInt()
    val nums: Array[String] = readLine().split(" ")
    println(product(n, nums))
  }

  def beautiful(nr: String): Boolean = {
    var ones = 0
    for(c <- nr) {
      if(c == '1') {
        ones += 1
      }
      if(c != '0' && c != '1') {
        return false
      }
    }
    return (ones <= 1)
  }

  //assumes - there is at least one element different from 0
  /*def relevantZeros(nr: String): Int = {
    for(i <- 0 until nr.length) {
      if(nr(i) != 0) {
        return i
      }
    }
    return 0
  }*/

  def product(n: Int, nums: Array[String]): String = {
      var result = Vector.empty[String]
      for(i <- 0 until n) {
          //println("checking " + nums(i))
          if(nums(i)(0) == '0') {
            return "0"
          }
          if(beautiful(nums(i)) && nums(i).length - 1 > 0) {
            result :+= "0" * (nums(i).length - 1)//relevantZeros(nums(i).reverse)
            //println("result is " + result.mkString(""))
          }
          else if(!beautiful(nums(i))) {
            result +:=nums(i)
          }
      }
      //println("result(0)(0) is " + result(0)(0))
      val strRep = result.mkString("")
      if(strRep.length == 0 || strRep(0) == '0') {
        result +:= "1"
      }
      return result.mkString("")
  }

}

// object Main
import java.io.{IOException, InputStream, PrintWriter}
import java.util.InputMismatchException

import scala.collection.mutable.ArrayBuffer

object Main {

    def solveCase(caseNo: Int, in: InputReader, out: PrintWriter): Unit = {
        val n = in.nextInt()
        var num = "1"
        var isZero = false
        var zeroCount = 0
        for (_ <- 1 to n) {
            val x = in.next()
            if (x == "0") {
                isZero = true
            } else if (x == "1" + "0" * (x.length - 1)) {
                zeroCount += x.length - 1
            } else {
                num = x
            }
        }
        if (isZero) {
            println(0)
        } else {
            println(num.toString + "0" * zeroCount)
        }

    }

    def solve(in: InputReader, out: PrintWriter): Unit = {
        solveCase(1, in, out)
//        val caseCount = in.nextInt()
//        for (caseNo <- 1 to caseCount) {
//            solveCase(caseNo, in, out)
//        }
    }

    def main(args: Array[String]) {
        val in = new InputReader(System.in)
        val out = new PrintWriter(System.out)

        solve(in, out)

        in.close()
        out.close()
    }
}

class InputReader(val inputStream: InputStream) {
    val buf = new Array[Byte](1 << 16)
    var curChar = 0
    var numChars = 0

    def read(): Int = {
        if (numChars == -1) {
            throw new InputMismatchException()
        }
        if (curChar >= numChars) {
            curChar = 0
            try {
                numChars = inputStream.read(buf)
            } catch {
                case _: IOException => throw new InputMismatchException()
            }
            if (numChars <= 0)
                return -1
        }
        curChar += 1
        buf(curChar - 1)
    }

    def peek(): Int = {
        if (numChars == -1) {
            return -1
        }
        if (curChar >= numChars) {
            curChar = 0
            try {
                numChars = inputStream.read(buf)
            } catch {
                case _: IOException => return -1
            }
            if (numChars <= 0)
                return -1
        }
        buf(curChar)
    }

    def isSpaceChar(c: Int): Boolean = c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1

    def nextInt(): Int = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        var sgn = 1
        if (c == '-') {
            sgn = -1
            c = read()
        }
        var res = 0
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException()
            res *= 10
            res += c & 15
            c = read()
        } while (!isSpaceChar(c))
        res * sgn
    }

    def nextLong(): Long = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        var sgn = 1
        if (c == '-') {
            sgn = -1
            c = read()
        }
        var res = 0l
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException()
            res *= 10
            res += c & 15
            c = read()
        } while (!isSpaceChar(c))
        res * sgn
    }

    def next(): String = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        val res = new StringBuilder()
        do {
            res += c.toChar
            c = read()
        } while (!isSpaceChar(c))
        res.toString()
    }

    def nextChar(): Char = {
        var c = read()
        while (isSpaceChar(c)) c = read()
        c.toChar
    }

    //noinspection AccessorLikeMethodIsEmptyParen
    def hasNext(): Boolean = {
        var value = peek()
        do {
            read()
            value = peek()
        } while (isSpaceChar(value) && value != -1)
        value != -1
    }

    def rawNextLine(): String = {
        val builder = new StringBuilder
        var c = read()
        while (c != '\n' && c != -1) {
            if (c != '\r')
                builder += c.toChar
            c = read()
        }
        builder.toString()
    }

    def nextLine(): String = {
        var s = rawNextLine()
        while (s.trim().length == 0) s = rawNextLine()
        s
    }

    def nextDouble(): Double = {
        next().toDouble
    }

    def close(): Unit = {
        inputStream.close()
    }
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(' ')
  if (data.contains("0"))
    println(0)
  else {
    val nonB = data.find(i =>
      i.head != '1' || !i.tail.forall(_ == '0')
    )
    val zeroCount = data.foldLeft(0) {
      case (acc, str) if nonB.contains(str) => acc
      case (acc, str) => acc + str.count(_ == '0')
    }

    println(nonB.getOrElse(1) + "0" * zeroCount)
  }
}

import java.io.InputStreamReader
import java.io.BufferedReader

/**
 * @author pvasilyev
 * @since 25 Jun 2016
 */
object B614 extends App {

  def isBeautiful(a: String): Boolean = {
    if ("0" equals a) {
      return true
    }
    val s = a
    if (s.charAt(0) != '1') {
      return false
    }
    for (i <- 1 until s.length) {
      if (s.charAt(i) != '0') {
        return false
      }
    }

    true
  }

  def solve() = {
    val reader = new BufferedReader(new InputStreamReader(System.in))
    val n = reader.readLine().toInt
    var nonBeautiful = ""
    var zeros = 0
    var isZero = false
    val aa: Array[String] = reader.readLine().split(" ")
    for (i <- 0 until n) {
      val a = aa(i)
      if (!isBeautiful(a)) {
        nonBeautiful = a
      } else {
        val z = a.length - 1
        if (z != 0) {
          zeros += z
        } else if ("0" equals a) {
          isZero = true
        }
      }
    }
    if (isZero) {
      println("0")
    } else if (!("" equals nonBeautiful)) {
      println(nonBeautiful + ("0" * zeros))
    } else {
      println("1" + ("0" * zeros))
    }
  }

  solve()

}

import scala.annotation.tailrec
import scala.collection.mutable
import scala.util._, control._
import scala.math.Ordering.Implicits._

object _614B extends CodeForcesApp {
  override type Result = String

  override def solve(scanner: Scanner) = {
    import scanner._
    val nums = List.fill(nextInt())(nextString())
    multiply(nums, mutable.StringBuilder.newBuilder, false)
  }

  @tailrec
  def multiply(nums: List[String], sb: mutable.StringBuilder, prefixFound: Boolean): String = nums match {
    case Nil => if (prefixFound) sb.toString() else 1 + sb.toString()
    case "0" :: _ => "0"
    case n :: ns if n.replace("0", "") == "1" => multiply(ns, sb.append(n.tail), prefixFound)
    case n :: ns => multiply(ns, sb.insert(0, n), true)
  }
}
/****************************[Ignore Template Below]****************************************/
abstract class CodeForcesApp {
  val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  val mod: Int = 1000000007
  type Result
  def solve(scanner: Scanner): Result
  def format(result: Result): String = result.toString
  def apply(scanner: Scanner): String = format(solve(scanner))
  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))
}
/*********************************[Scala Scanner]*******************************************/
import java.io._
import java.nio.file.{Files, Path}
import java.util.StringTokenizer

import scala.io.Codec

/**
 * Scala implementation of a faster java.util.Scanner
 * See: http://codeforces.com/blog/entry/21125
 * All next methods throw NoSuchElementException when !hasNext
 */
class Scanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {
  def this(reader: BufferedReader) = this(new LineNumberReader(reader))
  def this(reader: Reader) = this(new BufferedReader(reader))
  def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))
  def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))
  def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)
  def this(str: String) = this(new StringReader(str))

  val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null)

  private[this] val tokenizers = lines.map(new StringTokenizer(_)).filter(_.hasMoreTokens)
  private[this] var current: Option[StringTokenizer] = None

  @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {
    current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
    current
  }

  /**
   * Unlike Java's scanner which returns till end of current line, this actually returns the next line
   * @see line() if you want the Java behaviour
   */
  def nextLine(): String = {
    current = None   // reset
    lines.next()
  }
  def lineNumber: Int = reader.getLineNumber
  def line(): String = tokenizer().get.nextToken("\n\r")
  def nextString(): String = next()
  def nextChar(): Char = next().ensuring(_.length == 1).head
  def nextBoolean(): Boolean = next().toBoolean
  def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)
  def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)
  def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)
  def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)
  def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)
  def nextFloat(): Float = next().toFloat
  def nextDouble(): Double = next().toDouble
  def nextBigDecimal(): BigDecimal = BigDecimal(next())
  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty
  override def close() = reader.close()
}

import java.io.FileOutputStream
import java.io.FileInputStream
import java.io.PrintStream

/**
  * Created by octavian on 16/01/2016.
  */
object GCode {

  def main (args: Array[String]) {
    //System.setIn(new FileInputStream("src/gcode.in"))
    //System.setOut(new PrintStream(new FileOutputStream("src/gcode.out")))
    val n = readInt()
    val nums: Array[String] = readLine().split(" ")
    println(product(n, nums))
  }

  def beautiful(nr: String): Boolean = {
    var ones = 0
    for(c <- nr) {
      if(c == '1') {
        ones += 1
      }
      if(c != '0' && c != '1') {
        return false
      }
    }
    return (ones == 1)
  }

  //assumes - there is at least one element different from 0
  /*def relevantZeros(nr: String): Int = {
    for(i <- 0 until nr.length) {
      if(nr(i) != 0) {
        return i
      }
    }
    return 0
  }*/

  def product(n: Int, nums: Array[String]): String = {
      var result = Vector.empty[String]
      for(i <- 0 until n) {
          if(nums(i)(0) == '0') {
            return "0"
          }
          if(beautiful(nums(i)) && nums(i).length - 1 > 0) {
            result :+= "0" * (nums(i).length - 1)//relevantZeros(nums(i).reverse)
          }
          else if(!beautiful(nums(i))) {
            result +:=nums(i)
          }
      }
      return result.mkString("")
  }

}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(' ').map(_.toLong)
  println(data.foldLeft(0l){case (a, e) => a * e})
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(' ')
  if (data.contains("0"))
    println(0)
  else {
    val nonB = data.find(i =>
      i.head != '1' || i.tail.exists(_ == '0')
    )
    val zeroCount = data.foldLeft(0) {
      case (acc, str) if nonB.contains(str) => acc
      case (acc, str) => acc + str.count(_ == '0')
    }

    println(nonB.getOrElse(1) + "0" * zeroCount)
  }
}

import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(' ').map(_.toLong)
  println(data.product)
}

import scala.annotation.tailrec
import scala.collection.mutable
import scala.util._, control._
import scala.math.Ordering.Implicits._

object _614B extends CodeForcesApp {
  override type Result = String

  override def solve(scanner: Scanner) = {
    import scanner._
    val nums = List.fill(nextInt())(nextString())
    multiply(nums, mutable.StringBuilder.newBuilder)
  }

  @tailrec
  def multiply(nums: List[String], sb: mutable.StringBuilder): String = nums match {
    case Nil => sb.toString()
    case "0" :: _ => "0"
    case n :: ns if n.replace("0", "") == "1" => multiply(ns, sb.append(n.tail))
    case n :: ns => multiply(ns, sb.insert(0, n))
  }
}
/****************************[Ignore Template Below]****************************************/
abstract class CodeForcesApp {
  val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  val mod: Int = 1000000007
  type Result
  def solve(scanner: Scanner): Result
  def format(result: Result): String = result.toString
  def apply(scanner: Scanner): String = format(solve(scanner))
  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))
}
/*********************************[Scala Scanner]*******************************************/
import java.io._
import java.nio.file.{Files, Path}
import java.util.StringTokenizer

import scala.io.Codec

/**
 * Scala implementation of a faster java.util.Scanner
 * See: http://codeforces.com/blog/entry/21125
 * All next methods throw NoSuchElementException when !hasNext
 */
class Scanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {
  def this(reader: BufferedReader) = this(new LineNumberReader(reader))
  def this(reader: Reader) = this(new BufferedReader(reader))
  def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))
  def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))
  def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)
  def this(str: String) = this(new StringReader(str))

  val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null)

  private[this] val tokenizers = lines.map(new StringTokenizer(_)).filter(_.hasMoreTokens)
  private[this] var current: Option[StringTokenizer] = None

  @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {
    current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
    current
  }

  /**
   * Unlike Java's scanner which returns till end of current line, this actually returns the next line
   * @see line() if you want the Java behaviour
   */
  def nextLine(): String = {
    current = None   // reset
    lines.next()
  }
  def lineNumber: Int = reader.getLineNumber
  def line(): String = tokenizer().get.nextToken("\n\r")
  def nextString(): String = next()
  def nextChar(): Char = next().ensuring(_.length == 1).head
  def nextBoolean(): Boolean = next().toBoolean
  def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)
  def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)
  def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)
  def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)
  def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)
  def nextFloat(): Float = next().toFloat
  def nextDouble(): Double = next().toDouble
  def nextBigDecimal(): BigDecimal = BigDecimal(next())
  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty
  override def close() = reader.close()
}


object DefiningMacros extends App {
  sealed trait Term
  sealed trait Expr

  case object LeftParen extends Term
  case object RightParen extends Term
  case class Operator(op: Char) extends Term

  case class Number(n: Int) extends Term with Expr
  case class Var(name: String) extends Term with Expr

  case class Paren(sub: Expr) extends Expr
  case class BinOp(op: Operator, left: Expr, right: Expr) extends Expr

  object Term {
    def apply(s: String): Term = s match {
      case "(" => LeftParen
      case ")" => RightParen
      case _ if "+-*/" contains s(0) => Operator(s(0))
      case _ if Character.isLetter(s(0)) => Var(s)
      case _ if Character.isDigit(s(0)) => Number(s.toInt)
    }
  }

  object Expr {
    val preds = List(Character.isLetter _, Character.isDigit _)

    def getPriority(expr: Expr): Int = expr match {
      case Paren(_) => 1000
      case BinOp(op, _, _) => getPriority(op)
      case t: Term => getPriority(t: Term)
    }

    def getPriority(term: Term): Int = term match {
      case Number(_) => 1000
      case Var(_) => 1000
      case Operator(op) =>
        if (op == '+' || op == '-') 1
        else 2
      case _ => -1
    }

    def tokenize(expr: String): List[String] = {
      def loop(s: String, res: List[String]): List[String] = {
        if (s.length == 0) res.reverse
        else {
          val c = s(0)
          val pred = preds.find(_(c))
          if (pred == None)
            loop(s.drop(1), c.toString :: res)
          else {
            val (prefix, rest) = s.span(pred.get)
            loop(rest, prefix.mkString :: res)
          }
        }
      }
      loop(expr, Nil)
    }

    def toExpr(terms: List[Term]): Expr = {
      if (terms.length == 1) return terms(0).asInstanceOf[Expr]

      val levels = terms.scanLeft(0) { (lev: Int, t: Term) =>
        t match {
          case LeftParen => lev + 1
          case RightParen => lev - 1
          case _ => lev
        }
      }
      val pris = terms.map(getPriority _)
      val candidates = terms.zipWithIndex.zip(levels.zip(pris)).filter{
        case ((Operator(c), _), (0, _)) => true
        case _ => false
      }

      if (candidates.isEmpty)
        Paren(toExpr(terms.slice(1, terms.length - 1)))
      else {
        val spix = candidates.minBy {
          case ((_, i), (_, p)) => (p, -i)
        }._1._2
        val (pre, suf) = terms.splitAt(spix)
        val (l, rt, r) = (pre, suf.head, suf.tail)
        BinOp(rt.asInstanceOf[Operator], toExpr(l), toExpr(r))
      }
    }

    def parse(expr: String): Expr = {
      val terms = tokenize(expr).map(Term.apply _)
      toExpr(terms)
    }
  }

  val mem = collection.mutable.Map[(String, Int, Char), Boolean]()

  def check(macros: Map[String, Expr], expr: Expr, parentPri: Int, parentOp: Char): Boolean = {
    val thisPri = Expr.getPriority(expr)
    expr match {
      case Var(name) if macros contains name =>
        val mexpr = macros(name)
        if (parentPri > Expr.getPriority(mexpr) ||
            parentPri == Expr.getPriority(mexpr) && (parentOp == '-' || parentOp == '/')) false
        else {
          if (!(mem contains (name, parentPri, parentOp)))
            mem((name, parentPri, parentOp)) = check(macros, mexpr, parentPri, parentOp)
          mem(name, parentPri, parentOp)
        }
      case BinOp(Operator(op), l, r) =>
        check(macros, l, thisPri, '?') && check(macros, r, thisPri, op)
      case Paren(sub) => check(macros, sub, -1, '?')
      case _ => true
    }
  }

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  val macros = Map() ++ (for ((k, v) <- defs) yield k -> Expr.parse(v))
  val expr = Expr.parse(inputExpr)

//  println(macros)
//  println(expr)

  println(if (check(macros, expr, -1, '?')) "OK" else "Suspicious")
}

object P7E {
    import io.StdIn._

    val m = collection.mutable.Map[String, Int]().withDefaultValue(0)

    /* import util.parsing.combinator._
    object ExpParsers extends JavaTokenParsers {
        val factor = wholeNumber ^^^ 0 | ident ^^ m | paren
        val term = chainl1(factor, ("[*" + "/]").r ^^ {
            case "*" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 2) 1 else 3
            case "/" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 1) 1 else 3
        })
        val expr = chainl1(term, "[+-]".r ^^ {
            case "+" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 3) 2 else 3
            case "-" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 2) 2 else 3
        })
        val paren:Parser[Int] = "(" ~> expr <~ ")" ^^ {
            case 3 => 3
            case _ => 0
        }
        def apply(s:String) = parseAll(expr, s).get
    } */

    object ExpParsers {
        import util.matching._
        case class StringSlice(a:String, i:Int) extends CharSequence {
            def charAt(n:Int) = a(i + n)
            def length = a.size - i
            def subSequence(n1:Int, n2:Int) = a.substring(i + n1, i + n2)
            def from(n:Int) = StringSlice(a, i + n)
        }
        val re1 = " *([A-Za-z0-9_]+)".r
        val re2 = (" *([/" + "*])").r
        val re3 = " *([+-])".r
        val re4 = " *\\(".r
        val re5 = " *\\)".r
        def parseFactor(a:StringSlice):(StringSlice, Int) = {
            re1.findPrefixMatchOf(a) match {
                case Some(m1) => (a.from(m1.end), m(m1.group(1)))
                case None => parseParen(a)
            }
        }
        def parseTerm(a:StringSlice) = {
            def parse1(a1:StringSlice, r1:Int):(StringSlice, Int) = {
                re2.findPrefixMatchOf(a1) match {
                    case Some(m1) => parseFactor(a1.from(m1.end)) match {
                        case (a2, r2) if m1.group(1) == "*" =>
                            parse1(a2, if (r1 < 2 && r2 < 2) 1 else 3)
                        case (a2, r2) if m1.group(1) == "/" =>
                            parse1(a2, if (r1 < 2 && r2 < 1) 1 else 3)
                    }
                    case None => (a1, r1)
                }
            }
            parseFactor(a) match { case (a1, r1) => parse1(a1, r1) }
        }
        def parseExpr(a:StringSlice) = {
            def parse1(a1:StringSlice, r1:Int):(StringSlice, Int) = {
                re3.findPrefixMatchOf(a1) match {
                    case Some(m1) => parseTerm(a1.from(m1.end)) match {
                        case (a2, r2) if m1.group(1) == "+" =>
                            parse1(a2, if (r1 < 3 && r2 < 3) 2 else 3)
                        case (a2, r2) if m1.group(1) == "-" =>
                            parse1(a2, if (r1 < 3 && r2 < 2) 2 else 3)
                    }
                    case None => (a1, r1)
                }
            }
            parseTerm(a) match { case (a1, r1) => parse1(a1, r1) }
        }
        def parseParen(a:StringSlice) = {
            re4.findPrefixMatchOf(a) match {
                case Some(m1) => parseExpr(a.from(m1.end)) match {
                    case (a1, r1) => re5.findPrefixMatchOf(a1) match {
                        case Some(m2) =>
                            (a1.from(m2.end), if (r1 < 3) 0 else 3)
                    }
                }
            }
        }
        def apply(s:String) = parseExpr(StringSlice(s, 0))._2
    }

    def main(args : Array[String]) {
        val define = " *# *define +(.*?) +(.*)".r
        for (i <- 1 to readInt) {
            val define(name, exp) = readLine
            m(name) = ExpParsers(exp)
        }
        println(if (ExpParsers(readLine) == 3) "Suspicious" else "OK")
    }
}

object DefiningMacros extends App {

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  println("GA")
  println(defs)
  println(inputExpr)
}

object DefiningMacros extends App {
  sealed trait Term
  sealed trait Expr

  case object LeftParen extends Term
  case object RightParen extends Term
  case class Operator(op: Char) extends Term

  case class Number(n: Int) extends Term with Expr
  case class Var(name: String) extends Term with Expr

  case class Paren(sub: Expr) extends Expr
  case class BinOp(op: Operator, left: Expr, right: Expr) extends Expr

  object Term {
    def apply(s: String): Term = s match {
      case "(" => LeftParen
      case ")" => RightParen
      case _ if "+-*/" contains s(0) => Operator(s(0))
      case _ if Character.isLetter(s(0)) => Var(s)
      case _ if Character.isDigit(s(0)) => Number(s.toInt)
    }
  }

  object Expr {
    val preds = List(Character.isLetter _, Character.isDigit _)

    def tokenize(expr: String): List[String] = {
      def loop(s: String, res: List[String]): List[String] = {
        if (s.length == 0) res.reverse
        else {
          val c = s(0)
          val pred = preds.find(_(c))
          if (pred == None)
            loop(s.drop(1), c.toString :: res)
          else {
            val (prefix, rest) = s.span(pred.get)
            loop(rest, prefix.mkString :: res)
          }
        }
      }
      loop(expr, Nil)
    }

    def toExpr(terms: List[Term]): Expr = {
      if (terms.length == 1) return terms(0).asInstanceOf[Expr]

      val levels = terms.scanLeft(0) { (lev: Int, t: Term) =>
        t match {
          case LeftParen => lev + 1
          case RightParen => lev - 1
          case _ => lev
        }
      }
      val spix = terms.zipWithIndex.zip(levels).find{
        case ((Operator(c), i), l) => l == 0
        case _ => false
      }

      if (spix == None) {
        Paren(toExpr(terms.slice(1, terms.length - 1)))
      }
      else {
        val (pre, suf) = terms.splitAt(spix.get._1._2)
        val (l, rt, r) = (pre, suf.head, suf.tail)
        BinOp(rt.asInstanceOf[Operator], toExpr(l), toExpr(r))
      }
    }

    def parse(expr: String): Expr = {
      val terms = tokenize(expr).map(Term.apply _)
      toExpr(terms)
    }
  }

  def getPriority(expr: Expr) = expr match {
    case Paren(_) => 0
    case Number(_) => 1000
    case BinOp(Operator(op), _, _) =>
      if (op == '+' || op == '-') 1
      else 2
    case Var(_) => 1000
  }

  def check(macros: Map[String, Expr], expr: Expr, parentPri: Int, parentOp: Char): Boolean = {
    val thisPri = getPriority(expr)
    expr match {
      case Var(name) if macros contains name =>
        val mexpr = macros(name)
        if (parentPri > getPriority(mexpr) ||
            parentPri == getPriority(mexpr) && (parentOp == '-' || parentOp == '/')) {
/*          println("this expr = " + expr)
          println("parent op = " + parentOp)
          println("parent pri = " + parentPri)
          println("this pri = " + getPriority(mexpr))*/
          false
        }
        else check(macros, mexpr, parentPri, parentOp)
      case BinOp(Operator(op), l, r) =>
        check(macros, l, thisPri, '?') && check(macros, r, thisPri, op)
      case Paren(sub) => check(macros, sub, thisPri, '?')
      case _ => true
    }
  }

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  val macros = (Map() ++ defs).mapValues(Expr.parse _)
  val expr = Expr.parse(inputExpr)

  println(if (check(macros, expr, -1, '?')) "OK" else "Suspicious")
}

object DefiningMacros extends App {
  sealed trait Term
  sealed trait Expr

  case object LeftParen extends Term
  case object RightParen extends Term
  case class Operator(op: Char) extends Term

  case class Number(n: Int) extends Term with Expr
  case class Var(name: String) extends Term with Expr

  case class Paren(sub: Expr) extends Expr
  case class BinOp(op: Operator, left: Expr, right: Expr) extends Expr

  object Term {
    def apply(s: String): Term = s match {
      case "(" => LeftParen
      case ")" => RightParen
      case _ if "+-*/" contains s(0) => Operator(s(0))
      case _ if Character.isLetter(s(0)) => Var(s)
      case _ if Character.isDigit(s(0)) => Number(s.toInt)
    }
  }

  object Expr {
    val preds = List(Character.isLetter _, Character.isDigit _)

    def tokenize(expr: String): List[String] = {
      def loop(s: String, res: List[String]): List[String] = {
        if (s.length == 0) res.reverse
        else {
          val c = s(0)
          val pred = preds.find(_(c))
          if (pred == None)
            loop(s.drop(1), c.toString :: res)
          else {
            val (prefix, rest) = s.span(pred.get)
            loop(rest, prefix.mkString :: res)
          }
        }
      }
      loop(expr, Nil)
    }

    def toExpr(terms: List[Term]): Expr = {
      if (terms.length == 1) return terms(0).asInstanceOf[Expr]

      val levels = terms.scanLeft(0) { (lev: Int, t: Term) =>
        t match {
          case LeftParen => lev + 1
          case RightParen => lev - 1
          case _ => lev
        }
      }
      val spix = terms.zipWithIndex.zip(levels).find{
        case ((Operator(c), i), l) => l == 0
        case _ => false
      }

      if (spix == None) {
        Paren(toExpr(terms.slice(1, terms.length - 1)))
      }
      else {
        val (pre, suf) = terms.splitAt(spix.get._1._2)
        val (l, rt, r) = (pre, suf.head, suf.tail)
        BinOp(rt.asInstanceOf[Operator], toExpr(l), toExpr(r))
      }
    }

    def parse(expr: String): Expr = {
      val terms = tokenize(expr).map(Term.apply _)
      toExpr(terms)
    }
  }

  def getPriority(expr: Expr) = expr match {
    case Paren(_) => 1000
    case Number(_) => 1000
    case BinOp(Operator(op), _, _) =>
      if (op == '+' || op == '-') 1
      else 2
    case Var(_) => 1000
  }

  def check(macros: Map[String, Expr], expr: Expr, parentPri: Int, parentOp: Char): Boolean = {
    val thisPri = getPriority(expr)
    expr match {
      case Var(name) if macros contains name =>
        val mexpr = macros(name)
        if (parentPri > getPriority(mexpr) ||
            parentPri == getPriority(mexpr) && (parentOp == '-' || parentOp == '/')) false
        else check(macros, mexpr, parentPri, parentOp)
      case BinOp(Operator(op), l, r) =>
        check(macros, l, thisPri, '?') && check(macros, r, thisPri, op)
      case Paren(sub) => check(macros, sub, thisPri, '?')
      case _ => true
    }
  }

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  val macros = (Map() ++ defs).mapValues(Expr.parse _)
  val expr = Expr.parse(inputExpr)

  println(if (check(macros, expr, -1, '?')) "OK" else "Suspicious")
}

object DefiningMacros extends App {
  sealed trait Term
  sealed trait Expr

  case object LeftParen extends Term
  case object RightParen extends Term
  case class Operator(op: Char) extends Term

  case class Number(n: Int) extends Term with Expr
  case class Var(name: String) extends Term with Expr

  case class Paren(sub: Expr) extends Expr
  case class BinOp(op: Operator, left: Expr, right: Expr) extends Expr

  object Term {
    def apply(s: String): Term = s match {
      case "(" => LeftParen
      case ")" => RightParen
      case _ if "+-*/" contains s(0) => Operator(s(0))
      case _ if Character.isLetter(s(0)) => Var(s)
      case _ if Character.isDigit(s(0)) => Number(s.toInt)
    }
  }

  object Expr {
    val preds = List(Character.isLetter _, Character.isDigit _)

    def tokenize(expr: String): List[String] = {
      def loop(s: String, res: List[String]): List[String] = {
        if (s.length == 0) res.reverse
        else {
          val c = s(0)
          val pred = preds.find(_(c))
          if (pred == None)
            loop(s.drop(1), c.toString :: res)
          else {
            val (prefix, rest) = s.span(pred.get)
            loop(rest, prefix.mkString :: res)
          }
        }
      }
      loop(expr, Nil)
    }

    def toExpr(terms: List[Term]): Expr = {
      if (terms.length == 1) return terms(0).asInstanceOf[Expr]

      val levels = terms.scanLeft(0) { (lev: Int, t: Term) =>
        t match {
          case LeftParen => lev + 1
          case RightParen => lev - 1
          case _ => lev
        }
      }
      val spix = terms.zipWithIndex.zip(levels).find{
        case ((Operator(c), i), l) => l == 0
        case _ => false
      }

      if (spix == None) {
        Paren(toExpr(terms.slice(1, terms.length - 1)))
      }
      else {
        val (pre, suf) = terms.splitAt(spix.get._1._2)
        val (l, rt, r) = (pre, suf.head, suf.tail)
        BinOp(rt.asInstanceOf[Operator], toExpr(l), toExpr(r))
      }
    }

    def parse(expr: String): Expr = {
      val terms = tokenize(expr).map(Term.apply _)
      toExpr(terms)
    }
  }

  def getPriority(expr: Expr) = expr match {
    case Paren(_) => 1000
    case Number(_) => 1000
    case BinOp(Operator(op), _, _) =>
      if (op == '+' || op == '-') 1
      else 2
    case Var(_) => 1000
  }

  def check(macros: Map[String, Expr], expr: Expr, parentPri: Int, parentOp: Char): Boolean = {
    val thisPri = getPriority(expr)
    expr match {
      case Var(name) if macros contains name =>
        val mexpr = macros(name)
        if (parentPri > getPriority(mexpr) ||
            parentPri == getPriority(mexpr) && (parentOp == '-' || parentOp == '/')) {
          println("this expr = " + expr)
          println("parent op = " + parentOp)
          println("parent pri = " + parentPri)
          println("this pri = " + getPriority(mexpr))
          false
        }
        else check(macros, mexpr, parentPri, parentOp)
      case BinOp(Operator(op), l, r) =>
        check(macros, l, thisPri, '?') && check(macros, r, thisPri, op)
      case Paren(sub) => check(macros, sub, -1, '?')
      case _ => true
    }
  }

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  val macros = (Map() ++ defs).mapValues(Expr.parse _)
  val expr = Expr.parse(inputExpr)

  println(if (check(macros, expr, -1, '?')) "OK" else "Suspicious")
}

object DefiningMacros extends App {
  sealed trait Term
  sealed trait Expr

  case object LeftParen extends Term
  case object RightParen extends Term
  case class Operator(op: Char) extends Term

  case class Number(n: Int) extends Term with Expr
  case class Var(name: String) extends Term with Expr

  case class Paren(sub: Expr) extends Expr
  case class BinOp(op: Operator, left: Expr, right: Expr) extends Expr

  object Term {
    def apply(s: String): Term = s match {
      case "(" => LeftParen
      case ")" => RightParen
      case _ if "+-*/" contains s(0) => Operator(s(0))
      case _ if Character.isLetter(s(0)) => Var(s)
      case _ if Character.isDigit(s(0)) => Number(s.toInt)
    }
  }

  object Expr {
    val preds = List(Character.isLetter _, Character.isDigit _)

    def tokenize(expr: String): List[String] = {
      def loop(s: String, res: List[String]): List[String] = {
        if (s.length == 0) res.reverse
        else {
          val c = s(0)
          val pred = preds.find(_(c))
          if (pred == None)
            loop(s.drop(1), c.toString :: res)
          else {
            val (prefix, rest) = s.span(pred.get)
            loop(rest, prefix.mkString :: res)
          }
        }
      }
      loop(expr, Nil)
    }

    def toExpr(terms: List[Term]): Expr = {
      if (terms.length == 1) return terms(0).asInstanceOf[Expr]

      val levels = terms.scanLeft(0) { (lev: Int, t: Term) =>
        t match {
          case LeftParen => lev + 1
          case RightParen => lev - 1
          case _ => lev
        }
      }
      val spix = terms.zipWithIndex.zip(levels).find{
        case ((Operator(c), i), l) => l == 0
        case _ => false
      }

      if (spix == None) {
        Paren(toExpr(terms.slice(1, terms.length - 1)))
      }
      else {
        val (pre, suf) = terms.splitAt(spix.get._1._2)
        val (l, rt, r) = (pre, suf.head, suf.tail)
        BinOp(rt.asInstanceOf[Operator], toExpr(l), toExpr(r))
      }
    }

    def parse(expr: String): Expr = {
      val terms = tokenize(expr).map(Term.apply _)
      toExpr(terms)
    }
  }

  def getPriority(expr: Expr) = expr match {
    case Paren(_) => 1000
    case Number(_) => 1000
    case BinOp(Operator(op), _, _) =>
      if (op == '+' || op == '-') 1
      else 2
    case Var(_) => -1
  }

  def check(macros: Map[String, Expr], expr: Expr, parentPri: Int, parentOp: Char): Boolean = {
    val thisPri = getPriority(expr)
    expr match {
      case Var(name) if macros contains name =>
        val mexpr = macros(name)
        if (parentPri > getPriority(mexpr) ||
            parentPri == getPriority(mexpr) && (parentOp == '-' || parentOp == '/')) false
        else check(macros, mexpr, parentPri, parentOp)
      case BinOp(Operator(op), l, r) =>
        check(macros, l, thisPri, '?') && check(macros, r, thisPri, op)
      case Paren(sub) => check(macros, sub, thisPri, '?')
      case _ => true
    }
  }

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  val macros = (Map() ++ defs).mapValues(Expr.parse _)
  val expr = Expr.parse(inputExpr)

  println(if (check(macros, expr, -1, '?')) "OK" else "Suspicious")
}

object DefiningMacros extends App {
  sealed trait Term
  sealed trait Expr

  case object LeftParen extends Term
  case object RightParen extends Term
  case class Operator(op: Char) extends Term

  case class Number(n: Int) extends Term with Expr
  case class Var(name: String) extends Term with Expr

  case class Paren(sub: Expr) extends Expr
  case class BinOp(op: Operator, left: Expr, right: Expr) extends Expr

  object Term {
    def apply(s: String): Term = s match {
      case "(" => LeftParen
      case ")" => RightParen
      case _ if "+-*/" contains s(0) => Operator(s(0))
      case _ if Character.isLetter(s(0)) => Var(s)
      case _ if Character.isDigit(s(0)) => Number(s.toInt)
    }
  }

  object Expr {
    val preds = List(Character.isLetter _, Character.isDigit _)

    def tokenize(expr: String): List[String] = {
      def loop(s: String, res: List[String]): List[String] = {
        if (s.length == 0) res.reverse
        else {
          val c = s(0)
          val pred = preds.find(_(c))
          if (pred == None)
            loop(s.drop(1), c.toString :: res)
          else {
            val (prefix, rest) = s.span(pred.get)
            loop(rest, prefix.mkString :: res)
          }
        }
      }
      loop(expr, Nil)
    }

    def toExpr(terms: List[Term]): Expr = {
      if (terms.length == 1) return terms(0).asInstanceOf[Expr]

      val levels = terms.scanLeft(0) { (lev: Int, t: Term) =>
        t match {
          case LeftParen => lev + 1
          case RightParen => lev - 1
          case _ => lev
        }
      }
      val spix = terms.zipWithIndex.zip(levels).find{
        case ((Operator(c), i), l) => l == 0
        case _ => false
      }

      if (spix == None) {
        Paren(toExpr(terms.slice(1, terms.length - 1)))
      }
      else {
        val (pre, suf) = terms.splitAt(spix.get._1._2)
        val (l, rt, r) = (pre, suf.head, suf.tail)
        BinOp(rt.asInstanceOf[Operator], toExpr(l), toExpr(r))
      }
    }

    def parse(expr: String): Expr = {
      val terms = tokenize(expr).map(Term.apply _)
      toExpr(terms)
    }
  }

  def getPriority(expr: Expr) = expr match {
    case Paren(_) => 1000
    case Number(_) => 1000
    case BinOp(Operator(op), _, _) =>
      if (op == '+' || op == '-') 1
      else 2
    case Var(_) => 1000
  }

  def check(macros: Map[String, Expr], expr: Expr, parentPri: Int, parentOp: Char): Boolean = {
    val thisPri = getPriority(expr)
    expr match {
      case Var(name) if macros contains name =>
        val mexpr = macros(name)
        if (parentPri > getPriority(mexpr) ||
            parentPri == getPriority(mexpr) && (parentOp == '-' || parentOp == '/')) {
/*          println("this expr = " + expr)
          println("parent op = " + parentOp)
          println("parent pri = " + parentPri)
          println("this pri = " + getPriority(mexpr))*/
          false
        }
        else check(macros, mexpr, parentPri, parentOp)
      case BinOp(Operator(op), l, r) =>
        check(macros, l, thisPri, '?') && check(macros, r, thisPri, op)
      case Paren(sub) => check(macros, sub, -1, '?')
      case _ => true
    }
  }

  import java.io._

  val re = new BufferedReader(new InputStreamReader(System.in))
  val n = re.readLine.toInt
  val defs = for (i <- 0 until n) yield {
    val l = re.readLine.trim
    val pairs = l.substring(l.indexOf("define") + 6).trim
    val ss = pairs.split(" ", 2)
    ss(0) -> ss(1).replace(" ", "")
  }
  val inputExpr = re.readLine.replace(" ", "")

  val macros = (Map() ++ defs).mapValues(Expr.parse _)
  val expr = Expr.parse(inputExpr)

  println(if (check(macros, expr, -1, '?')) "OK" else "Suspicious")
}

object P7E {
    import io.StdIn._

    val m = collection.mutable.Map[String, Int]().withDefaultValue(0)

    /* import util.parsing.combinator._
    object ExpParsers extends JavaTokenParsers {
        val factor = wholeNumber ^^^ 0 | ident ^^ m | paren
        val term = chainl1(factor, ("[*" + "/]").r ^^ {
            case "*" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 2) 1 else 3
            case "/" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 1) 1 else 3
        })
        val expr = chainl1(term, "[+-]".r ^^ {
            case "+" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 3) 2 else 3
            case "-" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 2) 2 else 3
        })
        val paren:Parser[Int] = "(" ~> expr <~ ")" ^^ {
            case 3 => 3
            case _ => 0
        }
        def apply(s:String) = parseAll(expr, s).get
    } */

    object ExpParsers {
        import util.matching._
        case class StringSlice(a:String, i:Int) extends CharSequence {
            def charAt(n:Int) = a(i + n)
            def length = a.size - i
            def subSequence(n1:Int, n2:Int) = a.substring(i + n1, i + n2)
            def from(n:Int) = StringSlice(a, i + n)
        }
        val re1 = " *([A-Za-z0-9_]+)".r
        val re2 = (" *([/" + "*])").r
        val re3 = " *([+-])".r
        val re4 = " *\\(".r
        val re5 = " *\\)".r
        def parseFactor(a:StringSlice):(StringSlice, Int) = {
            re1.findPrefixMatchOf(a) match {
                case Some(m1) => (a.from(m1.end), m(m1.group(1)))
                case None => parseParen(a)
            }
        }
        def parseTerm(a:StringSlice) = {
            def parse1(a1:StringSlice, r1:Int):(StringSlice, Int) = {
                re2.findPrefixMatchOf(a1) match {
                    case Some(m1) => parseFactor(a1.from(m1.end)) match {
                        case (a2, r2) if m1.group(1) == "*" =>
                            parse1(a2, if (r1 < 3 && r2 < 2) 1 else 3)
                        case (a2, r2) if m1.group(1) == "/" =>
                            parse1(a2, if (r1 < 3 && r2 < 1) 1 else 3)
                    }
                    case None => (a1, r1)
                }
            }
            parseFactor(a) match { case (a1, r1) => parse1(a1, r1) }
        }
        def parseExpr(a:StringSlice) = {
            def parse1(a1:StringSlice, r1:Int):(StringSlice, Int) = {
                re3.findPrefixMatchOf(a1) match {
                    case Some(m1) => parseTerm(a1.from(m1.end)) match {
                        case (a2, r2) if m1.group(1) == "+" =>
                            parse1(a2, if (r1 < 3 && r2 < 3) 2 else 3)
                        case (a2, r2) if m1.group(1) == "-" =>
                            parse1(a2, if (r1 < 3 && r2 < 2) 2 else 3)
                    }
                    case None => (a1, r1)
                }
            }
            parseTerm(a) match { case (a1, r1) => parse1(a1, r1) }
        }
        def parseParen(a:StringSlice) = {
            re4.findPrefixMatchOf(a) match {
                case Some(m1) => parseExpr(a.from(m1.end)) match {
                    case (a1, r1) => re5.findPrefixMatchOf(a1) match {
                        case Some(m2) =>
                            (a1.from(m2.end), if (r1 < 3) 0 else 3)
                    }
                }
            }
        }
        def apply(s:String) = parseExpr(StringSlice(s, 0))._2
    }

    def main(args : Array[String]) {
        val define = " *# *define *(.*?) *(.*)".r
        for (i <- 1 to readInt) {
            val define(name, exp) = readLine
            m(name) = ExpParsers(exp)
        }
        println(if (ExpParsers(readLine) == 3) "Suspicious" else "OK")
    }
}

object P7E {
    import io.StdIn._

    val m = collection.mutable.Map[String, Int]().withDefaultValue(0)

    /* import util.parsing.combinator._
    object ExpParsers extends JavaTokenParsers {
        val factor = wholeNumber ^^^ 0 | ident ^^ m | paren
        val term = chainl1(factor, ("[*" + "/]").r ^^ {
            case "*" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 2) 1 else 3
            case "/" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 1) 1 else 3
        })
        val expr = chainl1(term, "[+-]".r ^^ {
            case "+" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 3) 2 else 3
            case "-" => (a1:Int, a2:Int) => if (a1 < 3 && a2 < 2) 2 else 3
        })
        val paren:Parser[Int] = "(" ~> expr <~ ")" ^^ {
            case 3 => 3
            case _ => 0
        }
        def apply(s:String) = parseAll(expr, s).get
    } */

    object ExpParsers {
        import util.matching._
        case class StringSlice(a:String, i:Int) extends CharSequence {
            def charAt(n:Int) = a(i + n)
            def length = a.size - i
            def subSequence(n1:Int, n2:Int) = a.substring(i + n1, i + n2)
            def from(n:Int) = StringSlice(a, i + n)
        }
        val re1 = " *([A-Za-z0-9_]+)".r
        val re2 = (" *([/" + "*])").r
        val re3 = " *([+-])".r
        val re4 = " *\\(".r
        val re5 = " *\\)".r
        def parseFactor(a:StringSlice):(StringSlice, Int) = {
            re1.findPrefixMatchOf(a) match {
                case Some(m1) => (a.from(m1.end), m(m1.group(1)))
                case None => parseParen(a)
            }
        }
        def parseTerm(a:StringSlice) = {
            def parse1(a1:StringSlice, r1:Int):(StringSlice, Int) = {
                re2.findPrefixMatchOf(a1) match {
                    case Some(m1) => parseFactor(a1.from(m1.end)) match {
                        case (a2, r2) if m1.group(1) == "*" =>
                            parse1(a2, if (r1 < 3 && r2 < 2) 1 else 3)
                        case (a2, r2) if m1.group(1) == "/" =>
                            parse1(a2, if (r1 < 3 && r2 < 1) 1 else 3)
                    }
                    case None => (a1, r1)
                }
            }
            parseFactor(a) match { case (a1, r1) => parse1(a1, r1) }
        }
        def parseExpr(a:StringSlice) = {
            def parse1(a1:StringSlice, r1:Int):(StringSlice, Int) = {
                re3.findPrefixMatchOf(a1) match {
                    case Some(m1) => parseTerm(a1.from(m1.end)) match {
                        case (a2, r2) if m1.group(1) == "+" =>
                            parse1(a2, if (r1 < 3 && r2 < 3) 2 else 3)
                        case (a2, r2) if m1.group(1) == "-" =>
                            parse1(a2, if (r1 < 3 && r2 < 2) 2 else 3)
                    }
                    case None => (a1, r1)
                }
            }
            parseTerm(a) match { case (a1, r1) => parse1(a1, r1) }
        }
        def parseParen(a:StringSlice) = {
            re4.findPrefixMatchOf(a) match {
                case Some(m1) => parseExpr(a.from(m1.end)) match {
                    case (a1, r1) => re5.findPrefixMatchOf(a1) match {
                        case Some(m2) =>
                            (a1.from(m2.end), if (r1 < 3) 0 else 3)
                    }
                }
            }
        }
        def apply(s:String) = parseExpr(StringSlice(s, 0))._2
    }

    def main(args : Array[String]) {
        val define = " *# *define +(.*?) +(.*)".r
        for (i <- 1 to readInt) {
            val define(name, exp) = readLine
            m(name) = ExpParsers(exp)
        }
        println(if (ExpParsers(readLine) == 3) "Suspicious" else "OK")
    }
}


object A686 {
  @inline def read = scala.io.StdIn.readLine

  @inline def tokenizeLine = new java.util.StringTokenizer(read)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n, x) = readLongs(2)
    val input = Array.fill(n.toInt){
      val tl = tokenizeLine
      (tl.nextToken, tl.nextToken.toLong)
    }
    var ice = x
    var left = 0L

    for(i <- 0 until n.toInt){
      if(input(i)._1 == "+") {
        ice += input(i)._2
      } else {
        if(ice >= input(i)._2) {
          ice -= input(i)._2
        } else {
          left += 1
        }
      }
    }

    println(s"$ice $left")
  }
}

object Main{
  def main(args: Array[String]) {

    val temp = scala.io.StdIn.readLine().split(" ").map(x => x.toInt)
    val n = temp(0); val x = temp(1)

    var children = 0
    var ice = x.toLong

    for(x <- 1 to n){
      val temp = scala.io.StdIn.readLine().split(" ")
      val b = temp(0); val d = temp(1).toLong

      b match {
        case "+" => ice = ice + d
        case "-" => if (ice >= d) {ice = ice - d} else {children = children + 1}
      }
    }

    println(ice + " " + children)

  }
}

import scala.io.StdIn._

object _359A extends App {
  val input = readLine().split(" ").map(_.toInt)
  val (n, x) = (input(0), input(1))
  var acc: Long = x
  var dis = 0
  for (i <- 1 to n) {
    val input = readLine().split(" ")
    var inc: Long = input(1).toInt
    inc = if (input(0) == "+") inc else -inc
    if (acc + inc < 0) dis += 1
    else acc += inc
  }
  println(acc + " " + dis)
}

import java.util.Scanner

import scala.collection.immutable.HashSet
import scala.io.StdIn

/**
  * Created by shvedchikov on 13.01.16.
  */
object Codeforces extends App {
  override def main(args: Array[String]) {
    iceCream()
  }

  //http://codeforces.com/problemset/problem/686/A
  def iceCream(): Unit = {

    case class Status(iceCreamsCount: Long, sadChildrenCount: Long) {
      override def toString: String = s"$iceCreamsCount $sadChildrenCount"
    }

    val Array(n, x) = StdIn.readLine().split(" ").map(_.toLong)
    val result = (1L to n)
      .map(_ => StdIn.readLine().split(" ") match { case Array(sign, count) => (sign, count.toLong) })
      .foldLeft(Status(x, 0))((status, request) => {
        val (sign, count) = request
        sign match {
          case "+" =>
            status.copy(iceCreamsCount = status.iceCreamsCount + count)
          case "-" if status.iceCreamsCount < count =>
            status.copy(sadChildrenCount = status.sadChildrenCount + 1)
          case "-" if status.iceCreamsCount >= count =>
            status.copy(iceCreamsCount = status.iceCreamsCount - count)
        }
      })
    print(result)
  }

}

object Solution {
    def re(ns:List[Long],x:Long,d:Int):Unit =
      if (ns.isEmpty) println(s"$x $d")
      else if (ns.head > 0) re(ns.tail,x+ns.head,d)
      else if (-ns.head > x) re(ns.tail,x,d+1)
      else re(ns.tail,x+ns.head,d)
    def main(args: Array[String]) {
        val nx = readLine.split(" ").map(_.toLong)
        val ns = (0 until nx(0).toInt).map(_=>{
          val pv = readLine.split(" ")
          if (pv(0)=="+") pv(1).toLong else -pv(1).toLong
        }).toList
        re(ns,nx(1),0)
    }
}

object Solution extends App {
  val lines = io.Source.stdin.getLines()
  val Array(n, x) = lines.next().split(' ').map(_.toInt)
  val (l, u) = lines.take(n).foldLeft(x.toLong, 0) {
    case((left, unh), str) if str.startsWith("+") => (left + str.drop(2).toInt, unh)
    case((left, unh), str) if str.startsWith("-") =>
      val count = str.drop(2).toInt
      if (count > left)
        (left, unh + 1)
      else
        (left - count, unh)
  }
  println(s"$l $u")
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _686A extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write}
    val n = read[Int]
    var x = read[Long]
    var unhappy = 0

    repeat(n) {
      read[(Char, Long)] match {
        case ('+', i) => x += i
        case ('-', i) if i <= x => x -= i
        case _ => unhappy += 1
      }
    }

    write(x, unhappy)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toYesNo = if(x) "yes" else "no"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    def bitCount: Int = java.lang.Integer.bitCount(x)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V]: mutable.MultiMap[K, V] = new mutable.HashMap[K, mutable.Set[V]] with mutable.MultiMap[K, V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any, more: Any*): this.type = {
    printer.print(obj)
    more foreach {i =>
      printer.print(' ')
      printer.print(i)
    }
    this
  }
  def writeLine(obj: Any*): this.type = {
    if (obj.isEmpty) printer.println() else obj foreach printer.println
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import java.util.Scanner

object Main{
  // val n = sc.nextInt()
  // val s = sc.nextLine()
  // val str = sc.next()

  def main (args: Array[String]){
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val x = sc.nextInt()
    sc.nextLine()

    var ice: Long = x
    var distman = 0
    for(k <- 1 to n){
      val query = sc.next()
      val d = sc.nextInt()
      sc.nextLine()

      if(query == "+")
        ice += d
      else{
        if(ice >= d)
          ice -= d
        else
          distman += 1
      }
    }

    println(ice + " " + distman)
  }
}

import java.util.Scanner

import scala.collection.immutable.HashSet
import scala.io.StdIn

/**
  * Created by shvedchikov on 13.01.16.
  */
object Codeforces extends App {
  override def main(args: Array[String]) {
    iceCream()
  }

  //http://codeforces.com/problemset/problem/686/A
  def iceCream(): Unit = {

    case class Status(iceCreamsCount: Int, sadChildrenCount: Int) {
      override def toString: String = s"$iceCreamsCount $sadChildrenCount"
    }

    val Array(n, x) = StdIn.readLine().split(" ").map(_.toInt)
    val result = (1 to n)
      .map(_ => StdIn.readLine().split(" ") match { case Array(sign, count) => (sign, count.toInt) })
      .foldLeft(Status(x, 0))((status, request) => {
        val (sign, count) = request
        sign match {
          case "+" =>
            status.copy(iceCreamsCount = status.iceCreamsCount + count)
          case "-" if status.iceCreamsCount < count =>
            status.copy(sadChildrenCount = status.sadChildrenCount + 1)
          case "-" if status.iceCreamsCount >= count =>
            status.copy(iceCreamsCount = status.iceCreamsCount - count)
        }
      })
    print(result)
  }

}

object Solution extends App {
  val lines = io.Source.stdin.getLines()
  val Array(n, x) = lines.next().split(' ').map(_.toInt)
  val (l, u) = lines.take(n).foldLeft(x, 0) {
    case((left, unh), str) if str.startsWith("+") => (left + str.drop(2).toInt, unh)
    case((left, unh), str) if str.startsWith("-") =>
      val count = str.drop(2).toInt
      if (count > left)
        (left, unh + 1)
      else
        (left - count, unh)
  }
  println(s"$l $u")
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _686A extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write}
    val n = read[Int]
    var x = read[Int]
    var unhappy = 0

    repeat(n) {
      read[(Char, Int)] match {
        case ('+', i) => x += i
        case ('-', i) if i <= x => x -= i
        case _ => unhappy += 1
      }
    }

    write(x, unhappy)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = t.head.ensuring(t.size == 1)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toYesNo = if(x) "yes" else "no"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    def bitCount: Int = java.lang.Integer.bitCount(x)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V]: mutable.MultiMap[K, V] = new mutable.HashMap[K, mutable.Set[V]] with mutable.MultiMap[K, V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any, more: Any*): this.type = {
    printer.print(obj)
    more foreach {i =>
      printer.print(' ')
      printer.print(i)
    }
    this
  }
  def writeLine(obj: Any*): this.type = {
    if (obj.isEmpty) printer.println() else obj foreach printer.println
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

object Main{
  def main(args: Array[String]) {

    val temp = scala.io.StdIn.readLine().split(" ").map(x => x.toInt)
    val n = temp(0); val x = temp(1)

    var children = 0
    var ice = x

    for(x <- 1 to n){
      val temp = scala.io.StdIn.readLine().split(" ")
      val b = temp(0); val d = temp(1).toInt

      b match {
        case "+" => ice = ice + d
        case "-" => if (ice >= d) {ice = ice - d} else {children = children + 1}
      }
    }

    println(ice + " " + children)

  }
}


import java.io._
import java.util
import java.util.StringTokenizer

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object A extends App {

  case class Point(x: Int, y: Int)

  @inline def dist(x1: Int, x2: Int, y1: Int, y2: Int): Int = math.abs(x1 - x2) * 2 + math.abs(y1 - y2) * 2

  def solve(in: InputReader): Unit = {
    val n = in.nextInt
    var mxX = -1000000000
    var mnX = 1000000000
    var mxY = -1000000000
    var mnY = 1000000000
    val arr = Array.fill(n) {
      val p = Point(in.nextInt, in.nextInt)
      mxX = math.max(mxX, p.x)
      mnX = math.min(mnX, p.x)
      mxY = math.max(mxY, p.y)
      mnY = math.min(mnY, p.y)
      p
    }

    var ans3 = 0
    arr.foreach { p =>
      ans3 = math.max(ans3, dist(p.x, mxX, p.y, mxY))
      ans3 = math.max(ans3, dist(p.x, mxX, p.y, mnY))
      ans3 = math.max(ans3, dist(p.x, mnX, p.y, mxY))
      ans3 = math.max(ans3, dist(p.x, mnX, p.y, mnY))
    }

    val ans4 = (mxX - mnX) * 2 + (mxY - mnY) * 2

    print(ans3 + (" " + ans4) * (n - 3))

  }

  solve(new InputReader(System.in))

  private class InputReader(val in: InputStream) {

    private val reader: BufferedReader = new BufferedReader(new InputStreamReader(in))
    private var tokenizer: StringTokenizer = _

    def nextInt: Int = {
      next.toInt
    }

    def nextDouble: Double = {
      next.toDouble
    }

    def nextLong: Long = {
      next.toLong
    }

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens) {
        tokenizer = new StringTokenizer(readLine)
      }
      tokenizer.nextToken
    }

    def readLine: String = {
      try {
        reader.readLine()
      } catch {
        case e: IOException => throw new RuntimeException(e)
      }
    }
  }

}

object E extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }

  case class P(x: Long, y: Long)

  def dist(p1: P, p2: P): Long = {
    Math.abs(p2.x - p1.x) + Math.abs(p1.y - p2.y)
  }

  val Array(n) = readInts(1)

  val ps = Array.fill(n) {
    val Array(x, y) = readLongs(2)
    P(x, y)
  }

  val psByX = ps.sortBy(_.x)
  val psByY = ps.sortBy(_.y)

  var on3 = 0L

  def triangle(p1: P, p2: P, p3: P): Long = {
    dist(p1, p2) + dist(p2, p3) + dist(p3, p1)
  }

  for (p <- ps) {
    val d1 = triangle(psByX.head, psByY.last, p)
    val d2 = triangle(psByX.head, psByY.head, p)
    val d3 = triangle(psByX.last, psByY.last, p)
    val d4 = triangle(psByX.last, psByY.head, p)
    val d = d1 max d2 max d3 max d4
    if (d > on3) on3 = d
  }

  val res = Array.ofDim[Long](n - 2)
  res(0) = on3

  val on4 = 2 * (psByX.last.x - psByX.head.x + psByY.last.y - psByY.head.y)

  for (i <- 1 until res.length) res(i) = on4

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  println(res.mkString(" "))

  Console.flush
}

import java.util

import scala.collection.mutable

object E extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  case class P(x: Long, y: Long)

  def dist(x1: Long, y1: Long, x2: Long, y2: Long): Long = {
    Math.abs(x2 - x1) + Math.abs(y2 - y1)
  }

  val Array(n) = readInts(1)
  val psBuilder = new mutable.ArrayBuilder.ofRef[P]

  for (_ <- 0 until n) {
    val Array(x, y) = readLongs(2)
    psBuilder += P(x, y)
  }

  val ps = psBuilder.result()
  val psByX = ps.sortBy(_.x)
  val psByY = ps.sortBy(_.y)

  var on3ByX, on3ByY = 0L

  {
    val first = psByX.head
    val last = psByX.last
    for (i <- 1 until n - 1) {
      val p = psByX(i)
      val d = dist(first.x, first.y, p.x, p.y) + dist(p.x, p.y, last.x, last.y) + dist(first.x, first.y, last.x, last.y)
      if (d > on3ByX) on3ByX = d
    }
  }

  {
    val first = psByY.head
    val last = psByY.last
    for (i <- 1 until n - 1) {
      val p = psByY(i)
      val d = dist(first.x, first.y, p.x, p.y) + dist(p.x, p.y, last.x, last.y) + dist(first.x, first.y, last.x, last.y)
      if (d > on3ByY) on3ByY = d
    }
  }

  val res = Array.ofDim[Long](n - 2)
  res(0) = Math.max(on3ByX, on3ByY)

  val on4 = 2 * (psByX.last.x - psByX.head.x + psByY.last.y - psByY.head.y)

  for (i <- 1 until res.length) res(i) = on4

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  println(res.mkString(" "))

  Console.flush
}

import java.util

import scala.collection.mutable

object E extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  case class P(x: Int, y: Int)

  def dist(x1: Int, y1: Int, x2: Int, y2: Int): Long = {
    Math.abs(x2 - x1) + Math.abs(y2 - y1)
  }

  val Array(n) = readInts(1)
  val psBuilder = new mutable.ArrayBuilder.ofRef[P]

  for (i <- 0 until n) {
    val Array(x, y) = readInts(2)
    psBuilder += P(x, y)
  }

  val ps = psBuilder.result
  val psByX = ps.sortBy(_.x)
  val psByY = ps.sortBy(_.y)

  var on3ByX = 0L

  {
    val first = psByX.head
    val last = psByX.last
    for (i <- 1 until n - 1) {
      val p = psByX(i)
      val d = dist(first.x, first.y, p.x, p.y) + dist(p.x, p.y, last.x, last.y ) + dist(first.x, first.y, last.x, last.y)
      if (d > on3ByX) on3ByX = d
    }
  }

  var on3ByY = 0L

  {
    val first = psByY.head
    val last = psByY.last
    for (i <- 1 until n - 1) {
      val p = psByY(i)
      val d = dist(first.x, first.y, p.x, p.y) + dist(p.x, p.y, last.x, last.y ) + dist(first.x, first.y, last.x, last.y)
      if (d > on3ByY) on3ByY = d
    }
  }

  val res = Array.ofDim[Long](n - 2)
  res(0) = on3ByX max on3ByY

  val on4 = 2 * (psByX.last.x - psByX.head.x + psByY.last.y - psByY.head.y)

  for (i <- 1 until res.length) res(i) = on4

  Console.setOut(new java.io.BufferedOutputStream(Console.out))

  println(res.mkString(" "))

  Console.flush
}

import java.io._
import java.util
import java.util.StringTokenizer

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object A extends App {

  case class Point(x: Int, y: Int)

  def dist(p1: Point, p2: Point): Long = math.abs(p1.x - p2.x) + math.abs(p1.y - p2.y)

  def solve(in: InputReader): Unit = {
    val n = in.nextInt
    val arr = Array.fill(n)(Point(in.nextInt, in.nextInt))
    val mxX: Long = arr.maxBy(_.x).x
    val mnX: Long = arr.minBy(_.x).x
    val mxY: Long = arr.maxBy(_.y).y
    val mnY: Long = arr.minBy(_.y).y

    val t = ArrayBuffer[Point]()
    arr.foreach { p =>
      if (p.x == mxX || p.x == mnX || p.y == mxY || p.y == mnY)
        t.append(p)
    }

    val ans3 = (for {
      p1 <- t
      p2 <- t
      p3 <- t
    } yield dist(p1, p2) + dist(p2, p3) + dist(p3, p1)).max

    val ans4 = (mxX - mnX) * 2 + (mxY - mnY) * 2

    print(ans3 + (" " + ans4) * (n - 3))

  }

  solve(new InputReader(System.in))

  private class InputReader(val in: InputStream) {

    private val reader: BufferedReader = new BufferedReader(new InputStreamReader(in))
    private var tokenizer: StringTokenizer = _

    def nextInt: Int = {
      next.toInt
    }

    def nextDouble: Double = {
      next.toDouble
    }

    def nextLong: Long = {
      next.toLong
    }

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens) {
        tokenizer = new StringTokenizer(readLine)
      }
      tokenizer.nextToken
    }

    def readLine: String = {
      try {
        reader.readLine()
      } catch {
        case e: IOException => throw new RuntimeException(e)
      }
    }
  }

}