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

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

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

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

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

e = A("e")
n = B("n")
a = C("a")
b = D("b")
d = E("d")
f = C("f")
c = E("c")

e.z = b
e.q = n
e.w = n
e.x = d
n.y = c
a.o = e
a.q = f
b.p = a
d.s = a
f.o = e
f.q = a
c.s = a
assert c.s.q.q.q.o.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: B = None
        self.w: B = None
        self.x: E = None
        self.txt = txt

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

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

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

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

e = A("e")
n = B("n")
a = C("a")
b = D("b")
d = E("d")
f = C("f")
c = E("c")

e.z = b
e.q = n
e.w = n
e.x = d
n.y = c
a.o = e
a.q = f
b.p = a
d.s = a
f.o = e
f.q = a
c.s = a
assert c.s.q.q.q.o.z.p.txt == "a"