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

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

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

a = A("a")
d = B("d")
l = C("l")
k = A("k")
i = B("i")
b = C("b")
e = B("e")

a.u = l
d.w = a
d.y = a
d.u = b
l.t = b
k.u = l
i.w = a
i.y = a
i.u = l
b.t = l
e.w = a
e.y = k
e.u = l
assert b.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
l = C("l")
k = A("k")
i = B("i")
b = C("b")
e = B("e")

a.u = l
d.w = a
d.y = a
d.u = b
l.t = b
k.u = l
i.w = a
i.y = a
i.u = l
b.t = l
e.w = a
e.y = k
e.u = l
assert b.t.t.t.t.t.t.txt == "b"