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

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

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

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

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

n = A("n")
l = B("l")
j = C("j")
h = D("h")
f = E("f")
b = A("b")

n.p = l
l.r = h
j.q = f
j.w = l
h.w = l
h.z = b
h.x = j
h.v = n
h.u = f
f.w = j
f.z = l
f.v = h
b.p = l
assert l.r.u.v.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

n = A("n")
l = B("l")
j = C("j")
h = D("h")
f = E("f")
b = A("b")

n.p = l
l.r = h
j.q = f
j.w = l
h.w = l
h.z = b
h.x = j
h.v = n
h.u = f
f.w = j
f.z = l
f.v = h
b.p = l
assert l.r.u.v.z.p.txt == "l"