Multiply both sides by Q(x) to get F(x) = G(x) for all x such that Q(x)!=0. There is only a finite # of such x (if Q is a non-zero polynomial) hence we have two polynomials agreeing together for an infinite number of different values thus it must be the same polynomial. And thus F(x) = G(x) for any x.