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

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

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

c = A("c")
l = B("l")
d = C("d")
f = A("f")
a = C("a")
e = B("e")
j = C("j")

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

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

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

c = A("c")
l = B("l")
d = C("d")
f = A("f")
a = C("a")
e = B("e")
j = C("j")

c.z = e
c.s = e
c.w = a
l.z = c
l.s = f
d.y = e
f.z = l
f.s = e
f.w = d
a.y = l
e.z = c
e.s = c
j.y = e
assert a.y.z.w.y.txt == "l"