def L(u,n):
    L=[u]
    h=u
    for k in range(n):
        if L[k]>h:
            h=L[k]
        if L[k]%2==0:
            L.append(L[k]//2)
        else:
            L.append(3*L[k]+1)
    return L,h

print(L(18,23))
print(L(127,50))
