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

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

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

i = A("i")
f = B("f")
h = C("h")
e = A("e")
m = C("m")
j = C("j")

i.s = f
i.t = f
i.u = e
f.t = e
f.r = i
h.t = f
e.s = f
e.t = f
e.u = i
m.t = f
j.t = f
assert i.s.t.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.u: A = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
h = C("h")
e = A("e")
m = C("m")
j = C("j")

i.s = f
i.t = f
i.u = e
f.t = e
f.r = i
h.t = f
e.s = f
e.t = f
e.u = i
m.t = f
j.t = f
assert i.s.t.s.t.s.txt == "f"