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

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

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

m = A("m")
d = B("d")
f = C("f")
n = A("n")
i = B("i")
e = C("e")

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

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

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

m = A("m")
d = B("d")
f = C("f")
n = A("n")
i = B("i")
e = C("e")

m.u = n
m.r = d
m.o = f
d.u = f
f.z = e
f.u = m
n.u = m
n.r = i
n.o = e
i.u = e
e.z = f
e.u = m
assert f.z.z.u.r.u.z.txt == "e"