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

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

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

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

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

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

d.u = l
j.w = d
j.r = h
j.p = m
n.z = l
n.p = j
n.u = c
c.q = h
m.y = d
m.s = d
m.q = c
l.z = n
l.p = j
l.u = c
h.y = d
h.s = d
h.q = c
assert c.q.s.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

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

d.u = l
j.w = d
j.r = h
j.p = m
n.z = l
n.p = j
n.u = c
c.q = h
m.y = d
m.s = d
m.q = c
l.z = n
l.p = j
l.u = c
h.y = d
h.s = d
h.q = c
assert c.q.s.u.p.txt == "j"