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

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

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

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

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

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

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

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

b.u = m
b.w = e
m.r = g
e.y = g
e.u = h
l.u = m
l.w = h
g.u = m
g.w = n
n.y = g
n.u = k
h.y = g
h.u = e
d.r = b
k.y = g
k.u = h
assert h.u.u.y.w.u.u.y.w.txt == "n"