Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

blockquote {
  font-family: Menlo, Monaco, "Courier New", monospace;
  color: #333333;
  display: block;
  padding: 8.5px;
  margin: 0 0 9px;
  font-size: 12px;
  line-height: 18px;
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  border: 1px solid rgba(0, 0, 0, 0.15);
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  white-space: pre;
  white-space: pre-wrap;
  word-break: break-all;
  word-wrap: break-word;
}

Problem Statement

One day, you found an old scroll with strange texts on it.

You revealed that the text was actually an expression denoting the position of
treasure.  The expression consists of following three operations:

 From two points, yield a line on which the points lie.

 From a point and a line, yield a point that is symmetric to the given point with respect to the line.

 From two lines, yield a point that is the intersection of the lines.

The syntax of the expression is denoted by following BNF:

<expression>      ::= <point>
<point>       	  ::= <point-factor> | <line> "@" <line-factor> | <line> "@" <point-factor> | <point> "@" <line-factor>
<point-factor>    ::= "(" <number> "," <number> ")" | "(" <point> ")"
<line>            ::= <line-factor> | <point> "@" <point-factor>
<line-factor>     ::= "(" <line> ")"
<number>          ::= <zero-digit> | <positive-number> | <negative-number>
<positive-number> ::= <nonzero-digit> | <positive-number> <digit>
<negative-number> ::= "-" <positive-number>
<digit>           ::= <zero-digit> | <nonzero-digit>
<zero-digit>      ::= "0"
<nonzero-digit>   ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

Each <point> or <point-factor> denotes a point, whereas each <line> or <line-factor> denotes a line.  The former notion of <point-factor> $(X,Y)$ represents a point which has $X$ for $x$-coordinate and $Y$ for $y$-coordinate on the $2$-dimensional plane.
"@" indicates the operations on two operands.  Since each operation is distinguishable from others by its operands' types (i.e. a point or a line),
all of these operations are denoted by the same character "@". 
Note that "@" is left-associative, as can be seen from the BNF.

Your task is to determine where the treasure is placed.

Input

The input consists of multiple datasets.  Each dataset is a single line which
contains an expression denoting the position of treasure.

It is guaranteed that each dataset satisfies the following conditions:

 The length of the string never exceeds $10^2$.

 If both operands of "@" are points, their distance is greater than $1$.

 If both operands of "@" are lines, they are never parallel.

 The absolute values of points' coordinates never exceed $10^2$ at any point of evaluation.

You can also assume that there are at most $100$ datasets.

The input ends with a line that contains only a single "#".

Output

For each dataset, print the $X$ and $Y$ coordinates of the point, denoted by
the expression, in this order.

The output will be considered correct if its absolute or relative error is at most $10^{-2}$.

Sample Input

((0,0)@(1,1))@((4,1)@(2,5))
((0,0)@(3,1))@((1,-3)@(2,-1))
(0,0)@(1,1)@(4,1)
(0,0)@((1,1)@(4,1))
(((0,0)@((10,20)@(((30,40))))))
((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)
#

Output for the Sample Input

3.00000000 3.00000000
3.00000000 1.00000000
1.00000000 4.00000000
0.00000000 2.00000000
-10.00000000 10.00000000
-99.83681795 -91.92248853



Sample input:
((0,0)@(1,1))@((4,1)@(2,5))
((0,0)@(3,1))@((1,-3)@(2,-1))
(0,0)@(1,1)@(4,1)
(0,0)@((1,1)@(4,1))
(((0,0)@((10,20)@(((30,40))))))
((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)
#


Sample output:
3.00000000 3.00000000
3.00000000 1.00000000
1.00000000 4.00000000
0.00000000 2.00000000
-10.00000000 10.00000000
-99.83681795 -91.92248853

Submission status: Accepted

Solution code:
digits = "-0123456789"
def cross_point(P, Q):
    x0, y0, x1, y1 = P
    x2, y2, x3, y3 = Q
    dx0 = x1 - x0; dy0 = y1 - y0
    dx1 = x3 - x2; dy1 = y3 - y2

    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if s < 0:
        s = -s
        sm = -sm
    if s == 0:
        x = x0
        y = y0
    else:
        x = x0 + s*dx0/sm
        y = y0 + s*dy0/sm
    return x, y
def reflection(line, point):
    x0, y0, x1, y1 = line
    p, q = point
    x1 -= x0; y1 -= y0
    p -= x0; q -= y0
    cv = p*x1 + q*y1
    sv = p*y1 - q*x1
    cv2 = cv**2 - sv**2
    sv2 = 2*cv*sv
    dd = (p**2 + q**2)*(x1**2 + y1**2)
    if dd == 0:
        return x0 + p, y0 + q
    return x0 + (cv2 * p - sv2 * q) / dd, y0 + (sv2 * p + cv2 * q) / dd

def parse(S):
    S = S + "$"
    cur = 0
    def expr():
        nonlocal cur
        res = None
        while S[cur] == '(':
            cur += 1 # '('
            if S[cur] in digits:
                x = number()
                cur += 1 # ','
                y = number()
                r = (0, x, y)
            else:
                r = expr()
            cur += 1 # ')'
            if res is None:
                res = r
            else:
                if res[0] == r[0] == 0:
                    # (point)@(point)
                    res = (1, res[1], res[2], r[1], r[2])
                elif res[0] == r[0] == 1:
                    # (line)@(line)
                    x, y = cross_point(res[1:], r[1:])
                    res = (0, x, y)
                else:
                    # (line)@(point) or (point)@(line)
                    point, line = (res, r) if r[0] else (r, res)
                    x, y = reflection(line[1:], point[1:])
                    res = (0, x, y)
            if S[cur] != '@':
                break
            cur += 1 # '@'
        return res

    def number():
        nonlocal cur
        v = 0; mns = 0
        if S[cur] == '-':
            mns = 1
            cur += 1 # '-'
        while S[cur] in digits:
            v = 10*v + int(S[cur])
            cur += 1
        return -v if mns else v

    return expr()

def solve():
    s = input()
    if s == '#':
        return False
    res = parse(s)
    print("%.16f %.16f" % res[1:])
    return True
while solve():
    ...