import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main implements Runnable {

	int n;
	double[] prob;
	double[][] a;

	void solve() throws IOException {
		n = nextInt();
		a = new double[n][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				a[i][j] = nextDouble();
			}
		}
		prob = new double[1<<n];
		Arrays.fill(prob, 0.0);
		prob[(1<<n)-1] = 1.0;
		for (int i = (1<<n)-1; i > 1; --i) {
			int c = 0;
			for (int bit = 0; bit < n; ++bit) {
				if (((1<<bit) & i) > 0) {
					++c;
				}
			}
			double k = c * (c - 1) / 2.0;
			for (int f = 0; f < n; ++f) {
				if (((1<<f) & i) > 0) {
					for (int s = f+1; s < n; ++s) {
						if (((1<<s) & i) > 0) {
							prob[i^(1<<f)] += prob[i] * a[s][f] / k;
							prob[i^(1<<s)] += prob[i] * a[f][s] / k;
						}
					}
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			writer.printf(Locale.US, "%.6f ", prob[1<<i]);
		}
	}

	public static void main(String[] args) throws InterruptedException {
		 new Thread(null, new Runnable() {
            public void run() {
                new Main().run();
            }
	     },
	     "1",
	     1 << 25).start();
	}

	@Override
	public void run() {
		try {
			boolean fromStandart = true;
			reader = new BufferedReader(fromStandart ? new InputStreamReader(System.in) : new FileReader(INFILE));
            writer = new PrintWriter(new BufferedWriter(fromStandart ? new OutputStreamWriter(System.out) : new FileWriter(OUTFILE)));
			tokenizer = null;
			solve();
			writer.flush();
		} catch (Exception error) {
			error.printStackTrace();
			System.exit(1);
		}
	}

	static final String INFILE = "input.txt";
	static final String OUTFILE = "output.txt";

	BufferedReader reader;
	StringTokenizer tokenizer;
    PrintWriter writer;

	int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextString() throws IOException {
    	return reader.readLine();
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}


import java.util.Locale;
import java.util.Scanner;

public class E {
	public static void main(String[] args) {
		new E().run();
	}

	private void run() {
		Locale.setDefault(Locale.US);
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[][] p = new double[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				p[i][j] = sc.nextDouble();
		}
		sc.close();
		double[] w = new double[1 << n];
		int max = (1 << n) - 1;
		w[max] = 1;
		for (int mask = max; mask > 0; mask--) {
			int count = 0;
			for (int i = 0; i < n; i++)
				if (((mask >> i) & 1) > 0)
					for (int j = i + 1; j < n; j++)
						if (((mask >> j) & 1) > 0) {
							count++;
						}
			if (count > 0)
				for (int i = 0; i < n; i++)
					if (((mask >> i) & 1) > 0)
						for (int j = i + 1; j < n; j++)
							if (((mask >> j) & 1) > 0) {
								w[mask ^ (1 << j)] += w[mask] * p[i][j] / count;
								w[mask ^ (1 << i)] += w[mask] * (1 - p[i][j])
										/ count;
							}
		}
		for (int i = 0; i < n; i++) {
			if (i != 0)
				System.out.print(' ');
			System.out.printf("%.6f", w[1 << i]);
		}
		System.out.println();
	}
}


import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader kek = new BufferedReader(new InputStreamReader(System.in));
		//Scanner skek = new Scanner(System.in);
		PrintWriter outkek = new PrintWriter(System.out);

		int N = Integer.parseInt(kek.readLine());
		double[][] lake = new double[N][N];

		for(int i = 0; i < N; i++){
			String[] input = kek.readLine().split(" ");
			for(int j = 0; j < N; j++){
				lake[i][j] = Double.parseDouble(input[j]);
			}
		}

		int pow = (int)Math.pow(2, N);
		double[] res = new double[pow];
		res[pow - 1] = 1.0;

		for(int i = pow - 1; i >= 0; i--){
			int ones = Integer.bitCount(i); // So this is apparently a thing
			int possibleCombos = ones * (ones - 1) /2;

			for(int j = 0; j < N; j++){
				if((i >> j) % 2 == 0){ // (X >> Y) literally does the same thing as divis func. Bit operators are weird.
					continue;
				}
				for(int k = j + 1; k < N; k++){
					if((i >> k) % 2 == 0){
						continue;
					}
					res[i ^ (1 << k)] += res[i] * lake[j][k]/possibleCombos;
					res[i ^ (1 << j)] += res[i] * lake[k][j]/possibleCombos;
				}
			}

		}

		for(int i = 0; i < N; i++){
			outkek.print(res[1 << i] + " ");
		}

		kek.close();
		outkek.close();
	}

	/*static int divis(int n, int a){
		for(int i = 0; i < a; i++){
			n /= 2;
		}
		return n;
	}*/

}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main implements Runnable {

    // ////////////////////////////////////////////////////////////////////
    // Solution

    private int n;
    private int nn;
    private double[][] a;
    private double[] dp;

    private void solve() throws Throwable {
        n = nextInt();
        nn = 1 << n;
        a = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = nextDouble();
            }
        }
        dp = new double[nn];
        Arrays.fill(dp, -1.0);
        dp[nn - 1] = 1.0;
        for (int j = 0; j < n; j++) {
            pw.format(Locale.US, "%.7f ", Dp(1 << j));
        }
    }

    private double Dp(int i) {
        if (dp[i] >= 0.0)
            return dp[i];

        double ans = 0;
        int count = Integer.bitCount(i);
        for (int j = 0; j < n; j++) {
            int jj = 1 << j;
            if ((jj & i) == 0) {
                double p = Dp(jj | i);
                double pPair = 2.0 / (double)((count + 1) * count);
                double s = 0;
                for (int l = 0; l < n; l++) {
                    int ll = 1 << l;
                    if ((ll & i) != 0) {
                        s += a[l][j];
                    }
                }
                ans += p * pPair * s;

            }
        }
        dp[i] = ans;
        return dp[i];
    }

    // ////////////////////////////////////////////////////////////////////
    // Utility functions

    PrintWriter pw;
    BufferedReader in;
    StringTokenizer st;

    void initStreams() throws FileNotFoundException {
        //System.setIn(new FileInputStream("1"));
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
    }

    String nextString() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextString());
    }

    long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextString());
    }

    double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextString());
    }

    static Throwable sError;

    public static void main(String[] args) throws Throwable {
        Thread t = new Thread(new Main());
        t.start();
        t.join();
        if (sError != null) {
            throw sError;
        }
    }

    public void run() {
        try {
            initStreams();
            solve();
        } catch (Throwable e) {
            sError = e;
        } finally {
            if (pw != null)
                pw.close();
        }
    }
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Task2 {

    public static void main(String[] args) throws IOException {

        new Task2().solve();

    }

    //ArrayList<Integer>[] g;

    int mod = 1000000007;

    PrintWriter out;

    int n;
    int m;
    //int[][] a = new int[1000][1000];

    //int cnt = 0;

    long base = (1L << 63);
    long P = 31;

    int[][] a;

    void solve() throws IOException {

        //Reader in = new Reader("in.txt");
        //out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        Reader in = new Reader();
        PrintWriter out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );

        //BufferedReader br = new BufferedReader( new FileReader("in.txt") );
        //BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );

        int n = in.nextInt();

        double[][] a = new double[n][n];

        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                a[i][j] = in.nextDouble();

        double[] dp = new double[1 << n];

        dp[(1 << n) - 1] = 1;

        for (int mask = (1 << n) -1; mask >= 0; mask--) {

            int k = Integer.bitCount(mask);
            double p = 1.0 / (k*(k-1)/2.0);

            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if ((mask & (1 << i)) != 0 && (mask & (1 << j)) != 0)
                        dp[(mask & ~(1 << j))] += p*dp[mask]*a[i][j];

        }

        for (int i = 0; i < n; i++)
            out.print(dp[1 << i]+" ");

        out.flush();
        out.close();
    }

    long gcd(long a, long b) {

        if (b == 0)
            return a;

        return gcd(b, a%b);

    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (b < p.b)
                return 1;

            if (b > p.b)
                return -1;

            return 0;
        }

        //		@Override
        //		public boolean equals(Object o) {
        //			Pair p = (Pair) o;
        //			return a == p.a && b == p.b;
        //		}
        //
        //		@Override
        //		public int hashCode() {
        //			return Integer.valueOf(a).hashCode() + Integer.valueOf(b).hashCode();
        //		}

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}


