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

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

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

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

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

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

h.t = e
g.p = h
g.v = h
e.s = k
k.o = g
b.r = k
a.p = h
a.v = h
assert k.o.v.t.s.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

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

h.t = e
g.p = h
g.v = h
e.s = k
k.o = g
b.r = k
a.p = h
a.v = h
assert k.o.v.t.s.o.v.txt == "h"