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

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

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

l = A("l")
g = B("g")
i = C("i")
a = A("a")
c = A("c")
m = C("m")
b = A("b")

l.u = g
g.t = a
g.w = b
i.t = g
i.w = g
i.z = m
a.u = g
c.u = g
m.t = g
m.w = g
m.z = i
b.u = g
assert g.w.u.w.u.t.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
i = C("i")
a = A("a")
c = A("c")
m = C("m")
b = A("b")

l.u = g
g.t = a
g.w = b
i.t = g
i.w = g
i.z = m
a.u = g
c.u = g
m.t = g
m.w = g
m.z = i
b.u = g
assert g.w.u.w.u.t.u.w.txt == "b"