import re


def convert_fyq_to_fyp(fyq):
    """ Converts the fyq provided to fyp if it is in fyq format. Do nothing if it is already in fyp format

        Args:
            fyq: String to convert or leave alone fiscal year quarters

        Returns:
            FYQ converted to FYP or left the same
    """
    # If it's in quarter format, convert to period
    if re.match('^FY\d{2}Q\d$', str(fyq).upper().strip()):
        # Make sure it's all uppercase and replace the Q with a P
        fyq = fyq.upper().strip().replace('Q', 'P')
        # take the last character in the string (the quarter), multiply by 3, replace
        quarter = fyq[-1]
        period = str(int(quarter) * 3).zfill(2)
        fyq = fyq[:-1] + period
        return fyq
    return fyq