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

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

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

f = A("f")
d = B("d")
b = C("b")
a = A("a")
i = C("i")
c = A("c")
e = B("e")

f.z = d
f.w = c
f.y = b
d.s = e
b.z = c
a.z = d
a.w = c
a.y = i
i.z = a
c.z = d
c.w = f
c.y = i
e.s = d
assert e.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: A = None
        self.y: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
b = C("b")
a = A("a")
i = C("i")
c = A("c")
e = B("e")

f.z = d
f.w = c
f.y = b
d.s = e
b.z = c
a.z = d
a.w = c
a.y = i
i.z = a
c.z = d
c.w = f
c.y = i
e.s = d
assert e.s.s.s.s.s.txt == "d"