class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: C = None
        self.txt = txt

e = A("e")
h = B("h")
d = C("d")
a = B("a")
f = C("f")

e.q = h
e.s = h
e.o = d
h.p = a
d.s = h
d.x = f
a.p = h
f.s = a
f.x = d
assert f.s.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: C = None
        self.txt = txt

e = A("e")
h = B("h")
d = C("d")
a = B("a")
f = C("f")

e.q = h
e.s = h
e.o = d
h.p = a
d.s = h
d.x = f
a.p = h
f.s = a
f.x = d
assert f.s.p.p.p.p.txt == "a"