So I take the derivative with regards to "l" on top and do the same with respect to "k" on bottom...

From what you've posted, K (or k?) is "on top", so I'm not sure what you mean by "to 'k' on bottom"...? Also, you posted this to "pre-algebra", but then refer to taking derivatives (from post-algebra calculus)...?

How do X, K, L, w, r, l, and k relate? With respect to what are you differentiating? What are you differentiating? What are the necessary formulas and relations? What are you trying to accomplish?