UPS Wiring Issue

The wiring is done such that all fans and tube lights are connected through a wire, it goes through each room. The wire is connected to the UPS.... to the back side, where it receives backup power from the ups

the UPS receives direct current (input voltage) from the socket in one room.... this is another wire

if i connect this wire to the other wire (it is connected directly to wapda current and UPS will not work)

but it is connected through UPS (for backup)

now the problem is that the UPS is not receiving any input voltage, however, when I directly connect the other two wires, the fans and tubelights work...

I also connected UPS to another socket, and it is receiving input voltage, so whats problem????

btw we faced phase problem yesterday, as a result none of the fans worked, as all the fans and tube lights are connect through UPS, and the UPS receives power from that phase. So yeah no fan worked. but problem was resolved this morning, and i am facing this issue.