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

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

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

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

m = A("m")
a = B("a")
l = C("l")
b = D("b")
i = A("i")
f = A("f")
d = C("d")
e = B("e")
h = B("h")

m.w = b
a.x = m
l.u = b
b.w = a
i.w = b
f.w = b
d.u = b
e.x = m
h.x = m
assert f.w.w.x.w.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

m = A("m")
a = B("a")
l = C("l")
b = D("b")
i = A("i")
f = A("f")
d = C("d")
e = B("e")
h = B("h")

m.w = b
a.x = m
l.u = b
b.w = a
i.w = b
f.w = b
d.u = b
e.x = m
h.x = m
assert f.w.w.x.w.w.x.w.txt == "b"