Under construction

Still being built. Things may change

Linear System of Equations

Interview

Time limit2sMemory limit512 MB

Summary
Given N linear equations in N unknowns with a unique solution, find and print the values of x1 through xN.
Level

Medium4 of 10

Topics
Math, Brute force, Implementation, Matrix
Solved
No attempts yet

Problem

An equation whose highest degree in each unknown is at most 1 is called a linear equation. In other words, it has the following form.

A1x1+A2x2+⋯+Anxn=BA_1x_1 + A_2x_2 + \cdots + A_nx_n = B

A linear system of equations is a finite collection of linear equations. For example:

x1+2x2=4x_1 + 2x_2 = 4

3x1+2x2=63x_1 + 2x_2 = 6

Given a linear system of equations, write a program that finds its solution.

Only inputs with a unique solution are given, and every solution value is a natural number at most 100.

Input

The first line gives the number of unknowns NN (2 ≤ NN ≤ 6).

Each of the next NN lines gives N+1N+1 integers A1,A2,…,AN,BA_1, A_2, \ldots, A_N, B (1 ≤ AiA_i ≤ 10) describing one equation.

Output

Print x1x_1 through xNx_N in order, separated by a single space.

Examples1

  1. Example 1

    Input
    2
    1 2 8
    3 2 12
    
    Expected output
    2 3