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

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

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

j = A("j")
n = B("n")
l = C("l")
b = B("b")
i = A("i")
g = A("g")
c = B("c")
k = A("k")
d = C("d")

j.w = b
n.t = j
n.w = l
l.x = c
l.y = b
b.t = j
b.w = l
i.w = c
g.w = b
c.t = g
c.w = l
k.w = c
d.x = b
d.y = b
assert b.t.w.w.y.t.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
l = C("l")
b = B("b")
i = A("i")
g = A("g")
c = B("c")
k = A("k")
d = C("d")

j.w = b
n.t = j
n.w = l
l.x = c
l.y = b
b.t = j
b.w = l
i.w = c
g.w = b
c.t = g
c.w = l
k.w = c
d.x = b
d.y = b
assert b.t.w.w.y.t.w.t.w.txt == "b"