"Il faut" is a whole expression, you have to use it as a whole.
The il is the impersonal form. It's not always it, it can be one sometimes.
An equivalent could be "On doit" (translated in English by "one should", "one must" depending on the sentence).
Il faut faire un exercice = We have to do an exercise. We must do an exercise.
In French, it will be the same "il faut" for an advice and for a strong obligation.
So "Quel exercice faut-il faire/doit-on faire ?" (the more formal and correct form) or "Quel exercice il faut faire ?", etc, are constructed with "Quel exercice" + the whole "il faut" or "faut-il" expression.
Faut-il faire l'exercice de math ?
Doit-on faire tous les exercices de la page ?
All these forms are formal.
On doit apprendre cette leçon ?
Est-ce qu'on doit faire les exercices ?
Il faut faire quel exercice ? and Quel exercice il faut faire ? are the same but the first one is very informal.
Quel translate to what OR which, depending on the sentence.
- Which exercise should we do? = Quel exercice devons nous faire ?
Because lequel is only used when you have a clear choice:
- Je prends un crayon sur la table. Lequel ? (which one?).
Lequel is NEVER a question word. So, it's easy when you have which in a question, it's always quel.
To know how to translate,
- ask yourself whether there is a clear choice between several things.
- and whether it's a question word.