def parse_fos(response, paper_id):
    """Parse the fields of study of a paper from a MAG API response.

    Args:
        response (json): Response from MAG API in JSON format. Contains all paper information.
        paper_id (int): Paper ID.

    Returns:
        fields_of_study (:obj:`list` of :obj:`dict`): List of dictionaries with fields of study information.
            There's one dictionary per field of study.
        paper_with_fos (:obj:`list` of :obj:`dict`): Matching fields of study and paper IDs.

    """
    # two outputs: fos_id with fos_name, fos_id with paper_id
    paper_with_fos = []
    fields_of_study = []
    for fos in response["F"]:
        # mag_fields_of_study
        fields_of_study.append(
            {"id": fos["FId"], "name": fos["DFN"], "norm_name": fos["FN"]}
        )
        # mag_paper_fields_of_study
        paper_with_fos.append({"field_of_study_id": fos["FId"], "paper_id": paper_id})

    return paper_with_fos, fields_of_study