Easy to prove that P must have rational coefficients.
If P has a degree d≥2, consider P(x)=qpxd+M1Q(x), where p,q∈Z, Q(x) is a polynomial of degree <d with integer coefficients. Suppose P(nm)=n1, m,n coprime.
We have Mnd−1P(nm)∈N, thus qn∣pMmd, and so n∣pM. However, n can be arbitrarily large, so pM=0, contradiction. Therefore, we must have d=1.
Assume P(x)=qpx+sr, gcd(p,q)=gcd(r,s)=1. The condition is equivalent to that for infinitely many coprime positive integer pairs (m,n),
psm+rqn=qs.
Let A=ps, B=qr, C=qs. We have gcd(A,B)∣C. We also must have AB≤0, otherwise ∣C∣=∣Am+Bn∣≥∣m+n∣, contradicting the existence of infinitely many solutions.
Conversely, if gcd(A,B)∣C and AB≤0, we can find integers a,b such that Aa+Bb=gcd(A,B). Let m=∣B∣t+Ca, n=∣A∣t+Cb, we have Am+Bn=C, and gcd(m,n)∣gcd(C,am−bn)=gcd(C,t+s), where s is some integer independent of t. Therefore, we have found large enough t so that m,n are positive and coprime.
So all solutions of P(x) are P(x)=qpx+sr, such that gcd(ps,qr)∣qs and qspr≤0. Since gcd(p,q)=gcd(r,s)=1, so gcd(ps,qr)=gcd(p,r)gcd(q,s), the first condition is equivalent to gcd(p,r)=1.