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

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

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

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

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

h.y = m
h.p = b
h.z = b
h.o = i
b.s = h
m.s = i
m.z = i
m.u = b
i.z = m
i.o = m
i.q = h
i.s = h
assert m.u.s.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: B = None
        self.o: D = None
        self.z: B = None
        self.txt = txt

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

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

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

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

h.y = m
h.p = b
h.z = b
h.o = i
b.s = h
m.s = i
m.z = i
m.u = b
i.z = m
i.o = m
i.q = h
i.s = h
assert m.u.s.y.z.txt == "i"