Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Equations
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 878Accepted: 175

Description

Given 2 equations on the variables x and y, solve for x and y.

Input

The first line of input contains N, the number of test cases. Each test case consists of two equations, each on a separate line. An empty line separates cases. An equation consists of two or more terms separated by addition, subtraction, or equality operators. A term is an integer, or a variable name (x or y) optionally preceded by a minus sign or an integer coefficient. There is exactly one equality operator. All operators are surrounded by spaces, and there are no spaces within terms.

Output

For each case, print two lines, giving the values of x and y as rationals in simplest terms. If x or y has no unique rational value such that both equations hold, print "don't know" for its value. Print an empty line between cases.

Sample Input

7
2x + 3y = x
5 = x + y + 3

2x + 3y = 0
10x = -15y

2x + 3y = 0
10x = -15y + 1

x = 1
3x = 6y

2x = 3x + -x + y
x + y = x + y

2x = -3
-2y = 3

1 = 2
x = 3

Sample Output

3
-1

don't know
don't know

don't know
don't know

1
1/2

don't know
0

-3/2
-3/2

don't know
don't know

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator