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

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

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

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

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

j = A("j")
d = B("d")
h = C("h")
b = D("b")
m = E("m")
g = C("g")
l = A("l")
c = B("c")
n = C("n")

j.p = m
j.s = m
j.y = b
j.w = l
j.q = d
d.w = l
d.x = b
d.v = b
h.z = n
b.o = h
m.s = h
m.q = h
g.z = n
l.p = m
l.s = m
l.y = b
l.w = j
l.q = d
c.w = j
c.x = b
c.v = b
n.z = h
assert d.w.s.q.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.y: D = None
        self.w: A = None
        self.q: B = None
        self.s: E = None
        self.txt = txt

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

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

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

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

j = A("j")
d = B("d")
h = C("h")
b = D("b")
m = E("m")
g = C("g")
l = A("l")
c = B("c")
n = C("n")

j.p = m
j.s = m
j.y = b
j.w = l
j.q = d
d.w = l
d.x = b
d.v = b
h.z = n
b.o = h
m.s = h
m.q = h
g.z = n
l.p = m
l.s = m
l.y = b
l.w = j
l.q = d
c.w = j
c.x = b
c.v = b
n.z = h
assert d.w.s.q.z.z.txt == "h"