# a=b=list/dict is bad practice
# because they are referencing the same object

class TicTacToe(object):

    def __init__(self, n):
        """
        Initialize your data structure here.
        :type n: int
        """
        #self.grid = [['']*n for _ in xrange(n)]
        self.rows = {1: {}, 2:{}}
        self.cols = {1: {}, 2:{}}
        self.diag1 = {1: 0, 2: 0}
        self.diag2 = {1: 0, 2: 0}
        self.n = n

    def move(self, row, col, player):
        """
        Player {player} makes a move at ({row}, {col}).
        @param row The row of the board.
        @param col The column of the board.
        @param player The player, can be either 1 or 2.
        @return The current winning condition, can be either:
                0: No one wins.
                1: Player 1 wins.
                2: Player 2 wins.
        :type row: int
        :type col: int
        :type player: int
        :rtype: int
        """
    
        if row in self.rows[player]:
            self.rows[player][row] += 1
        else:
            self.rows[player][row] = 1
            
        if self.rows[player][row] == self.n:
            return player

        if col in self.cols[player]:
            self.cols[player][col] += 1
        else:
            self.cols[player][col] = 1
            
        if self.cols[player][col] == self.n:
            return player

        if row == col:
            self.diag1[player] += 1
            if self.diag1[player] == self.n:
                return player

        if row + col == self.n - 1:
            self.diag2[player] += 1
            if self.diag2[player] == self.n:
                return player
        return 0

# Your TicTacToe object will be instantiated and called as such:
# obj = TicTacToe(n)
# param_1 = obj.move(row,col,player)
