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

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

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

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

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

k.v = i
k.w = b
d.t = k
i.z = n
i.v = d
b.z = k
n.z = k
f.z = k
e.z = k
assert b.z.v.v.t.w.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: D = None
        self.txt = txt

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

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

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

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

k.v = i
k.w = b
d.t = k
i.z = n
i.v = d
b.z = k
n.z = k
f.z = k
e.z = k
assert b.z.v.v.t.w.z.v.txt == "i"