class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: A = 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.s: C = None
        self.txt = txt

l = A("l")
j = B("j")
h = C("h")
i = C("i")
f = A("f")
d = A("d")

l.t = i
l.x = d
j.s = l
h.s = i
i.s = h
f.t = i
f.x = d
d.t = i
d.x = f
assert l.t.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: A = 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.s: C = None
        self.txt = txt

l = A("l")
j = B("j")
h = C("h")
i = C("i")
f = A("f")
d = A("d")

l.t = i
l.x = d
j.s = l
h.s = i
i.s = h
f.t = i
f.x = d
d.t = i
d.x = f
assert l.t.s.s.s.s.txt == "i"