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

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

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

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

e = A("e")
k = B("k")
f = C("f")
l = D("l")
i = D("i")
m = A("m")
d = B("d")
g = C("g")
j = C("j")
h = D("h")

e.y = k
k.z = f
f.z = g
f.w = m
l.s = f
i.s = f
m.y = d
d.z = j
g.z = j
g.w = e
j.z = g
j.w = e
h.s = f
assert f.w.y.z.z.w.y.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

e = A("e")
k = B("k")
f = C("f")
l = D("l")
i = D("i")
m = A("m")
d = B("d")
g = C("g")
j = C("j")
h = D("h")

e.y = k
k.z = f
f.z = g
f.w = m
l.s = f
i.s = f
m.y = d
d.z = j
g.z = j
g.w = e
j.z = g
j.w = e
h.s = f
assert f.w.y.z.z.w.y.z.z.txt == "g"