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

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

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

d = A("d")
h = B("h")
k = C("k")
g = C("g")
c = C("c")
f = B("f")
l = A("l")
m = A("m")

d.t = k
h.o = l
h.v = f
h.w = k
k.o = h
g.o = f
c.o = f
f.o = l
f.v = h
f.w = g
l.t = c
m.t = c
assert f.w.o.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
k = C("k")
g = C("g")
c = C("c")
f = B("f")
l = A("l")
m = A("m")

d.t = k
h.o = l
h.v = f
h.w = k
k.o = h
g.o = f
c.o = f
f.o = l
f.v = h
f.w = g
l.t = c
m.t = c
assert f.w.o.v.v.v.v.txt == "f"