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

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

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

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

b = A("b")
m = B("m")
k = C("k")
j = D("j")
e = C("e")

b.s = e
m.s = e
k.x = e
k.o = e
k.v = m
j.q = b
j.x = e
e.x = k
e.o = k
e.v = m
assert e.v.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
k = C("k")
j = D("j")
e = C("e")

b.s = e
m.s = e
k.x = e
k.o = e
k.v = m
j.q = b
j.x = e
e.x = k
e.o = k
e.v = m
assert e.v.s.o.txt == "k"