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

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

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

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

a = A("a")
m = B("m")
j = C("j")
i = D("i")

a.u = i
m.p = a
j.y = i
j.t = a
j.o = a
j.q = m
i.q = a
i.x = a
assert m.p.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
j = C("j")
i = D("i")

a.u = i
m.p = a
j.y = i
j.t = a
j.o = a
j.q = m
i.q = a
i.x = a
assert m.p.u.x.txt == "a"