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

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

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

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

d.u = b
d.q = m
d.y = c
c.s = d
c.z = b
m.v = a
m.r = a
i.u = c
i.y = c
i.q = a
e.v = a
e.r = a
a.v = e
a.r = e
b.s = i
b.z = c
assert c.s.u.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: C = None
        self.y: B = None
        self.txt = txt

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

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

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

d.u = b
d.q = m
d.y = c
c.s = d
c.z = b
m.v = a
m.r = a
i.u = c
i.y = c
i.q = a
e.v = a
e.r = a
a.v = e
a.r = e
b.s = i
b.z = c
assert c.s.u.z.s.q.txt == "m"