import scala.io.{Source, StdIn}
import scala.util.parsing.combinator._


object Main extends JavaTokenParsers {
  sealed trait Element
  case class Point(x: Double, y: Double) extends Element {
    def this(_x: Element, _y: Element) = this(_x.asInstanceOf[Value].n, _y.asInstanceOf[Value].n)
    def +(p: Point) = Point(x+p.x, y+p.y)
    def -(p: Point) = Point(x-p.x, y-p.y)
    def *(d: Double) = Point(x*d, y*d)
    def /(d: Double) = Point(x/d, y/d)
    def norm = x * x + y * y
  }
  case class Line(a: Point, b: Point) extends Element
  case class Par(a: Element) extends Element
  case class AtMark(a: Element, b: Element) extends Element
  case class Value(n: Double) extends Element


  // geometry library begin
  val EPS = 1e-8

  def dot(a: Point, b: Point): Double = a.x * b.x + a.y * b.y

  def cross(a: Point, b: Point): Double = a.x * b.y - a.y * b.x

  def crossPoint(l: Line, m: Line): Option[Point] = {
    val A = cross(l.b - l.a, m.b - m.a)
    val B = cross(l.b - l.a, l.b - m.a)
    if(Math.abs(A) < EPS && Math.abs(B) < EPS) Some(m.a)
    else if(Math.abs(A) >= EPS) Some(m.a + (m.b - m.a) * B / A)
    else None
  }

  def proj(p: Point, l: Line): Point =  l.a + (l.b - l.a) * dot(p - l.a, l.b - l.a) / (l.b - l.a).norm

  def reflect(p: Point, l: Line): Point = p + (proj(p, l) - p) * 2.0
  //geometry library end


  // BNF begin
  def expression: Parser[Element] = factor ~ rep("@" ~ factor) ^^ {
    case left ~ rights =>
      rights.foldLeft(left){
        (res, right) => right match {
          case "@" ~ ri => AtMark(res, ri)
        }
      }
  }

  def factor: Parser[Element] = _point | "(" ~ expression ~ ")" ^^ {
    case "(" ~ a ~ ")" => Par(a)
  }

  def _point: Parser[Element] = "(" ~ number ~ "," ~ number ~ ")" ^^ {
    case "(" ~ a ~ "," ~ b ~ ")" => new Point(a, b)
  }
  /*
  def expression: Parser[Elem] = point


  def point: Parser[Elem] = /*point_factor | line ~ "@" ~ line_factor | line ~ "@" ~ point_factor |*/ point ~ "@" ~ line_factor ^^ {
    case left ~ "@" ~ right => AtMark(left, right)
  }

  def point_factor: Parser[Elem] = "(" ~ number ~ "," ~ number ~ ")" | "(" ~ point ~ ")" ^^ {
    case "(" ~ a ~ "," ~ b ~ ")" => new Point(a, b)
    case "(" ~ a ~ ")" => Par(a)
  }

  def line: Parser[Elem] = line_factor | point ~ "@" ~ point_factor ^^ {
    case left ~ "@" ~ right => AtMark(left, right)
  }

  def line_factor: Parser[Elem] = "(" ~ line ~ ")" ^^ {
    case "(" ~ a ~ ")" => Par(a)
  }
  */

  def number: Parser[Element] = floatingPointNumber ^^ {
    value => Value(value.toDouble)
  }
  // BNF end

  def calc(op: Element) : Option[Element] = op match {
    case p: Point => Some(p)

    case l: Line => Some(l)

    case Par(a) => calc(a)

    case AtMark(a, b) => (calc(a), calc(b)) match {
      case (Some(a: Point), Some(b: Point)) => Some(Line(a, b))
      case (Some(a: Line), Some(b: Line)) => crossPoint(a, b)
      case (Some(p: Point), Some(l: Line)) => Some(reflect(p, l))
      case (Some(l: Line), Some(p: Point)) => Some(reflect(p, l))
      case _ => None
    }

    case Value(n) => None
  }

  def main(args: Array[String]) {
    for(line <- Source.stdin.getLines().filter(_ != "#")){
      parseAll(expression, line) match {
        case Success(result, next) => calc(result) match {
          case Some(Point(x, y)) => println(x + " " + y)
          case a => println("not point error: actual is " + a)
        }
        case _ => println("parse failed error")
      }
    }
  }
}

Measured memory_bytes: 56180