Performing salaah with the urge of relieving oneself
Q: I am taking a class that goes from 5:30 pm to 8:30 pm. Hence it covers asr and maghrib prayers. The class is located far away from where I live. In order to maintain purity (wudhu) for both prayers (there is no cleaning facility at the class location) I used to hold myself not to urine during the entire 3 hour session. Hence for both prayers, especially for the maghrib prayer, I am exerting a huge effort not to let anything come out during the prayer (3 hours are very long). Is my prayer valid?
In addition, even though I tried my best, I cannot guarantee that my pants is 100% clean when I start praying as it is possible that some urine come out while I was in the classroom (that is outside the prayer, before it starts). Does this possible impurity affect my prayer? I almost did my best but I really don't know if my prayers are valid.