Now a days almost all scientific calculators have the property of solving a system of simultaneous equations. Code a program to do the same for the following and find the value of X,Y and Z.

** a1X + b1Y + c1Z = d1**

** a2X + b2Y + c2Z = d2**

** a3X + b3Y + c3Z = d3**

**Input:**

The first line of input takes the number of test cases T. Then T test cases follow.

Each test case has 3 input lines.

The 3 lines of each test case take 4 space separated integers denoting the values of a, b, c and d respectively.

Note: Your code should be able to handle double values.

**Output:**

Print 0 in case the system is inconsistent and 1 in case the system is consistent and has infinitely many solutions.

In case the system is consistent and has a unique solution, print 3 space separated integers denoting the floor values of X, Y and Z respectively.

**Constraints:**

1<=T<=100

-100<=a, b, c, d<=100

**Example:**

**Input:**

```
3
5 4 2 0
1 4 2 0
4 2 9 0
3.4 -8.9 10 12.3
4.5 3.2 -89.01 23.4
2.2 -2.1 1.1 12.3
-4.2 6 7 10
1 2 3 12
3 2 2 20
```

**Output:**

```
0 0 0
6 1 0
3 4 -1
```

Author: akundusaltlake

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

preparecodinginterview_dot_com | 190 |

__murugan__ | 171 |

manvimahajan20 | 134 |

ShameekAgarwal | 116 |

SoumyaKaushik | 108 |

preparecodinginterview_dot_com | 190 |

__murugan__ | 171 |

manvimahajan20 | 160 |

SoumyaKaushik | 146 |

arpit_anshuman | 140 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.