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

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

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

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

k = A("k")
e = B("e")
b = C("b")
a = D("a")
f = C("f")

k.s = b
e.x = a
e.o = k
b.v = a
a.y = k
a.w = b
f.v = a
assert e.x.y.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

k = A("k")
e = B("e")
b = C("b")
a = D("a")
f = C("f")

k.s = b
e.x = a
e.o = k
b.v = a
a.y = k
a.w = b
f.v = a
assert e.x.y.s.v.txt == "a"