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

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

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

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

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

l = A("l")
f = B("f")
e = C("e")
n = D("n")
m = E("m")
a = A("a")
h = A("h")

l.w = f
f.v = l
f.z = m
e.y = n
e.x = a
n.x = m
n.u = m
m.p = n
m.t = f
m.v = f
m.q = e
a.w = f
h.w = f
assert l.w.v.w.z.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

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

l = A("l")
f = B("f")
e = C("e")
n = D("n")
m = E("m")
a = A("a")
h = A("h")

l.w = f
f.v = l
f.z = m
e.y = n
e.x = a
n.x = m
n.u = m
m.p = n
m.t = f
m.v = f
m.q = e
a.w = f
h.w = f
assert l.w.v.w.z.p.u.txt == "m"