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

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

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

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

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

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

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

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

i.u = d
m.s = e
d.r = n
e.u = d
n.r = d
assert d.r.r.r.txt == "n"