I am working on a phase detection project in which i am trying to find the order in which the incoming signal comes. I converted the 240v 50hz Ac signal to a 7v 50hz square pulse. when i connect one(7v 50hz) of the three lines to a digital pin on arduino it is properly detecting, but the problem is if i check the unconnected pins via oscilloscope i am getting the same signal which i connected as input, so when i connect another line to any other pin the two signals are getting added.
(Image 1)this is what i see in the DSO when i connect one line to the arduino pin and observe other pins
.(Image 2)this is what i get after i give another line as input to arduino and observe the pins.
i tried with 2 to 3 boards but i still get the same problem.

simulate this circuit – Schematic created using CircuitLab
this is the schematic i used for converting the sine wave into square wave, i used 4n33 optocoupler for this purpose.