def get_submatrix(m, rows, cols):
    """
      Gets the selected positions from the matrix and inserts them into the submatrix.

      Args:
        m: the larger matrix
        rows: list of the indexes of the rows to select from
        cols: list of the indexes of the columns to select from

      Returns:
        submatrix: the matrix filled with the selected values
    """
    submatrix = []
    for row in rows:
        new_row = []
        for col in cols:
            new_row.append(m[row][col])
        submatrix.append(new_row)
    return submatrix