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

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

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

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

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

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

b.p = a
b.y = m
b.o = g
d.u = m
d.z = m
d.p = b
a.r = d
m.z = i
m.y = a
i.q = a
i.p = a
i.z = m
i.y = g
i.t = d
g.q = a
g.p = a
g.z = m
g.y = i
g.t = d
assert b.p.r.p.o.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: D = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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

b.p = a
b.y = m
b.o = g
d.u = m
d.z = m
d.p = b
a.r = d
m.z = i
m.y = a
i.q = a
i.p = a
i.z = m
i.y = g
i.t = d
g.q = a
g.p = a
g.z = m
g.y = i
g.t = d
assert b.p.r.p.o.z.y.txt == "a"