import java.io.*;
import static java.lang.Math.*;
import java.util.*;
import java.util.function.*;
import java.lang.*;

public class Main {
    final static boolean debug = false;
    final static String fileName = "";
    final static boolean useFiles = false;

    public static void main(String[] args) throws FileNotFoundException {
        long start;
        if (debug)
            start = System.nanoTime();
        InputStream inputStream;
        OutputStream outputStream;
        if (useFiles) {
            inputStream = new FileInputStream(fileName + ".in");
            outputStream = new FileOutputStream(fileName + ".out");
        } else {
            inputStream = System.in;
            outputStream = System.out;
        }
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        if(debug)
            out.println((System.nanoTime() - start) / 1e+9);
        out.close();
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public byte nextByte() {
        return Byte.parseByte(next());
    }

    byte[][] nextBitMatrix(int n, int m) {
        byte[][] a = new byte[n][m];
        for (int i = 0; i < n; i++) {
            String s = next();
            for (int j = 0; j < m; j++) {
                a[i][j] = (byte) (s.charAt(j) - '0');
            }
        }
        return a;
    }

    char[][] nextCharMatrix(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            String s = next();
            for (int j = 0; j < m; j++) {
                a[i][j] = s.charAt(j);
            }
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }
}

class Task {
    boolean get(int mask, int i){
        return (mask & (1 << i)) > 0;
    }

    int zero(int mask, int i){
        return mask & (~(1 << i));
    }

    public void solve() {
        int n = in.nextInt();
        double[][] a = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++)
                a[i][j] = in.nextDouble();
        }
        double[] d = new double[1 << n];
        d[(1 << n) - 1] = 1;
        for (int mask = (1 << n) - 1; mask >= 0; mask--) {
            int bits = Integer.bitCount(mask);
            double transfer = 1.0 / (bits * (bits - 1) / 2);
            for (int i = 0; i < n; i++) {
                if (get(mask, i)) {
                    for (int j = i + 1; j < n; j++) {
                        if (get(mask, j)) {
                            d[zero(mask, j)] += a[i][j] * transfer * d[mask];
                            d[zero(mask, i)] += a[j][i] * transfer * d[mask];
                        }
                    }
                }
            }
        }
        for(int i = 0; i < n; i++)
            out.print(d[1 << i] + " ");
    }

    private InputReader in;
    private PrintWriter out;

    Task(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }
}


import java.util.Locale;
import java.util.Scanner;

public class E {
    public static void main(String[] args) {
        new E().solve();
    }

    private int c(int n) {
        return n * (n - 1) / 2;
    }

