<s>[INST] def list_triangles(n):
    """
    This function prints all distinct triangles with integer sides that can be constructed
    with a perimeter of exactly n.
    
    Parameters:
    n (int): The perimeter of the triangle
    
    Returns:
    None
    """
    for a in range(1, n//3 + 1):
        for b in range(a, (n - a) // 2 + 1):
            c = n - a - b
            if a + b > c and a + c > b and b + c > a:
                if a**2 + b**2 == c**2 or a**2 + c**2 == b**2 or b**2 + c**2 == a**2:
                    print(f"Side lengths: {a}, {b}, {c}")[/INST]