NIT Jsr Premier League

All submissions for this problem are available.
The new season of the NIT JSR Premier League(NPL) has started!
In the NPL, any two soccer teams play with each other exactly once. In each match, the winner earns 3 points and the
loser earns no point. There is no draw (if the match is level after the two halves, two teams will take part in a
penalty shootout to decide the winner).
At the end of the league, the winner is the team having the largest number of points. In case there are more than one
team which has the largest number of points, these teams will be cochampions of the league.
The league has been running for some time. Now, the following problem has arisen: we would like to know if a specific
team still has a chance of winning the league.
Input
The first line contains T (about 100), the number of test cases.
Then T test cases follow. Each test case has the
following form.
The first line of the test case contains a number N (1 <= N <= 100), the number of teams in the league.
The ith line in the next N lines contains N numbers ai1, ai2, ..., ain. The number aij gives the status of the match
between the ith team and the jth team:
aij = 1 if the ith team wins,
aij = 0 if the ith team loses,
aij = 2 if the match has not taken place yet.
The input data is such that if i!=j, then aij + aji = 1 or aij = aji = 2. Moreover, aii = 0 for all i.
Output
For each test case, print a binary string of length N, in which the ith character is 1 if the ith team still has a chance to be a champion of the league, and 0 otherwise.
Example
Input: 3 3 0 0 0 1 0 1 1 0 0 4 0 1 1 0 0 0 2 0 0 2 0 0 1 1 1 0 5 0 2 2 1 0 2 0 1 1 0 2 0 0 1 0 0 0 0 0 1 1 1 1 0 0 Output: 010 0001 11001
Author:  pacific35 
Tags  pacific35 
Date Added:  8102015 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, 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, TCL, PERL6, TEXT, SCM chicken, 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. 