    public void solve() {
        Locale.setDefault(Locale.US);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[][] pb = new double[n][n];
        for (int i=0; i<n; ++i)
            for (int j=0; j<n; ++j)
                pb[i][j] = sc.nextDouble();

        int m = (1<<n);
        double[] dp = new double[m];
        dp[0] = 1.0f;
        for (int i=1; i<m; ++i)
            for (int j=0; j<n; ++j) if ((i & (1<<j)) != 0)
                for (int k=0; k<n; ++k) if ((i & (1<<k)) == 0)
                    dp[i] += pb[k][j] * dp[i & ~(1<<j)] / c(n - Integer.bitCount(i) + 1);

        int w = (1<<n) - 1;
        for (int i=0; i<n-1; ++i)
            System.out.printf("%.6f ", dp[w & ~(1<<i)]);
        System.out.printf("%.6f\n", dp[w & ~(1<<(n-1))]);
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.Arrays;

public class Fish extends Thread {

    public Fish() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    private void solve() throws Throwable {
        int n = nextInt();
        double[][] a = new double[n][n];
        double[] dp = new double[(1 << n)];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                a[i][j] = nextDouble();
            }
        }
        int limit = (1 << n) - 1;
        //dp[mask] = probability of current subset (mask) to remain in the end
        dp[limit] = 1.0;
        for (int mask = limit; mask > 0; --mask) {
            int cardinality = Integer.bitCount(mask);
            int probability = cardinality * (cardinality - 1) / 2;
            for (int first = 0; first < n; ++first) {
                if ((mask & powers[first]) != 0) {
                    for (int second = first + 1; second < n; ++second) {
                        if ((mask & powers[second]) != 0) {
                            dp[mask - powers[first]] += dp[mask] * a[second][first] / probability;
                            dp[mask - powers[second]] += dp[mask] * a[first][second] / probability;
                        }

                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            output.printf("%.10f ", dp[powers[i]]);
        }
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new Fish().start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    static int powers[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}


/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/14/11
 * Time: 9:53 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.Arrays;

public class Fish extends Thread {

    public Fish() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    static int getOnes(int mask) {
        int result = 0;
        while (mask != 0) {
            mask &= mask - 1;
            ++result;
        }
        return result;
    }

    private void solve() throws Throwable {
        int n = nextInt();
        double[][] a = new double[n][n];
        double[] dp = new double[(1 << n)];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                a[i][j] = nextDouble();
            }
        }
        int limit = (1 << n) - 1;
        //dp[mask] = probability of current subset (mask) to remain in the end
        dp[limit] = 1.0;
        for (int mask = limit; mask > 0; --mask) {
            int cardinality = getOnes(mask);
            if (cardinality < 2) {
                continue;
            }
            int probability = cardinality * (cardinality - 1) / 2;
            for (int first = 0; first < n; ++first) {
                if ((mask & powers[first]) != 0) {
                    for (int second = first + 1; second < n; ++second) {
                        if ((mask & powers[second]) != 0) {
                            dp[mask ^ powers[first]] += dp[mask] * a[second][first] / probability;
                            dp[mask ^ powers[second]] += dp[mask] * a[first][second] / probability;
                        }

                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            output.printf("%.10f ", dp[powers[i]]);
        }
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new Fish().start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    static final int powers[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter pw = new PrintWriter(System.out);

        in.nextToken();
        int n = (int) in.nval;
        double[][] a = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                in.nextToken();
                a[i][j] = in.nval;
            }
        }

        double[] dp = new double[1 << n];
        dp[(1 << n) - 1] = 1.0;

        for (int mask = (1 << n) - 2; mask > 0; mask--) {
            int count = Integer.bitCount(mask);
            double pPair = 2.0 / ((double) count * (count + 1));
            double ans = 0.0;

            for (int j = 0; j < n; j++) {
                int jj = 1 << j;
                if ((jj & mask) != 0) continue;
                double p = dp[mask | jj];
                double s = 0;
                for (int k = 0; k < n; k++) {
                    int kk = 1 << k;
                    if ((kk & mask) == 0) continue;
                    s += a[k][j];
                }
                ans += s * pPair * p;
            }
            dp[mask] = ans;
        }

        for (int i = 0; i < n; i++) {
            pw.print(dp[1 << i]);
            pw.print(' ');
        }

        pw.close();
    }
}


import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class E {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static double[][] p;
	static DecimalFormat format = new DecimalFormat("0.000000");

	public static void main(String[] args) throws Exception {
		N = sc.nextInt();
		p = new double[N][N];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				p[i][j] = sc.nextDouble();
			}
		}
		double[] memo = new double[1 << N];
		memo[memo.length - 1] = 1;
		for (int i = N; i >= 2; --i) {
			int[] live = new int[N];
			for (int j = 0; j < i; ++j) {
				live[N - 1 - j] = 1;
			}
			do {
				int n = toInt(live);
				double norm = 2.0 / i / (i - 1);
				for (int f1 = 0; f1 < N; ++f1) {
					if (live[f1] == 0) continue;
					for (int f2 = f1 + 1; f2 < N; ++f2) {
						if (live[f2] == 0) continue;
						memo[n - (1 << f1)] += memo[n] * p[f2][f1] * norm;
						memo[n - (1 << f2)] += memo[n] * p[f1][f2] * norm;
					}
				}
			} while (nextPermutation(live));
			//			System.out.println(Arrays.toString(memo));
		}
		for (int i = 0; i < N; ++i) {
			System.out.print(format.format(memo[1 << i]));
			if (i < N - 1) {
				System.out.print(" ");
			}
		}
	}

	static int toInt(int[] a) {
		int ret = 0;
		for (int i = 0; i < N; ++i) {
			ret += (1 << i) * a[i];
		}
		return ret;
	}

	public static boolean nextPermutation(int[] a) {
		for (int i = a.length - 1; i > 0; --i) {
			if (a[i - 1] < a[i]) {
				int swapIndex = find(a[i - 1], a, i, a.length - 1);
				int temp = a[swapIndex];
				a[swapIndex] = a[i - 1];
				a[i - 1] = temp;
				Arrays.sort(a, i, a.length);
				return true;
			}
		}
		return false;
	}

	private static int find(int dest, int[] a, int s, int e) {
		if (s == e) {
			return s;
		}
		int m = (s + e + 1) / 2;
		return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
	}
}


import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public Main() {
		super();
	}

	public static void main(String... args) {
		Main main = new Main();
		main.start();
	}

	public void start() {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double a[][] = new double[n][n];
		for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = Double.parseDouble(in.next());

		int nn = 1 << n;
		double p[] = new double[nn];
		Arrays.fill(p, -1.0);
        p[nn - 1] = 1.0;

		DecimalFormat f = new DecimalFormat();
		f.applyPattern("0.000000");
		for (int i = 0; i < n; i++) {
			if (i != 0) System.out.print(" ");
			System.out.print(f.format(this.probability(a, p, 1 << i)));
		}
	}

	private double probability(double a[][], double p[], int i) {
        if (p[i] >= 0.0) return p[i];
        double ans = 0;
        int count = Integer.bitCount(i);
        int n = a.length;
        for (int j = 0; j < n; j++) {
            int jj = 1 << j;
            if ((jj & i) == 0) {
                double d = this.probability(a, p, jj | i);
                double dPair = 2.0 / (double)((count + 1) * count);
                double s = 0;
                for (int l = 0; l < n; l++) {
                    int ll = 1 << l;
                    if ((ll & i) != 0) s += a[l][j];
                }
                ans += d * dPair * s;
            }
        }
        p[i] = ans;
        return p[i];
    }

}


import java.util.Scanner;

public class Fishes {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        double[][] p = new double[n][n];
        double[] dp = new double[1 << 18];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                p[i][j] = Double.parseDouble(s.next());
            }
        }
        int last = 1 << n;
        dp[last - 1] = 1.0;
        for (int i = last - 2; i > 0; i--) {
            int res = 0;
            for (int j = 0; j < n; j++) {
                if (((1 << j) & i) > 0) res++;
            }
            res++;
            res = res * (res - 1) / 2;
            for (int j = 0; j < n; j++) {
                if (((1 << j) & i) == 0) {
                    for (int z = 0; z < n; z++) {
                        if (((1 << z) & i) > 0) {
                            dp[i] += dp[i | (1 << j)] * 1.0 / res * p[z][j];
                        }
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.print(dp[1 << i] + " ");
        }
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Trung Pham
 */
public class E {

    public static double[] dp;
    public static double[][] data;
    public static int n;

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        n = in.nextInt();
        data = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                data[i][j] = in.nextDouble();
            }
        }
        dp = new double[1 << n];
        Arrays.fill(dp, -1);
        for (int i = 0; i < n; i++) {
            int a = 1 << i;
            out.print(cal(a) + " ");
        }
        out.close();
        //System.out.print(builder.toString());
    }

    public static double cal(int mask) {
        if (mask == (1 << n) - 1) {
            //  System.out.println(mask);
            return 1;
        }
        if (dp[mask] != -1) {
            return dp[mask];
        }
        double result = 0;
        int c = 0;
        for (int i = 0; i < n; i++) {
            int a = 1 << i;
            if ((a & mask) != 0) {
                c++;
                for (int j = 0; j < n; j++) {
                    int b = 1 << j;
                    if ((b & mask) == 0) {
                        result += (data[i][j] * cal(mask | b));
                    }
                }
            }
        }

        int nC2 = (c + 1) * c / 2;
        dp[mask] = result / nC2;
        return dp[mask];
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Task16e {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[][] prob = new double[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				prob[i][j] = sc.nextDouble();
			}
		}
		double[] var = new double[1 << n];
		boolean[] was = new boolean[1 << n];
		Arrays.fill(var, 0.0);
		Arrays.fill(was, false);
		was[0] = true;
		var[(1 << n) - 1] = 1.0;
		Set<Integer> cr = new HashSet<Integer>();
		Set<Integer> nx = new HashSet<Integer>();
		nx.add((1 << n) - 1);
		boolean[] fish = new boolean[n];
		for (int cnt = 0; cnt < n -1; cnt++) {
			cr.clear();
			cr.addAll(nx);
			nx.clear();
			for (Iterator<Integer> iterator = cr.iterator(); iterator.hasNext();) {
				int curr = iterator.next();
				for (int i = 0; i < n; i++) {
					fish[i] = ((1 << i) & curr) != 0;
				}
				int fishn = 0;
				for (int i = 0; i < n; i++) {
					if (fish[i]) fishn++;
				}
				if (fishn == 1) continue;

				for (int i = 0; i < n; i++) {
					if (!fish[i]) continue;
					for (int j = i + 1; j < n; j++) {
						if (!fish[j]) continue;
						int woi = curr & ~(1 << i);
						int woj = curr & ~(1 << j);
						var[woi] += var[curr] * prob[j][i];
						var[woj] += var[curr] * prob[i][j];
						nx.add(woi);
						nx.add(woj);
					}
				}
			}
		}
		double sum = 0.0;
		for (int i = 0; i < n; i++) {
			sum += var[1 << i];
		}
		for (int i = 0; i < n; i++) {
			System.out.printf("%.6f ", var[1 << i] / sum);
		}
	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskE2 solver = new TaskE2();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++) {
            solver.solve(i, in, out);
        }
        out.close();
    }

