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

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

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.s: C = None
        self.o: E = None
        self.z: B = None
        self.txt = txt

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

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

c.p = l
l.q = a
d.q = a
a.y = b
a.o = b
a.s = d
a.z = l
m.t = l
m.q = c
m.p = a
m.s = a
m.z = d
g.p = l
b.t = l
b.q = g
b.p = a
b.s = a
b.z = d
assert g.p.q.s.q.o.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.s: C = None
        self.o: E = None
        self.z: B = None
        self.txt = txt

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

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

c.p = l
l.q = a
d.q = a
a.y = b
a.o = b
a.s = d
a.z = l
m.t = l
m.q = c
m.p = a
m.s = a
m.z = d
g.p = l
b.t = l
b.q = g
b.p = a
b.s = a
b.z = d
assert g.p.q.s.q.o.t.q.txt == "a"