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

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

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

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

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

b.u = i
b.y = j
b.q = j
j.s = d
j.z = b
j.v = b
i.o = j
i.r = j
i.z = d
i.t = d
d.x = i
d.u = i
d.p = b
d.q = b
assert j.z.u.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: B = None
        self.q: B = None
        self.txt = txt

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

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

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

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

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