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

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: C = None
        self.txt = txt

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

a.w = g
g.o = e
f.p = c
f.t = e
d.p = c
d.t = e
h.o = e
e.p = c
e.t = d
c.w = h
assert d.t.t.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: C = None
        self.txt = txt

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

a.w = g
g.o = e
f.p = c
f.t = e
d.p = c
d.t = e
h.o = e
e.p = c
e.t = d
c.w = h
assert d.t.t.t.p.txt == "c"