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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: A = None
        self.txt = txt

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

k = A("k")
e = B("e")
d = C("d")
c = D("c")

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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: A = None
        self.txt = txt

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

k = A("k")
e = B("e")
d = C("d")
c = D("c")

k.w = c
k.r = e
e.y = k
e.s = d
e.t = c
d.v = e
d.r = k
c.v = k
c.z = k
c.u = k
c.q = d
assert d.r.r.s.r.txt == "k"