public class Solution {
    public static void main(String[] args) {
        //напишите тут ваш код
        ArrayList<Human> list = new ArrayList<Human>();
        list.add(new Human("Таня", false, 60));
        list.add(new Human("Сергей", true, 63));
        list.add(new Human("Таня", false, 62));
        list.add(new Human("Владимир", true, 68));
        list.add(new Human("Александр", true, 40, list.get(0), list.get(1)));
        list.add(new Human("Светлана", false, 39, list.get(2), list.get(3)));
        list.add(new Human("Алексей", true, 17, list.get(4), list.get(5)));
        list.add(new Human("Андрей", true, 11, list.get(4), list.get(5)));
        list.add(new Human("Елена", false, 7, list.get(4), list.get(5)));
        for (int i = 0; i < list.size(); i++) {
            list.get(i).toString();
        }

    }

    public static class Human {
        //напишите тут ваш код
        private String name;
        private boolean sex;
        private int age;
        public Human father;
        public Human mother;

        public Human(String name, boolean sex, int age){
            this.name = name;
            this.sex = sex;
            this.age = age;
        }
        public Human(String name, boolean sex, int age, Human father, Human mother){
            this.name = name;
            this.sex = sex;
            this.age = age;
            this.father = father;
            this.mother = mother;
        }

        public String toString() {
            String text = "";
            text += "Имя: " + this.name;
            text += ", пол: " + (this.sex ? "мужской" : "женский");
            text += ", возраст: " + this.age;

            if (this.father != null)
                text += ", отец: " + this.father.name;

            if (this.mother != null)
                text += ", мать: " + this.mother.name;

            return text;
        }
    }
}