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^\circ\) from \(Y\). \(Q\) is on a bearing of \(040^\circ\) from \(X\) and on a bearing of \(010^\circ\) from \(Y\). If the distance between \(X\) and \(Y\) is \(4\) miles, calculate the distance of the two ships from the shore.