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

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

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

a = A("a")
m = B("m")
n = C("n")
e = A("e")
k = C("k")

a.x = n
a.y = e
a.z = k
m.o = k
m.r = a
m.t = a
n.o = k
e.x = k
e.z = k
e.y = a
k.o = n
assert e.x.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: A = None
        self.z: C = None
        self.txt = txt

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

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

a = A("a")
m = B("m")
n = C("n")
e = A("e")
k = C("k")

a.x = n
a.y = e
a.z = k
m.o = k
m.r = a
m.t = a
n.o = k
e.x = k
e.z = k
e.y = a
k.o = n
assert e.x.o.o.o.txt == "n"