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

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

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

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

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

g = A("g")
b = B("b")
f = C("f")
a = D("a")
m = E("m")
h = B("h")

g.p = f
b.x = a
b.o = f
f.v = a
f.s = a
f.z = a
f.r = g
f.q = m
a.p = f
a.w = f
a.t = b
a.o = m
m.q = h
h.x = a
h.o = f
assert b.o.v.p.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

g = A("g")
b = B("b")
f = C("f")
a = D("a")
m = E("m")
h = B("h")

g.p = f
b.x = a
b.o = f
f.v = a
f.s = a
f.z = a
f.r = g
f.q = m
a.p = f
a.w = f
a.t = b
a.o = m
m.q = h
h.x = a
h.o = f
assert b.o.v.p.s.o.txt == "m"