class A:
    def __init__(self, txt: str):
        self.s: C = 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.v: D = None
        self.x: D = None
        self.o: B = None
        self.txt = txt

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

b = A("b")
j = B("j")
d = C("d")
i = D("i")

b.s = d
j.p = b
d.y = i
d.v = i
d.x = i
d.o = j
i.q = b
i.y = j
i.p = j
i.u = j
assert j.p.s.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = 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.v: D = None
        self.x: D = None
        self.o: B = None
        self.txt = txt

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

b = A("b")
j = B("j")
d = C("d")
i = D("i")

b.s = d
j.p = b
d.y = i
d.v = i
d.x = i
d.o = j
i.q = b
i.y = j
i.p = j
i.u = j
assert j.p.s.x.p.txt == "j"