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

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

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

e = A("e")
a = B("a")
j = C("j")
c = A("c")
n = C("n")
m = B("m")

e.r = m
e.z = c
a.u = j
a.z = m
j.x = m
j.o = a
c.r = m
c.z = e
n.x = m
n.o = a
m.u = j
m.z = a
assert c.r.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: A = None
        self.txt = txt

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

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

e = A("e")
a = B("a")
j = C("j")
c = A("c")
n = C("n")
m = B("m")

e.r = m
e.z = c
a.u = j
a.z = m
j.x = m
j.o = a
c.r = m
c.z = e
n.x = m
n.o = a
m.u = j
m.z = a
assert c.r.u.o.txt == "a"