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

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

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

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

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

i.w = e
i.u = e
i.q = k
m.p = k
e.w = m
k.x = i
assert k.x.u.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

i.w = e
i.u = e
i.q = k
m.p = k
e.w = m
k.x = i
assert k.x.u.w.p.txt == "k"