Two ships P and Q are simultaneously observed from two points X and Y on a straight coastline running from west to east. P is due north of X and lies on a bearing of 300∘ from Y. Q is on a bearing of 040∘ from X and on a bearing of 010∘ from Y. If the distance between X and Y is 4 miles, calculate the distance of the two ships from the shore.