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

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

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

b = A("b")
j = B("j")
g = C("g")
e = A("e")
h = B("h")
i = A("i")
d = A("d")
a = B("a")
c = C("c")
l = C("l")

b.z = i
j.w = c
g.p = e
e.z = d
h.w = g
i.z = d
d.z = b
a.w = l
c.p = b
l.p = d
assert h.w.p.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
g = C("g")
e = A("e")
h = B("h")
i = A("i")
d = A("d")
a = B("a")
c = C("c")
l = C("l")

b.z = i
j.w = c
g.p = e
e.z = d
h.w = g
i.z = d
d.z = b
a.w = l
c.p = b
l.p = d
assert h.w.p.z.z.z.txt == "i"