    static class TaskE2 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            int[][] a = in.readIntTable(n, m);
            int[][] id = new int[n + 1][1 << n];
            int[][] val = new int[n + 1][1 << n];
            ArrayUtils.fill(id, m);
            int[] sum = new int[1 << n];
            int[] low = new int[1 << n];
            boolean[] base = new boolean[1 << n];
            int[] vv = new int[1 << n];
            for (int i = 1; i < (1 << n); i++) {
                low[i] = Integer.bitCount(Integer.lowestOneBit(i) - 1);
                int current = i;
                base[i] = true;
                vv[i] = i;
                for (int j = 0; j < n; j++) {
                    current = current << 1;
                    current += current >> n;
                    current -= (current >> n) << n;
                    if (current < i) {
                        base[i] = false;
                        vv[i] = vv[current];
                        break;
                    }
                }
            }
            for (int i = 0; i < m; i++) {
                for (int j = 1; j < (1 << n); j++) {
                    sum[j] = sum[j - (1 << low[j])] + a[low[j]][i];
                }
                for (int j = 1; j < (1 << n); j++) {
                    sum[vv[j]] = Math.max(sum[vv[j]], sum[j]);
                }
                for (int j = 1; j < (1 << n); j++) {
                    if (!base[j]) {
                        continue;
                    }
                    for (int k = n - 1; k >= 0; k--) {
                        if (sum[j] > val[k][j]) {
                            val[k + 1][j] = val[k][j];
                            id[k + 1][j] = id[k][j];
                            val[k][j] = sum[j];
                            id[k][j] = i;
                        } else {
                            break;
                        }
                    }
                }
            }
            int[] tempVal = new int[n];
            int[] tempId = new int[n];
            for (int i = 1; i < (1 << n); i++) {
                if (!base[i]) {
                    for (int j = 0; j < n; j++) {
                        val[j][i] = val[j][vv[i]];
                        id[j][i] = id[j][vv[i]];
                    }
                } else {
                    for (int j = 0; j < n; j++) {
                        tempVal[j] = val[j][i];
                        tempId[j] = id[j][i];
                    }
                    ArrayUtils.orderBy(tempId, tempVal);
                    for (int j = 0; j < n; j++) {
                        val[j][i] = tempVal[j];
                        id[j][i] = tempId[j];
                    }
                }
            }
            int[] at = new int[1 << n];
            int[] current = new int[1 << n];
            int[] next = new int[1 << n];
            int all = (1 << n) - 1;
            for (int i = 0; i < m; i++) {
                System.arraycopy(current, 0, next, 0, (1 << n));
                for (int j = 1; j < (1 << n); j++) {
                    if (at[j] == n || id[at[j]][j] != i) {
                        continue;
                    }
                    int other = all - j;
                    for (int k = other; k > 0; k = (k - 1) & other) {
                        next[k + j] = Math.max(next[k + j], current[k] + val[at[j]][j]);
                    }
                    next[j] = Math.max(next[j], val[at[j]][j]);
                    at[j]++;
                }
                int[] temp = current;
                current = next;
                next = temp;
            }
            out.printLine(current[all]);
        }

    }

    static abstract class IntAbstractStream implements IntStream {
        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }

        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }

        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }

    }

    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);

        public abstract void set(int index, int value);

        public abstract void addAt(int index, int value);

        public abstract void removeAt(int index);

        default public void swap(int first, int second) {
            if (first == second) {
                return;
            }
            int temp = get(first);
            set(first, get(second));
            set(second, temp);
        }

        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }

        default public void add(int value) {
            addAt(size(), value);
        }

        default public IntList sort(IntComparator comparator) {
            Sorter.sort(this, comparator);
            return this;
        }

        default public IntList subList(final int from, final int to) {
            return new IntList() {
                private final int shift;
                private final int size;

                {
                    if (from < 0 || from > to || to > IntList.this.size()) {
                        throw new IndexOutOfBoundsException("from = " + from + ", to = " + to + ", size = " + size());
                    }
                    shift = from;
                    size = to - from;
                }

                public int size() {
                    return size;
                }

                public int get(int at) {
                    if (at < 0 || at >= size) {
                        throw new IndexOutOfBoundsException("at = " + at + ", size = " + size());
                    }
                    return IntList.this.get(at + shift);
                }

                public void addAt(int index, int value) {
                    throw new UnsupportedOperationException();
                }

                public void removeAt(int index) {
                    throw new UnsupportedOperationException();
                }

                public void set(int at, int value) {
                    if (at < 0 || at >= size) {
                        throw new IndexOutOfBoundsException("at = " + at + ", size = " + size());
                    }
                    IntList.this.set(at + shift, value);
                }

                public IntList compute() {
                    return new IntArrayList(this);
                }
            };
        }

    }

    static interface IntCollection extends IntStream {
        public int size();

        default public void add(int value) {
            throw new UnsupportedOperationException();
        }

        default public int[] toArray() {
            int size = size();
            int[] array = new int[size];
            int i = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                array[i++] = it.value();
            }
            return array;
        }

        default public IntCollection addAll(IntStream values) {
            for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
            return this;
        }

    }

    static interface IntIterator {
        public int value() throws NoSuchElementException;

        public boolean advance();

        public boolean isValid();

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int[][] readIntTable(int rowCount, int columnCount) {
            int[][] table = new int[rowCount][];
            for (int i = 0; i < rowCount; i++) {
                table[i] = readIntArray(columnCount);
            }
            return table;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = readInt();
            }
            return array;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class Range {
        public static IntList range(int from, int to) {
            int[] result = new int[Math.abs(from - to)];
            int current = from;
            if (from <= to) {
                for (int i = 0; i < result.length; i++) {
                    result[i] = current++;
                }
            } else {
                for (int i = 0; i < result.length; i++) {
                    result[i] = current--;
                }
            }
            return new IntArray(result);
        }

    }

    static class ArrayUtils {
        public static void fill(int[][] array, int value) {
            for (int[] row : array) {
                Arrays.fill(row, value);
            }
        }

        public static int[] range(int from, int to) {
            return Range.range(from, to).toArray();
        }

        public static int[] createOrder(int size) {
            return range(0, size);
        }

        public static int[] sort(int[] array, IntComparator comparator) {
            return sort(array, 0, array.length, comparator);
        }

        public static int[] sort(int[] array, int from, int to, IntComparator comparator) {
            if (from == 0 && to == array.length) {
                new IntArray(array).sort(comparator);
            } else {
                new IntArray(array).subList(from, to).sort(comparator);
            }
            return array;
        }

        public static int[] order(final int[] array) {
            return sort(createOrder(array.length), new IntComparator() {
                public int compare(int first, int second) {
                    if (array[first] < array[second]) {
                        return -1;
                    }
                    if (array[first] > array[second]) {
                        return 1;
                    }
                    return 0;
                }
            });
        }

        public static void orderBy(int[] base, int[]... arrays) {
            int[] order = ArrayUtils.order(base);
            order(order, base);
            for (int[] array : arrays) {
                order(order, array);
            }
        }

        public static void order(int[] order, int[] array) {
            int[] tempInt = new int[order.length];
            for (int i = 0; i < order.length; i++) {
                tempInt[i] = array[order[i]];
            }
            System.arraycopy(tempInt, 0, array, 0, array.length);
        }

    }

    static class IntArrayList extends IntAbstractStream implements IntList {
        private int size;
        private int[] data;

        public IntArrayList() {
            this(3);
        }

        public IntArrayList(int capacity) {
            data = new int[capacity];
        }

        public IntArrayList(IntCollection c) {
            this(c.size());
            addAll(c);
        }

        public IntArrayList(IntStream c) {
            this();
            if (c instanceof IntCollection) {
                ensureCapacity(((IntCollection) c).size());
            }
            addAll(c);
        }

        public IntArrayList(IntArrayList c) {
            size = c.size();
            data = c.data.clone();
        }

        public IntArrayList(int[] arr) {
            size = arr.length;
            data = arr.clone();
        }

        public int size() {
            return size;
        }

        public int get(int at) {
            if (at >= size) {
                throw new IndexOutOfBoundsException("at = " + at + ", size = " + size);
            }
            return data[at];
        }

        private void ensureCapacity(int capacity) {
            if (data.length >= capacity) {
                return;
            }
            capacity = Math.max(2 * data.length, capacity);
            data = Arrays.copyOf(data, capacity);
        }

        public void addAt(int index, int value) {
            ensureCapacity(size + 1);
            if (index > size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size) {
                System.arraycopy(data, index, data, index + 1, size - index);
            }
            data[index] = value;
            size++;
        }

        public void removeAt(int index) {
            if (index >= size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size - 1) {
                System.arraycopy(data, index + 1, data, index, size - index - 1);
            }
            size--;
        }

        public void set(int index, int value) {
            if (index >= size) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            data[index] = value;
        }

        public int[] toArray() {
            return Arrays.copyOf(data, size);
        }

    }

    static interface IntReversableCollection extends IntCollection {
    }

    static class IntArray extends IntAbstractStream implements IntList {
        private int[] data;

        public IntArray(int[] arr) {
            data = arr;
        }

        public int size() {
            return data.length;
        }

        public int get(int at) {
            return data[at];
        }

        public void addAt(int index, int value) {
            throw new UnsupportedOperationException();
        }

        public void removeAt(int index) {
            throw new UnsupportedOperationException();
        }

        public void set(int index, int value) {
            data[index] = value;
        }

    }

    static interface IntComparator {
        public int compare(int first, int second);

    }

    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();

        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }

        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }

    }

    static class Sorter {
        private static final int INSERTION_THRESHOLD = 16;

        private Sorter() {
        }

        public static void sort(IntList list, IntComparator comparator) {
            quickSort(list, 0, list.size() - 1, (Integer.bitCount(Integer.highestOneBit(list.size()) - 1) * 5) >> 1,
                    comparator);
        }

        private static void quickSort(IntList list, int from, int to, int remaining, IntComparator comparator) {
            if (to - from < INSERTION_THRESHOLD) {
                insertionSort(list, from, to, comparator);
                return;
            }
            if (remaining == 0) {
                heapSort(list, from, to, comparator);
                return;
            }
            remaining--;
            int pivotIndex = (from + to) >> 1;
            int pivot = list.get(pivotIndex);
            list.swap(pivotIndex, to);
            int storeIndex = from;
            int equalIndex = to;
            for (int i = from; i < equalIndex; i++) {
                int value = comparator.compare(list.get(i), pivot);
                if (value < 0) {
                    list.swap(storeIndex++, i);
                } else if (value == 0) {
                    list.swap(--equalIndex, i--);
                }
            }
            quickSort(list, from, storeIndex - 1, remaining, comparator);
            for (int i = equalIndex; i <= to; i++) {
                list.swap(storeIndex++, i);
            }
            quickSort(list, storeIndex, to, remaining, comparator);
        }

        private static void heapSort(IntList list, int from, int to, IntComparator comparator) {
            for (int i = (to + from - 1) >> 1; i >= from; i--) {
                siftDown(list, i, to, comparator, from);
            }
            for (int i = to; i > from; i--) {
                list.swap(from, i);
                siftDown(list, from, i - 1, comparator, from);
            }
        }

        private static void siftDown(IntList list, int start, int end, IntComparator comparator, int delta) {
            int value = list.get(start);
            while (true) {
                int child = ((start - delta) << 1) + 1 + delta;
                if (child > end) {
                    return;
                }
                int childValue = list.get(child);
                if (child + 1 <= end) {
                    int otherValue = list.get(child + 1);
                    if (comparator.compare(otherValue, childValue) > 0) {
                        child++;
                        childValue = otherValue;
                    }
                }
                if (comparator.compare(value, childValue) >= 0) {
                    return;
                }
                list.swap(start, child);
                start = child;
            }
        }

        private static void insertionSort(IntList list, int from, int to, IntComparator comparator) {
            for (int i = from + 1; i <= to; i++) {
                int value = list.get(i);
                for (int j = i - 1; j >= from; j--) {
                    if (comparator.compare(list.get(j), value) <= 0) {
                        break;
                    }
                    list.swap(j, j + 1);
                }
            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class E {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int T = Integer.parseInt(bf.readLine());
        for(int t=0; t<T; t++) {
          StringTokenizer st = new StringTokenizer(bf.readLine());
          int n = Integer.parseInt(st.nextToken());
          int m = Integer.parseInt(st.nextToken());
          int[][] a = new int[n][m];
          for(int i=0; i<n; i++) {
            st = new StringTokenizer(bf.readLine());
            for(int j=0; j<m; j++) a[i][j] = Integer.parseInt(st.nextToken());

          }
          // small case
          int[] max = new int[m];
          for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
              if(a[i][j] > max[j]) max[j] = a[i][j];
            }
          }
          int[][] pos = new int[m][2];
          for(int i=0; i<m; i++) {
            pos[i][0] = max[i];
            pos[i][1] = i;
          }
          Arrays.sort(pos, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
              return Integer.compare(o2[0], o1[0]);
            }
          });

          int[][] new_a = new int[n][Math.min(n,m)];
          for(int i=0; i<n; i++) {
            for(int j=0; j<Math.min(n,m); j++) {
              new_a[i][j] = a[i][pos[j][1]];
            }
          }
          int exp = 1; for(int i=0; i<Math.min(n,m); i++) exp *= n;
          int maxval = -1;
          for(int i=0; i<exp; i++) {
          //  int val = i;
            int sum = 0;
            for(int j=0; j<n; j++) {
              int toAdd = 0;
              int val = i;
              for(int k=0; k<Math.min(n,m); k++) {
                int tooAdd = new_a[(j+val)%n][k];
                val /= n;
                if(tooAdd > toAdd) toAdd = tooAdd;
              }
              sum += toAdd;
            }
            if(sum > maxval) maxval = sum;
          }
          out.println(maxval);

        }

        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}


