Answe
a)  Q = 0.820 10⁻⁹ C
,   b)  Q = -3.52 10⁻⁹ C
Explanation:
The electric field is given by the formula
          E = k q / r²
where E is a vector quantity, so it must be added as a vector
           E_total = E₁ + E₂
let's look for the two electric fields
            E₁ = k q₁ / r₁²
            E₁ = 9 10⁹  5.4 10⁻⁹ / 1.25²
            E₁ = 31.10 N / C
            E2 = k Q / r₂²
            E2 = 9 10⁹ Q / 0.625²
            E2 = 23.04 10⁹ Q N / C           (1)
now we can solve the two cases presented
a) The total field is
             E_total = 50.0 N / C towards + x
since the test charge is positive the electric field E1 points to the right in the direction of the + x axis, so the equation is
             E_total = E1 + E₂
              E₂ = E_toal - E₁
              E₂ = 50.0 -31.10
              E2 = 18.9 N /C
With the value of the electric field we can calculate the charge (Q) using equation 1
              E₂ = 23.04 10⁹ Q
               Q = E₂ / 23.04 10⁹
               Q = 18.9 / 23.04 10⁹
               Q = 0.820 10⁻⁹ C
the charge on Q is positive
b) E_total = -50.0 N / C
               E_total = E₁ + E₂
               E₂ = E_total - E₁
               E2 = -50.0 - 31.10
                E2 = -81.10 N /C
we calculate the charge
              Q = E2 / 23.04 10⁹
              Q = -81.1 / 23.04 10⁹
               Q = -3.52 10⁻⁹ C
for this case the charge is negative