def solve(_n, tree):
    """
    Given a list of list of tokens:
    . (empty), or # (tree), compute the
    number of trees one would encounter
    if one traverses the 2D grid along
    a slope of (3, 1).
    :param _n: The number of rows in the
               2D grid.
    :param tree: The 2D grid as a list of list.

    :return: The number of trees encountered on
             a traversal along the slope (3, 1).
    """

    _i, _j = 0, 0
    count = 0

    _col = len(tree[0])

    while _i + 1 < _n:
        _j = (_j + 3) % _col
        _i += 1
        if tree[_i][_j] == "#":
            count += 1

    return count