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

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

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

a = A("a")
l = B("l")
d = C("d")
j = C("j")
k = A("k")
c = B("c")
i = A("i")

a.t = j
l.t = c
l.w = i
d.x = a
d.s = c
j.x = i
j.s = l
k.t = d
c.t = l
c.w = i
i.t = j
assert l.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
d = C("d")
j = C("j")
k = A("k")
c = B("c")
i = A("i")

a.t = j
l.t = c
l.w = i
d.x = a
d.s = c
j.x = i
j.s = l
k.t = d
c.t = l
c.w = i
i.t = j
assert l.t.t.t.t.t.txt == "c"