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

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: A = None
        self.r: C = None
        self.v: A = None
        self.x: A = None
        self.txt = txt

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

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

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

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

k.p = h
m.w = c
m.s = k
m.v = k
m.x = k
m.r = n
n.o = c
n.w = m
n.r = h
n.p = j
h.v = k
h.y = m
h.o = c
c.o = m
j.o = m
assert c.o.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: A = None
        self.r: C = None
        self.v: A = None
        self.x: A = None
        self.txt = txt

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

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

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

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

k.p = h
m.w = c
m.s = k
m.v = k
m.x = k
m.r = n
n.o = c
n.w = m
n.r = h
n.p = j
h.v = k
h.y = m
h.o = c
c.o = m
j.o = m
assert c.o.v.p.txt == "h"