class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

b = A("b")
e = B("e")
h = C("h")
d = D("d")
k = E("k")
c = C("c")
j = B("j")

b.o = k
e.v = d
h.s = k
d.w = c
k.o = c
k.p = j
c.s = k
j.v = d
assert j.v.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

b = A("b")
e = B("e")
h = C("h")
d = D("d")
k = E("k")
c = C("c")
j = B("j")

b.o = k
e.v = d
h.s = k
d.w = c
k.o = c
k.p = j
c.s = k
j.v = d
assert j.v.w.s.txt == "k"