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

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

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

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

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

h = A("h")
k = B("k")
d = C("d")
f = D("f")
c = E("c")
a = A("a")
g = C("g")

h.p = g
k.y = d
d.x = a
d.z = c
d.o = c
d.v = k
f.y = c
f.w = g
c.x = h
c.v = k
a.p = g
g.x = h
g.z = c
g.o = c
g.v = k
assert h.p.x.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

h = A("h")
k = B("k")
d = C("d")
f = D("f")
c = E("c")
a = A("a")
g = C("g")

h.p = g
k.y = d
d.x = a
d.z = c
d.o = c
d.v = k
f.y = c
f.w = g
c.x = h
c.v = k
a.p = g
g.x = h
g.z = c
g.o = c
g.v = k
assert h.p.x.p.v.txt == "k"