import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class mainE {
    public static PrintWriter out = new PrintWriter(System.out);
    public static FastScanner enter = new FastScanner(System.in);
    public static void main(String[] args) throws IOException {
        int t=enter.nextInt();
        for (int i = 0; i < t; i++) {
            solve();
        }
        out.close();
    }
    public static int[][] arr=new int[13][2010];
    public static pair[] par= new pair[2010];
    private static void solve() throws IOException{
        int n=enter.nextInt();
        int m=enter.nextInt();
        for (int i = 0; i <n ; i++) {
            for (int j = 0; j <m ; j++) {
                arr[i][j]=enter.nextInt();
            }
        }
        for (int i = 0; i <n ; i++) {
            for (int j = m; j <m+3 ; j++) {
                arr[i][j]=0;
            }
        }
        m=m+3;

        for (int i = 0; i <m ; i++) {
            int max=-1;
            for (int j = 0; j <n ; j++) {
                max=Math.max(arr[j][i], max);
            }
            par[i]=new pair(max,i);
        }
        Arrays.sort(par,0,m, pair::compareTo);

        int i0=par[0].st;
        int i1=par[1].st;
        int i2=par[2].st;
        int i3=par[3].st;
        int ans=-1;
        for (int i = 0; i <n ; i++) {
            for (int j = 0; j <n ; j++) {
                for (int k = 0; k <n ; k++) {
                    for (int l = 0; l <n ; l++) {
                        int first=Math.max(Math.max(arr[i][i0],arr[j][i1]), Math.max(arr[k][i2],arr[l][i3]));
                        int second=Math.max(Math.max(arr[(i+1)%n][i0],arr[(j+1)%n][i1]), Math.max(arr[(k+1)%n][i2],arr[(l+1)%n][i3]));
                        int third=Math.max(Math.max(arr[(i+2)%n][i0],arr[(j+2)%n][i1]), Math.max(arr[(k+2)%n][i2],arr[(l+2)%n][i3]));
                        int fourth=Math.max(Math.max(arr[(i+3)%n][i0],arr[(j+3)%n][i1]), Math.max(arr[(k+3)%n][i2],arr[(l+3)%n][i3]));
                        if(n==1) {
                            second=0;
                            third=0;
                            fourth=0;
                        }
                        else if(n==2){
                            third=0;
                            fourth=0;
                        }
                        else if(n==3){
                            fourth=0;
                        }
                        ans=Math.max(ans, first+second+fourth+third);

                    }
                }
            }
        }
        System.out.println(ans);

    }

    static class pair implements Comparable<pair>{
        int max,st;

        public pair(int max, int st) {
            this.max = max;
            this.st = st;
        }

        @Override
        public int compareTo(pair o) {
            return -Integer.compare(max, o.max);
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return null;
                }
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        char nextChar() throws IOException {
            return (char) (br.read());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE2 solver = new TaskE2();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskE2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            TaskE2.Column[] columns = new TaskE2.Column[m];
            for (int i = 0; i < m; ++i) columns[i] = new TaskE2.Column(new int[n]);
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    columns[j].vals[i] = in.nextInt();
                }
            }
            for (int i = 0; i < m; ++i) columns[i].initMax();
            Arrays.sort(columns, new Comparator<TaskE2.Column>() {

                public int compare(TaskE2.Column o1, TaskE2.Column o2) {
                    return o2.max - o1.max;
                }
            });
            if (columns.length > n) {
                columns = Arrays.copyOf(columns, n);
            }
            out.println(solveOne(columns));
        }

        private int solveOne(TaskE2.Column[] columns) {
            int n = columns[0].vals.length;
            int[] best = new int[1 << n];
            int[] next = new int[1 << n];
            int[] tmp = new int[1 << n];
            for (TaskE2.Column c : columns) {
                System.arraycopy(best, 0, next, 0, best.length);
                for (int rot = 0; rot < n; ++rot) {
                    System.arraycopy(best, 0, tmp, 0, best.length);
                    for (int i = 0, pos = rot; i < n; ++i, ++pos) {
                        if (pos >= n) pos = 0;
                        int val = c.vals[pos];
                        for (int j = 0; j < tmp.length; ++j)
                            if ((j & (1 << i)) == 0) {
                                tmp[j ^ (1 << i)] = Math.max(tmp[j ^ (1 << i)], tmp[j] + val);
                            }
                    }
                    for (int j = 0; j < tmp.length; ++j) {
                        next[j] = Math.max(next[j], tmp[j]);
                    }
                }
                int[] aa = best;
                best = next;
                next = aa;
            }
            return best[best.length - 1];
        }

        static class Column {
            int[] vals;
            int max;

            public Column(int[] vals) {
                this.vals = vals;
            }

            void initMax() {
                max = 0;
                for (int x : vals) max = Math.max(max, x);
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE2 solver = new TaskE2();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE2 {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int t = in.nextInt();
            while (t-- > 0) {
                int n = in.nextInt(), m = in.nextInt();
                int[][] a = new int[m][n];
                int[] bestMask = new int[1 << n];
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        a[j][i] = in.nextInt();
                    }
                }
                int[] dp = new int[1 << n];
                for (int i = 0; i < m; i++) {
                    int[] array = a[i];
                    for (int j = 0; j < n; j++) {
                        int val = array[j];
                        for (int mask = 0; mask < 1 << n; mask++) {
                            if ((mask & (1 << j)) == 0) {
                                dp[mask | (1 << j)] = Math.max(dp[mask | (1 << j)], dp[mask] + val);
                            }
                        }
                    }
                    for (int mask = 0; mask < 1 << n; mask++) {
                        int best = 0;
                        int cur = mask;
                        for (int j = 0; j < n; j++) {
                            best = Math.max(best, dp[cur]);
                            cur = (cur >> 1) | ((cur & 1) << (n - 1));
                        }
                        for (int j = 0; j < n; j++) {
                            dp[cur] = best;
                            cur = (cur >> 1) | ((cur & 1) << (n - 1));
                        }
                    }
                }
                out.println(dp[(1 << n) - 1]);
            }
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}


