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

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

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

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

h = A("h")
e = B("e")
b = C("b")
i = D("i")
c = B("c")
j = D("j")
m = C("m")

h.w = b
e.x = m
b.o = m
b.y = h
b.z = h
b.w = i
i.z = j
i.o = j
c.x = b
j.z = i
j.o = i
m.o = b
m.y = h
m.z = h
m.w = i
assert e.x.o.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

h = A("h")
e = B("e")
b = C("b")
i = D("i")
c = B("c")
j = D("j")
m = C("m")

h.w = b
e.x = m
b.o = m
b.y = h
b.z = h
b.w = i
i.z = j
i.o = j
c.x = b
j.z = i
j.o = i
m.o = b
m.y = h
m.z = h
m.w = i
assert e.x.o.o.w.txt == "i"