package com.javarush.task.task06.task0621;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
Родственные связи кошек
*/

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String grandPapaName = reader.readLine();
        Cat catGrandPapa = new Cat(grandPapaName, null, null);

        String granMotherName = reader.readLine();
        Cat catGrandMother = new Cat(granMotherName, null, null);

        String fatherName = reader.readLine();
        Cat catFather = new Cat(fatherName, null, catGrandPapa);

        String motherName = reader.readLine();
        Cat catMother = new Cat(motherName, catGrandMother, null);

        String sonName = reader.readLine();
        Cat catSon = new Cat(sonName, catMother, catFather);

        String daughterName = reader.readLine();
        Cat catDaughter = new Cat(daughterName, catMother, catFather);

        System.out.println(catGrandPapa);
        System.out.println(catGrandMother);
        System.out.println(catFather);
        System.out.println(catMother);
        System.out.println(catSon);
        System.out.println(catDaughter);
    }

    public static class Cat {
        private String name;
        private Cat parent1;
        private Cat parent2;


        Cat(String name, Cat parent1, Cat parent2)  {
            this.name = name;
            this.parent1 = parent1;
             this.parent2 = parent2;
        }

        @Override
        public String toString() {
            String s = "The cat's name is " + name;
            if (parent1 == null){
                return  s = s +", no mother" ;
            }
            else{
                s += ", mother is " + parent1.name;
            }

            if (parent2 == null){
                return  s = s +", no father" ;
            }
            else{
                s += ", father is " + parent2.name;
            }
            return s;
        }
    }

}