INPUT Problem for Lcd display

I want to display some information on lcd when I input the number Thirteen( 1pin +2pin) = HIGH. The problem is when it comes for thirty-one, for 31 the same pin is used so the information that should be in 13 is now displayed...what should I do???

We are going to need a lot more information to help. Post your code. Post your schematic. What board are you using? How to get the best out of this forum

Detect which comes first 1, or 3

read if you have received "13" --> switch your pins
if you have received something different --> don switch your pins.