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

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

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

i = A("i")
g = B("g")
m = C("m")
k = B("k")
e = A("e")

i.r = m
i.z = m
g.q = m
g.y = m
g.w = e
m.u = g
m.s = i
k.q = m
k.y = m
k.w = e
e.r = m
e.z = m
assert m.u.q.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
m = C("m")
k = B("k")
e = A("e")

i.r = m
i.z = m
g.q = m
g.y = m
g.w = e
m.u = g
m.s = i
k.q = m
k.y = m
k.w = e
e.r = m
e.z = m
assert m.u.q.s.z.s.txt == "i"