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

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

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

e = A("e")
k = B("k")
c = C("c")
i = C("i")
j = B("j")
a = C("a")
b = B("b")
d = C("d")
l = A("l")
m = C("m")

e.z = c
k.w = e
c.r = b
i.r = k
j.w = l
a.r = j
b.w = e
d.r = j
l.z = i
m.r = j
assert e.z.r.w.z.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
c = C("c")
i = C("i")
j = B("j")
a = C("a")
b = B("b")
d = C("d")
l = A("l")
m = C("m")

e.z = c
k.w = e
c.r = b
i.r = k
j.w = l
a.r = j
b.w = e
d.r = j
l.z = i
m.r = j
assert e.z.r.w.z.r.w.txt == "e"