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

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

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

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

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

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

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

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

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

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

j.o = e
j.z = m
m.z = e
m.s = h
m.u = j
h.q = j
e.z = m
e.o = m
e.p = m
e.u = j
assert h.q.z.u.txt == "j"