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

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

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

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

d = A("d")
k = B("k")
i = C("i")
f = D("f")

d.w = i
k.y = d
k.u = i
k.p = f
i.r = d
i.t = d
i.q = k
i.v = k
f.p = k
f.z = k
f.s = d
assert f.s.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

d = A("d")
k = B("k")
i = C("i")
f = D("f")

d.w = i
k.y = d
k.u = i
k.p = f
i.r = d
i.t = d
i.q = k
i.v = k
f.p = k
f.z = k
f.s = d
assert f.s.w.r.w.txt == "i"