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

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

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

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

k = A("k")
b = B("b")
m = C("m")
f = D("f")

k.w = b
b.r = m
m.y = b
m.q = k
m.u = k
m.x = f
f.o = b
f.v = m
f.s = m
assert m.y.r.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
m = C("m")
f = D("f")

k.w = b
b.r = m
m.y = b
m.q = k
m.u = k
m.x = f
f.o = b
f.v = m
f.s = m
assert m.y.r.u.w.txt == "b"