Find all members home 's position
for i in range ( ROW ) : NEW_LINE INDENT for j in range ( COL ) : NEW_LINE INDENT if grid [ i ] [ j ] == 1 : NEW_LINE INDENT vertical . append ( i ) NEW_LINE horizontal . append ( j ) NEW_LINE DEDENT DEDENT DEDENT