#!/usr/bin/env python3
"""
Skeleton solution for the Options Pricing Engine challenge.
Your task: implement the Black-Scholes pricing model and Greeks calculation.
"""

import sys
import math


def normal_cdf(x):
    """
    TODO: Implement cumulative standard normal distribution N(x)
    Hint: Use math.erf(x) with the formula: N(x) = 0.5 * (1 + erf(x / sqrt(2)))
    """
    # Implement this
    return 0.0


def normal_pdf(x):
    """
    TODO: Implement standard normal probability density function n(x)
    Formula: n(x) = exp(-x^2/2) / sqrt(2*pi)
    """
    # Implement this
    return 0.0


def compute_option(S, K, T, r, sigma, option_type):
    """
    TODO: Implement Black-Scholes pricing and Greeks calculation.

    Parameters:
    - S: Current underlying (spot) price
    - K: Strike price
    - T: Time to expiry (in years)
    - r: Risk-free interest rate
    - sigma: Volatility (annualized)
    - option_type: 'C' for call, 'P' for put

    Returns: (price, delta, gamma, vega, theta, rho)

    Black-Scholes formulas:
    - d1 = (ln(S/K) + (r + sigma^2/2) * T) / (sigma * sqrt(T))
    - d2 = d1 - sigma * sqrt(T)

    - Call Price = S * N(d1) - K * e^(-rT) * N(d2)
    - Put Price  = K * e^(-rT) * N(-d2) - S * N(-d1)

    Greeks:
    - Delta_Call = N(d1),           Delta_Put = N(d1) - 1
    - Gamma = n(d1) / (S * sigma * sqrt(T))
    - Vega = S * n(d1) * sqrt(T)
    - Theta_Call = -(S * n(d1) * sigma) / (2 * sqrt(T)) - r * K * e^(-rT) * N(d2)
    - Theta_Put  = -(S * n(d1) * sigma) / (2 * sqrt(T)) + r * K * e^(-rT) * N(-d2)
    - Rho_Call = K * T * e^(-rT) * N(d2)
    - Rho_Put  = -K * T * e^(-rT) * N(-d2)
    """

    # Compute d1 and d2
    # TODO: Implement

    # Get normal CDF and PDF values
    # TODO: Compute N(d1), N(d2), N(-d1), N(-d2), n(d1)

    # Compute discount factor
    # TODO: disc = e^(-rT)

    # Compute price and Greeks based on option type
    # TODO: if option_type == 'C': (call)
    # TODO: else: (put)

    price = 0.0   # TODO
    delta = 0.0   # TODO
    gamma = 0.0   # TODO
    vega = 0.0    # TODO
    theta = 0.0   # TODO
    rho = 0.0     # TODO

    return (price, delta, gamma, vega, theta, rho)


def main():
    # Read all input at once
    lines = sys.stdin.read().strip().split('\n')

    N = int(lines[0])

    # Process each option contract
    for i in range(1, N + 1):
        parts = lines[i].split(',')
        S = float(parts[0])
        K = float(parts[1])
        T = float(parts[2])
        r = float(parts[3])
        sigma = float(parts[4])
        option_type = parts[5].strip()

        price, delta, gamma, vega, theta, rho = compute_option(S, K, T, r, sigma, option_type)

        # Output with 6 decimal places
        print(f"{price:.6f} {delta:.6f} {gamma:.6f} {vega:.6f} {theta:.6f} {rho:.6f}")


if __name__ == "__main__":
    main()
