2. For a positive integer $n$, let $\varphi(n)$ denote the number of positive integers not exceeding $n$ that are coprime to $n$, and let $f(n)$ denote the smallest positive integer greater than $n$ that is not coprime to $n$. If $f(n)=m$ and $\varphi(m)=n$, then the pair of positive integers $(n, m)$ is called a friendly pair. Find all friendly pairs.
(Liu Kaifeng, problem contributor)
2. Let the smallest prime factor of $n$ be $p$, then $f(n)=n+p$, so $n+p=m$, so $\varphi(m)=\varphi(n+p)=n$. Suppose $n+p=p a$, then $p, 2 p, \cdots, a p$ are not coprime with $n+p$, so $n=\varphi(n+p) \leqslant n+p-a$, so $a \leqslant p \Rightarrow n+p=p a \leqslant p^{2} \Rightarrow n \leqslant p(p-1)$.

Thus, $n$ is one of the numbers $p, 2 p, \cdots,(p-1) p$, i.e., $n=k p(1 \leqslant k \leqslant p-1)$. If $k>1$, then the smallest prime factor of $k$ is less than $p$, which contradicts " $p$ is the smallest prime factor of $n$". Therefore, $n=p$, at this time $\varphi(m)=\varphi(2 p)=p$. If $p$ is odd, then $\varphi(2 p)=p-1$, which contradicts $\varphi(2 p)=p$. So $p=2$, hence $n=2, m=4$.