Even Coefficients

All submissions for this problem are available.
In this problem, you are given a polynomial P over multiple variables with integer coefficients and your task is simply to determine if all of the coefficients are even or not.
Unfortunately, you will not be given an explicit description of the polynomial. Rather, you will be given a square matrix whose entries are polynomials and the polynomial P is the determinant of this matrix.
Here, we are defining the determinant of a matrix by the usual cofactor expansion formula. That is, say the matrix M is of size d x d and denote the polynomial located at row i, column j by M_{i,j} for any i,j between 1 and d. For a permutation X on the set {1,2,...,d}, let sgn(X) be (1)^{inv(X)} where inv(X) is the number of pairs 1 ≤ i < j ≤ d with X(i) > X(j) (i.e. the number of inversions of X). Then the determinant of M is the sum, over all permutations X, of the products sgn(X)M_{1,X(1)}M_{2,X(2)}...M_{d,X(d)}.
Input
The first line consists of a value k ≤ 30 indicating the number of test cases. Each test case begins with a single line containing an integer d, 1 ≤ d ≤ 40 indicating the order of the matrix. Then, d lines follow where each contains d strings describing the polynomials. The j'th string on the i'th line describes entry M_{i,j} of the polynomial matrix. The d strings on a single line are separated by a single space.
Each polynomial is given by a string of length between 1 and 100. A monomial is either the string '0', or the string '1', or a string of lowercase characters 'a','b', ..., 'z'. A polynomial is then a sequence of monomials separated by '+' with no spaces. The monomials '0' or '1' are simply the respective constant polynomials and a monomial consisting of a string of lowercase letters is simply the product of variables a, b, ..., z where the power of a letter, say L, is exactly the number of times it appears in the string. For example, "1+aba" is the string representing the polynomial 1+a^{2}b and "0+xy+yx" represents the polynomial 2xy.
Output
The output for each test case consists of a single line containing the message "All Even" or "Some Odd" to indicate if all coefficients of the polynomial represented by the determinant of the matrix are even or if there is at least one odd coefficient, respectively.
Example
Input: 3 2 x+1 0 0 x 3 x y z y z x xx+xy xy+xz xx+xz 1 a+a Output: Some Odd All Even All Even
Explanation of Sample Data
The determinant in the first test case is simply x^{2}+x which has two odd coefficients. A tedious calculation shows that the determinant in the second test case is actually 0. The last test case has determinant 2a, so all coefficients are even.
Author:  friggstad 
Tester:  pieguy 
Editorial  http://discuss.codechef.com/problems/EVENPOLY 
Tags  dec10, friggstad, hard 
Date Added:  8112010 
Time Limit:  0.65 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 