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

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

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

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

j = A("j")
d = B("d")
i = C("i")
c = D("c")
k = D("k")

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

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

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

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

j = A("j")
d = B("d")
i = C("i")
c = D("c")
k = D("k")

j.q = d
j.w = i
j.y = k
d.s = c
d.v = k
i.t = k
i.r = k
i.x = j
c.o = j
c.u = j
c.q = d
c.w = k
k.o = j
k.u = j
k.q = d
k.w = c
assert d.s.w.u.q.s.txt == "c"