It may also be possible to book this on one tickets as a multi city using SFO-MAD and then MAD-LIS as your second pair. This will depend on multiple things going right, such as UA even able to sell LIS-MAD, and in the discount fare buckets. UA has a habit of not verifying married segment inventory, etc. and might (note I say, might) fare it with the sale and then continuing on. YMMV.
but yes, UA/AC should both interline with TP - they are all *A, after all.