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

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

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

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

k = A("k")
h = B("h")
g = C("g")
e = D("e")

k.x = e
k.r = e
h.w = e
g.u = h
g.w = k
e.v = g
e.s = g
e.z = k
e.o = k
assert e.v.u.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: D = None
        self.txt = txt

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

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

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

k = A("k")
h = B("h")
g = C("g")
e = D("e")

k.x = e
k.r = e
h.w = e
g.u = h
g.w = k
e.v = g
e.s = g
e.z = k
e.o = k
assert e.v.u.w.s.txt == "g"