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

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

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

l = A("l")
a = B("a")
m = C("m")
k = B("k")
g = C("g")
b = A("b")
h = C("h")
d = C("d")
f = A("f")
i = B("i")

l.w = f
l.v = m
a.p = b
a.y = d
m.z = g
k.p = f
k.y = d
g.z = d
b.w = f
b.v = d
h.z = d
d.z = h
f.w = l
f.v = m
i.p = l
i.y = g
assert g.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: C = None
        self.txt = txt

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

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

l = A("l")
a = B("a")
m = C("m")
k = B("k")
g = C("g")
b = A("b")
h = C("h")
d = C("d")
f = A("f")
i = B("i")

l.w = f
l.v = m
a.p = b
a.y = d
m.z = g
k.p = f
k.y = d
g.z = d
b.w = f
b.v = d
h.z = d
d.z = h
f.w = l
f.v = m
i.p = l
i.y = g
assert g.z.z.z.z.txt == "h"