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

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

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

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

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

d = A("d")
a = B("a")
i = C("i")
g = D("g")
l = E("l")
j = E("j")
m = B("m")
e = A("e")

d.y = l
d.p = m
a.r = g
a.p = g
a.y = g
a.z = i
i.z = e
g.t = e
g.q = d
g.p = i
g.s = m
l.w = j
l.p = g
j.w = l
j.p = g
m.r = g
m.p = g
m.y = g
m.z = i
e.y = j
e.p = m
assert g.s.z.z.y.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.p: B = None
        self.txt = txt

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

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

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

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

d = A("d")
a = B("a")
i = C("i")
g = D("g")
l = E("l")
j = E("j")
m = B("m")
e = A("e")

d.y = l
d.p = m
a.r = g
a.p = g
a.y = g
a.z = i
i.z = e
g.t = e
g.q = d
g.p = i
g.s = m
l.w = j
l.p = g
j.w = l
j.p = g
m.r = g
m.p = g
m.y = g
m.z = i
e.y = j
e.p = m
assert g.s.z.z.y.p.q.txt == "d"