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

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

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

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

i = A("i")
m = B("m")
e = C("e")
f = D("f")
k = D("k")

i.z = e
m.q = k
e.w = k
e.v = i
e.s = m
f.u = i
f.o = i
f.w = m
k.u = i
k.o = i
k.w = m
assert f.u.z.w.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

i = A("i")
m = B("m")
e = C("e")
f = D("f")
k = D("k")

i.z = e
m.q = k
e.w = k
e.v = i
e.s = m
f.u = i
f.o = i
f.w = m
k.u = i
k.o = i
k.w = m
assert f.u.z.w.w.q.txt == "k"