import java.io.*;
import java.util.*;

public class E implements Runnable {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int t = scn.nextInt();
		while(t-- > 0) {
			int n = scn.nextInt(), m = scn.nextInt();
			int[][] arr = scn.next2DInt(n, m);

			int[][] col = new int[m][2];
			for(int j = 0; j < m; j++) {
				int max = 0;
				for(int i = 0; i < n; i++) {
					max = Math.max(max, arr[i][j]);
				}
				col[j][0] = max;
				col[j][1] = j;
			}
			Arrays.parallelSort(col, (o1, o2) -> o2[0] - o1[0]);

			int take = Math.min(n, m);

			int[][] lol = new int[n][take];
			for(int j = 0; j < take; j++) {
				for(int i = 0; i < n; i++) {
					lol[i][j] = arr[i][col[j][1]];
				}
			}

			ans = 0;
			func(lol, 0);
			out.println(ans);
		}
	}

	int ans = 0;

	void func(int[][] arr, int col) {
		int n = arr.length, m = arr[0].length;
		if(col == m) {
			int rv = 0;
			for(int i = 0; i < n; i++) {
				int mx = 0;
				for(int j = 0; j < m; j++) {
					mx = Math.max(mx, arr[i][j]);
				}
				rv += mx;
			}
			ans = Math.max(ans, rv);
			return;
		}

		for(int rot = 0; rot < n; rot++) {
			int f = arr[0][col];
			for(int j = 1; j < n; j++) {
				arr[j - 1][col] = arr[j][col];
			}
			arr[n - 1][col] = f;
			func(arr, col + 1);
		}
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new E(), "Main", 1 << 26).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		String nextLine() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}


