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

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

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

f = A("f")
m = B("m")
n = C("n")

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

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

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

f = A("f")
m = B("m")
n = C("n")

f.o = n
f.t = m
m.r = n
m.z = n
n.x = f
assert m.z.x.t.txt == "m"