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

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

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

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

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

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

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

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

a.z = j
e.y = f
e.w = a
e.x = j
j.x = a
c.z = j
k.y = f
k.w = a
k.x = j
l.y = g
l.w = a
l.x = j
g.y = l
g.w = c
g.x = j
f.y = k
f.w = a
f.x = j
assert k.w.z.x.z.x.z.x.z.txt == "j"