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

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

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

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

m = A("m")
l = B("l")
k = C("k")
b = D("b")
e = C("e")
g = D("g")
h = B("h")
n = D("n")
i = B("i")

m.w = n
l.x = i
l.r = e
k.w = m
b.v = k
e.w = m
g.v = k
h.x = l
h.r = k
n.v = k
i.x = h
i.r = e
assert h.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
k = C("k")
b = D("b")
e = C("e")
g = D("g")
h = B("h")
n = D("n")
i = B("i")

m.w = n
l.x = i
l.r = e
k.w = m
b.v = k
e.w = m
g.v = k
h.x = l
h.r = k
n.v = k
i.x = h
i.r = e
assert h.x.x.x.txt == "h"