
def is_prime(n)
  if n <= 3            # edge cases
    return n > 1       # false if n is negative!
  elsif n % 2 == 0 or n % 3 == 0      # n is divisible by 2 or by 3
    return false
  end

  i = 5                               # 6k-1 for k = 1
  while i ** 2 <= n                   # same as i <= sqrt(n) but faster and more precise.
    if n % i == 0 or n % (i+2) == 0   # is divisible by 6k-1 or 6k+1?
      return false
    end
    i += 6                            # k = k+1
  end

  return true
end


# Program interface
input = eval(gets).map { |item| item.to_i }    # Assume the user inputs an array of integers
p input.filter{|i| is_prime(i)}.map{|i| i**2}  # Filter primes then squares
