Find the value of \( p \) if the shortest distance between the lines \( \vec{r} = (\hat{i} + 2\hat{j} + \hat{k}) + \lambda(\hat{i} - \hat{j} + \hat{k}) \) and \( \vec{r} = (p\hat{i} - \hat{j} - \hat{k}) + \mu(2\hat{i} + \hat{j} + 2\hat{k}) \) is \( \frac{3}{\sqrt{2}} \) units.