def do_action_two(lights, instruction):
    """
    >>> from collections import defaultdict
    >>> lights = [[0 for j in range(2)] for i in range(2)]
    >>> do_action_two(lights, "turn on 0,0 through 1,1")
    [[1, 1], [1, 1]]
    >>> do_action_two(lights, "toggle 0,0 through 1,1")
    [[3, 3], [3, 3]]
    >>> do_action_two(lights, "turn off 0,0 through 1,1")
    [[2, 2], [2, 2]]
    >>> do_action_two(lights, "toggle 0,0 through 0,0")
    [[4, 2], [2, 2]]
    """
    action = instruction.split(" ")

    if "on" in action:
        start = [int(i) for i in action[2].split(",")]
        end = [int(i) for i in action[4].split(",")]
        for i in range(start[0], end[0]+1):
            for j in range(start[1], end[1]+1):
                lights[i][j] += 1

    elif "off" in action:
        start = [int(i) for i in action[2].split(",")]
        end = [int(i) for i in action[4].split(",")]
        for i in range(start[0], end[0]+1):
            for j in range(start[1], end[1]+1):
                lights[i][j] = max(0, lights[i][j] - 1)

    else:
        start = [int(i) for i in action[1].split(",")]
        end = [int(i) for i in action[3].split(",")]
        for i in range(start[0], end[0]+1):
            for j in range(start[1], end[1]+1):
                lights[i][j] += 2

    return lights