### constant

MAX_MN = 20

### main

ccache = (MAX_MN + 1).times.map{[]}

for i in (0..MAX_MN)
  ccache[i][0] = ccache[i][i] = 1
  for j in (1...i)
    ccache[i][j] = ccache[i - 1][j] + ccache[i - 1][j - 1]
  end
end

loop do
  a, m, b, n = gets.split.map(&:to_i)
  break if (a | m | b | n) == 0
  #p [a, m, b, n]

  mn = m * n
  mn2 = mn * 2
  
  mtx = []
  mn.downto(0).each do |d|
    cs = mn.times.map{Rational(0)}
    for k in (0..d)
      ck = ccache[d][k] * (a ** (k / m)) * (b ** ((d - k) / n))
      m0 = k % m
      n0 = (d - k) % n
      cs[m0 * n + n0] += ck
    end
    mtx << cs.reverse
  end

  ad = mtx.shift.map{|t| -t}
  mtx = mtx.transpose
  #p ad
  #p mtx

  for i in (0...mn)
    if mtx[i][i] == 0
      i0 = i + 1
      while mtx[i0][i] == 0
        i0 += 1
      end
      for j in (i...mn)
        t = mtx[i][j]; mtx[i][j] = mtx[i0][j]; mtx[i0][j] = t
      end
      t = ad[i]; ad[i] = ad[i0]; ad[i0] = t
    end

    mii = mtx[i][i]
    if mii == 0
      puts "error"
      p i
      p mtx
      exit
    end
    (i...mn).each{|j| mtx[i][j] /= mii}
    ad[i] /= mii

    for j in ((i + 1)...mn)
      mji = mtx[j][i]
      (i...mn).each{|k| mtx[j][k] -= mji * mtx[i][k]}
      ad[j] -= mji * ad[i]
    end
  end
  #p mtx
  #p ad

  (mn - 1).downto(0).each do |i|
    ((i + 1)...mn).each{|j| ad[i] -= mtx[i][j] * ad[j]}
  end

  puts ([1] + ad.map{|d| d.to_i}).join(' ')
end