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

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

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

m = A("m")
g = B("g")
e = C("e")
b = C("b")
d = C("d")
i = C("i")
c = C("c")
h = B("h")
l = A("l")
n = B("n")

m.y = h
g.t = b
g.u = m
e.w = h
b.w = g
d.w = g
i.w = g
c.w = n
h.t = i
h.u = l
l.y = h
n.t = d
n.u = m
assert b.w.u.y.u.y.u.y.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
e = C("e")
b = C("b")
d = C("d")
i = C("i")
c = C("c")
h = B("h")
l = A("l")
n = B("n")

m.y = h
g.t = b
g.u = m
e.w = h
b.w = g
d.w = g
i.w = g
c.w = n
h.t = i
h.u = l
l.y = h
n.t = d
n.u = m
assert b.w.u.y.u.y.u.y.t.w.t.txt == "b"