import java.util.*;
import java.io.*;

public class E {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out, false);
        int t = scanner.nextInt();
        while(t-->0) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[][] cols = new int[m][n];
            for(int i = 0; i < n; i++) {
                for(int j =0; j < m; j++) {
                    cols[j][i] = scanner.nextInt();
                }
            }
            int maxMask = 1 << n;
            int[] dp = new int[maxMask];
            Arrays.fill(dp, -1);
            dp[0] = 0;
            for(int i = 0; i < m; i++) {
                for(int mask = maxMask-1; mask>=0; mask--) {
                    int[] arr = cols[i].clone();
                    for(int j = 0; j < n; j++) {
                        for(int smask = mask; smask >= 0; smask = (smask-1)&mask) {
                            if (dp[smask] == -1) continue;
                            int add = 0;
                            for(int k = 0; k < n; k++) {
                                if (((mask^smask)&(1 << k)) > 0) add += arr[k];
                            }
                            dp[mask] = Math.max(dp[mask], dp[smask] + add);
                            if (smask == 0) break;
                        }
                        arr = shift(arr);
                    }
                }
            }
            out.println(dp[maxMask-1]);
        }
        out.flush();
    }
    static int[] shift (int[] a) {
        int[] b = new int[a.length];
        b[0] = a[a.length-1];
        for(int i = 0; i < a.length-1; i++) {
            b[i+1] = a[i];
        }
        return b;
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1209e1_2 {

    public static void main(String[] args) throws IOException {
        int t = ri();
        while (t --> 0) {
            int n = rni(), m = ni(), a[][] = new int[m][n], dp[] = new int[1 << n];
            for (int i = 0; i < n; ++i) {
                int[] row = ria(m);
                for (int j = 0; j < m; ++j) {
                    a[j][i] = row[j];
                }
            }
            for (int i = 0; i < m; ++i) {
                for (int r = 0; r < 1 << n; ++r) {
                    for (int j = 0; j < n; ++j) {
                        if ((r & (1 << j)) == 0) {
                            continue;
                        }
                        dp[r] = max(dp[r], dp[r ^ (1 << j)] + a[i][j]);
                    }
                }
                for (int r = 0; r < 1 << n; ++r) {
                    int s = r;
                    for (int j = 0; j < n; ++j) {
                        if ((s & 1) != 0) {
                            s = (s >> 1) | (1 << (n - 1));
                        } else {
                            s >>= 1;
                        }
                        dp[s] = max(dp[s], dp[r]);
                    }
                }
            }
            prln(dp[(1 << n) - 1]);
        }
        close();
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static boolean pryesno(boolean b) {prln(b ? "yes" : "no"); return b;};
    static boolean pryn(boolean b) {prln(b ? "Yes" : "No"); return b;}
    static boolean prYN(boolean b) {prln(b ? "YES" : "NO"); return b;}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}
}