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

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

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

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

g = A("g")
i = B("i")
j = C("j")
m = D("m")
h = B("h")
l = C("l")

g.w = m
g.y = i
i.x = g
i.o = l
i.t = l
j.y = i
j.z = i
m.w = h
h.x = g
h.o = l
h.t = j
l.y = h
l.z = i
assert m.w.o.z.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: B = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
j = C("j")
m = D("m")
h = B("h")
l = C("l")

g.w = m
g.y = i
i.x = g
i.o = l
i.t = l
j.y = i
j.z = i
m.w = h
h.x = g
h.o = l
h.t = j
l.y = h
l.z = i
assert m.w.o.z.x.y.txt == "i"