def inverse(n, r, arr)
  p = 1
  (r+2).times do |i|
    arr[i]= p / n
    p = (p % n) * 10
  end
end

def add(r, arr)
  up = 0
  (r+1).downto(0) do |i|
    $arr[i] += arr[i] + up
    up = $arr[i] / 10
    $arr[i] %= 10
  end
end


while true
  $arr = []
  n, k, m, r = gets.split.map(&:to_i)
  break if n == 0
  inverse(n, r, $arr)
  if m == 1
    tmp = []
    (1..n-1).each do |i|
      inverse(n*i, r, tmp)
      add(r, tmp)
    end
  end
  puts [$arr[0], $arr[1,r].join('')].join('.')
end