taking firm1 as an example
Differentiate u() with respect to q1, treating q2 as a constant. You'll need to use the quotient rule.
you'll probably end up with a nasty looking fraction with a quadratic numerator and a messy denominator.
The "trick" in this type of problem is normally that you can ignore the denominator, you want the first derivative=0 which means the numerator must be zero. Find the value of q1 that makes the numerator zero.
If you need further help post your entire solution up to the point you get stuck.