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

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: B = None
        self.z: B = None
        self.txt = txt

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

b = A("b")
d = B("d")
m = C("m")
h = D("h")
a = E("a")
c = A("c")

b.y = d
b.p = c
d.p = h
d.s = m
m.o = c
h.x = c
h.r = d
h.z = d
a.x = d
a.r = d
a.s = d
a.v = m
c.y = d
c.p = b
assert b.p.y.p.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: B = None
        self.z: B = None
        self.txt = txt

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

b = A("b")
d = B("d")
m = C("m")
h = D("h")
a = E("a")
c = A("c")

b.y = d
b.p = c
d.p = h
d.s = m
m.o = c
h.x = c
h.r = d
h.z = d
a.x = d
a.r = d
a.s = d
a.v = m
c.y = d
c.p = b
assert b.p.y.p.z.s.txt == "m"