class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: B = None
        self.p: D = None
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: E = None
        self.z: A = None
        self.o: A = None
        self.p: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: D = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

k = A("k")
h = B("h")
m = C("m")
f = D("f")
c = E("c")

k.w = m
k.t = h
k.r = h
k.p = f
h.t = m
m.s = f
m.p = f
m.r = c
m.z = k
m.o = k
f.o = m
f.w = m
c.r = f
c.w = f
c.v = k
c.p = m
assert m.o.p.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: B = None
        self.p: D = None
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: E = None
        self.z: A = None
        self.o: A = None
        self.p: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: D = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

k = A("k")
h = B("h")
m = C("m")
f = D("f")
c = E("c")

k.w = m
k.t = h
k.r = h
k.p = f
h.t = m
m.s = f
m.p = f
m.r = c
m.z = k
m.o = k
f.o = m
f.w = m
c.r = f
c.w = f
c.v = k
c.p = m
assert m.o.p.w.r.txt == "c"