SP423 ASSIGN - Assignments

Description

Your task will be to calculate number of different assignments of $n$ different topics to $n$ students such that everybody gets exactly one topic he likes.

Input Format

First line of input contains number of test cases $c(1 \le c \le 80)$. Each test case begins with number of students $n(1\le n\le 20)$. Each of the next $n$ lines contains $n$ integers describing preferences of one student. $1$ at the ith position means that this student likes ith topic, $0$ means that he definitely doesn't want to take it.

Output Format

For each test case output number of different assignments (it will fit in a signed 64-bit integer).